Commit d7016138 authored by KingRainbow44's avatar KingRainbow44
Browse files

Formatting changes

parent e666dede
......@@ -8,13 +8,14 @@ import java.util.List;
@Command(label = "coop", usage = "coop",
description = "Forces someone to join the world of others", permission = "server.coop")
public class CoopCommand implements CommandHandler {
public final class CoopCommand implements CommandHandler {
@Override
public void execute(Player sender, List<String> args) {
if (args.size() < 2) {
CommandHandler.sendMessage(sender, "Usage: coop <playerId> <target playerId>");
return;
}
try {
int tid = Integer.parseInt(args.get(0));
int hostId = Integer.parseInt(args.get(1));
......
......@@ -15,7 +15,7 @@ import java.util.*;
@Command(label = "giveall", usage = "giveall [player] [amount]",
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
public class GiveAllCommand implements CommandHandler {
public final class GiveAllCommand implements CommandHandler {
@Override
public void execute(Player sender, List<String> args) {
......@@ -142,16 +142,11 @@ public class GiveAllCommand implements CommandHandler {
}
}
if (testItemsList.contains(itemId)) {
return true;
}
return false;
return testItemsList.contains(itemId);
}
static class Range {
private int min;
private int max;
private final int min, max;
public Range(int min, int max) {
if(min > max){
......@@ -159,6 +154,7 @@ public class GiveAllCommand implements CommandHandler {
max ^= min;
min ^= max;
}
this.min = min;
this.max = max;
}
......
......@@ -6,24 +6,20 @@ import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@Command(label = "sendmail", usage = "sendmail <userId|all|help> [templateId]",
description = "Sends mail to the specified user. The usage of this command changes based on it's composition state.", permission = "server.sendmail")
public class SendMailCommand implements CommandHandler {
public final class SendMailCommand implements CommandHandler {
// TODO: You should be able to do /sendmail and then just send subsequent messages until you finish
// However, due to the current nature of the command system, I don't think this is possible without rewriting
// the command system (again). For now this will do
// Key = User that is constructing the mail.
private static HashMap<Integer, MailBuilder> mailBeingConstructed = new HashMap<Integer, MailBuilder>();
private static final HashMap<Integer, MailBuilder> mailBeingConstructed = new HashMap<Integer, MailBuilder>();
// Yes this is awful and I hate it.
@Override
......@@ -48,7 +44,6 @@ public class SendMailCommand implements CommandHandler {
default -> {
if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) {
mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail());
break;
} else {
CommandHandler.sendMessage(sender, "The user with an id of '" + args.get(0) + "' does not exist");
return;
......@@ -73,7 +68,7 @@ public class SendMailCommand implements CommandHandler {
}
case "finish" -> {
if (mailBuilder.constructionStage == 3) {
if (mailBuilder.sendToAll == false) {
if (!mailBuilder.sendToAll) {
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
CommandHandler.sendMessage(sender, "Message sent to user " + mailBuilder.recipient + "!");
} else {
......
......@@ -9,23 +9,25 @@ import java.util.List;
@Command(label = "tpall", usage = "tpall",
description = "Teleports all players in your world to your position", permission = "player.tpall")
public class TpallCommand implements CommandHandler {
public final class TeleportAllCommand implements CommandHandler {
@Override
public void execute(Player sender, List<String> args) {
if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game.");
return;
}
if (!sender.getWorld().isMultiplayer()) {
CommandHandler.sendMessage(sender, "You only can use this command in MP mode.");
return;
}
for (Player gp : sender.getWorld().getPlayers()) {
if (gp.equals(sender))
for (Player player : sender.getWorld().getPlayers()) {
if (player.equals(sender))
continue;
Position pos = sender.getPos();
gp.getWorld().transferPlayerToScene(gp, sender.getSceneId(), pos);
player.getWorld().transferPlayerToScene(player, sender.getSceneId(), pos);
}
}
}
......@@ -30,6 +30,7 @@ import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.URI;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.util.*;
......@@ -243,10 +244,9 @@ public final class DispatchServer {
try {
kmf = createKeyManagerFactory(keystoreFile, "123456");
Grasscutter.getLogger().warn(
"[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to 123456 in config.json.");
"[Dispatch] The default keystore password was loaded successfully. Please consider setting the password to '123456' in config.json.");
} catch (Exception e2) {
Grasscutter.getLogger().warn("[Dispatch] Error while loading keystore!");
e2.printStackTrace();
Grasscutter.getLogger().warn("[Dispatch] Error while loading keystore!", e2);
}
}
}
......@@ -339,10 +339,6 @@ public final class DispatchServer {
// added.
account = DatabaseHelper.createAccountWithId(requestData.account, 0);
for (String permission : Grasscutter.getConfig().getDispatchOptions().defaultPermissions) {
account.addPermission(permission);
}
if (account != null) {
responseData.message = "OK";
responseData.data.account.uid = account.getId();
......@@ -352,6 +348,9 @@ public final class DispatchServer {
Grasscutter.getLogger()
.info(String.format("[Dispatch] Client %s failed to log in: Account %s created",
t.getRemoteAddress(), responseData.data.account.uid));
for (String permission : Grasscutter.getConfig().getDispatchOptions().defaultPermissions) {
account.addPermission(permission);
}
} else {
responseData.retcode = -201;
responseData.message = "Username not found, create failed.";
......@@ -575,15 +574,11 @@ public final class DispatchServer {
if (next > last) {
int eqPos = qs.indexOf('=', last);
try {
if (eqPos < 0 || eqPos > next) {
result.put(URLDecoder.decode(qs.substring(last, next), "utf-8"), "");
} else {
result.put(URLDecoder.decode(qs.substring(last, eqPos), "utf-8"),
URLDecoder.decode(qs.substring(eqPos + 1, next), "utf-8"));
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e); // will never happen, utf-8 support is mandatory for java
if (eqPos < 0 || eqPos > next) {
result.put(URLDecoder.decode(qs.substring(last, next), StandardCharsets.UTF_8), "");
} else {
result.put(URLDecoder.decode(qs.substring(last, eqPos), StandardCharsets.UTF_8),
URLDecoder.decode(qs.substring(eqPos + 1, next), StandardCharsets.UTF_8));
}
}
last = next + 1;
......
package emu.grasscutter.server.event.dispatch;
import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.types.ServerEvent;
public final class QueryAllRegionsEvent extends ServerEvent {
private String regionList;
......
package emu.grasscutter.server.event.dispatch;
import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.types.ServerEvent;
public final class QueryCurrentRegionEvent extends ServerEvent {
private String regionInfo;
......
package emu.grasscutter.server.event.game;
import emu.grasscutter.server.event.Cancellable;
import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.types.ServerEvent;
import emu.grasscutter.server.game.GameSession;
public final class ReceivePacketEvent extends ServerEvent implements Cancellable {
......
......@@ -17,7 +17,7 @@ import emu.grasscutter.game.world.World;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.netty.KcpServer;
import emu.grasscutter.server.event.ServerEvent;
import emu.grasscutter.server.event.types.ServerEvent;
import emu.grasscutter.server.event.game.ServerTickEvent;
import emu.grasscutter.server.event.internal.ServerStartEvent;
import emu.grasscutter.server.event.internal.ServerStopEvent;
......
......@@ -3,24 +3,12 @@ package emu.grasscutter.task;
import org.quartz.*;
@PersistJobDataAfterExecution
public class TaskHandler implements Job {
public abstract class TaskHandler implements Job {
public void restartExecute() throws JobExecutionException {
execute(null);
}
public void onEnable() {
}
public void onDisable() {
}
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
// TODO Auto-generated method stub
}
public abstract void onEnable();
public abstract void onDisable();
}
......@@ -4,22 +4,21 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.task.Task;
import emu.grasscutter.task.TaskHandler;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@Task(taskName = "MoonCard", taskCronExpression = "0 0 0 * * ?", triggerName = "MoonCardTrigger")
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
public class MoonCard extends TaskHandler {
public final class MoonCard extends TaskHandler {
@Override
public void onEnable() {
Grasscutter.getLogger().info("[Task] MoonCard task enabled.");
Grasscutter.getLogger().debug("[Task] MoonCard task enabled.");
}
@Override
public void onDisable() {
Grasscutter.getLogger().info("[Task] MoonCard task disabled.");
Grasscutter.getLogger().debug("[Task] MoonCard task disabled.");
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment