diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index 2f1a737ce..de66a9a50 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -1,5 +1,8 @@ package emu.grasscutter; +import static emu.grasscutter.config.Configuration.SERVER; +import static emu.grasscutter.utils.lang.Language.translate; + import ch.qos.logback.classic.*; import emu.grasscutter.auth.*; import emu.grasscutter.command.*; @@ -18,20 +21,16 @@ import emu.grasscutter.tools.Tools; import emu.grasscutter.utils.*; import emu.grasscutter.utils.lang.Language; import io.netty.util.concurrent.FastThreadLocalThread; +import java.io.*; +import java.util.Calendar; +import java.util.concurrent.*; +import javax.annotation.Nullable; import lombok.*; import org.jline.reader.*; import org.jline.terminal.*; import org.reflections.Reflections; import org.slf4j.LoggerFactory; -import javax.annotation.Nullable; -import java.io.*; -import java.util.Calendar; -import java.util.concurrent.*; - -import static emu.grasscutter.config.Configuration.SERVER; -import static emu.grasscutter.utils.lang.Language.translate; - public final class Grasscutter { public static final File configFile = new File("./config.json"); public static final Reflections reflector = new Reflections("emu.grasscutter"); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java b/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java index b897a00ad..4816603db 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java @@ -10,17 +10,18 @@ import emu.grasscutter.game.world.*; import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo; import emu.grasscutter.scripts.EntityControllerScriptManager; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; - import javax.annotation.Nullable; +import lombok.*; @ToString(callSuper = true) public class EntityWeapon extends EntityBaseGadget { @Getter private final GadgetData gadgetData; - @Getter(onMethod_ = @Override) @Setter + + @Getter(onMethod_ = @Override) + @Setter private int gadgetId; - @Nullable @Getter - private ConfigEntityGadget configGadget; + + @Nullable @Getter private ConfigEntityGadget configGadget; @Getter(onMethod_ = @Override, lazy = true) private final Int2FloatMap fightProperties = new Int2FloatOpenHashMap(); @@ -50,21 +51,20 @@ public class EntityWeapon extends EntityBaseGadget { } this.id = scene.getWorld().getNextEntityId(EntityIdType.WEAPON); - Grasscutter.getLogger().trace("New weapon entity {} in scene {}.", - this.id, this.getScene().getId()); + Grasscutter.getLogger() + .trace("New weapon entity {} in scene {}.", this.id, this.getScene().getId()); this.initAbilities(); } - private void addConfigAbility(ConfigAbilityData abilityData){ - var data = GameData.getAbilityData(abilityData.getAbilityName()); - if (data != null) this.getWorld().getHost() - .getAbilityManager().addAbilityToEntity(this, data); + private void addConfigAbility(ConfigAbilityData abilityData) { + var data = GameData.getAbilityData(abilityData.getAbilityName()); + if (data != null) this.getWorld().getHost().getAbilityManager().addAbilityToEntity(this, data); } @Override public void initAbilities() { - //TODO: handle pre-dynamic, static and dynamic here + // TODO: handle pre-dynamic, static and dynamic here if (this.configGadget != null && this.configGadget.getAbilities() != null) { for (var ability : this.configGadget.getAbilities()) { this.addConfigAbility(ability); diff --git a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java index 92122c60d..39bc93717 100644 --- a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java +++ b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java @@ -9,10 +9,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.net.proto.InvestigationMonsterOuterClass; import emu.grasscutter.scripts.data.*; import emu.grasscutter.server.game.*; -import org.luaj.vm2.LuaError; - import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import org.luaj.vm2.LuaError; public class WorldDataSystem extends BaseGameSystem { private final Map chestInteractHandlerMap; // chestType-Handler @@ -56,8 +55,10 @@ public class WorldDataSystem extends BaseGameSystem { .filter(imd -> imd.getMonsterIdList().get(0) == monsterId) .findFirst(); - return investigationMonsterData.map(monsterData -> GameData.getRewardPreviewDataMap() - .get(monsterData.getRewardPreviewId())).orElse(null); + return investigationMonsterData + .map( + monsterData -> GameData.getRewardPreviewDataMap().get(monsterData.getRewardPreviewId())) + .orElse(null); } private SceneGroup getInvestigationGroup(int sceneId, int groupId) { diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index 6355a168a..03f14a824 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -5,11 +5,10 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.plugin.api.ServerHelper; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.utils.FileUtils; -import lombok.EqualsAndHashCode; -import org.slf4j.*; - import java.io.*; import java.net.URLClassLoader; +import lombok.EqualsAndHashCode; +import org.slf4j.*; /** The base class for all plugins to extend. */ @EqualsAndHashCode diff --git a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java index 529436fd3..e4de100e0 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.http.documentation; +import static emu.grasscutter.config.Configuration.HANDBOOK; + import emu.grasscutter.Grasscutter; import emu.grasscutter.auth.AuthenticationSystem.AuthenticationRequest; import emu.grasscutter.server.http.Router; @@ -8,19 +10,15 @@ import emu.grasscutter.utils.objects.*; import emu.grasscutter.utils.objects.HandbookBody.Action; import io.javalin.Javalin; import io.javalin.http.*; - import java.util.*; import java.util.concurrent.*; -import static emu.grasscutter.config.Configuration.HANDBOOK; - /** Handles requests for the new GM Handbook. */ public final class HandbookHandler implements Router { private String handbook; private final boolean serve; - private final Map currentRequests - = new ConcurrentHashMap<>(); + private final Map currentRequests = new ConcurrentHashMap<>(); /** * Constructor for the handbook router. Enables serving the handbook if the handbook file is @@ -41,13 +39,16 @@ public final class HandbookHandler implements Router { // Create a new task to reset the request count. if (HANDBOOK.limits.enabled) { - new Timer().scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - currentRequests.clear(); - } - }, 0, TimeUnit.SECONDS.toMillis( - HANDBOOK.limits.interval)); + new Timer() + .scheduleAtFixedRate( + new TimerTask() { + @Override + public void run() { + currentRequests.clear(); + } + }, + 0, + TimeUnit.SECONDS.toMillis(HANDBOOK.limits.interval)); } } @@ -90,9 +91,7 @@ public final class HandbookHandler implements Router { var count = this.currentRequests.getOrDefault(address, 0); if (++count >= limits.maxRequests) { // Respond to the request. - ctx.status(429).result(JObject.c() - .add("timestamp", System.currentTimeMillis()) - .toString()); + ctx.status(429).result(JObject.c().add("timestamp", System.currentTimeMillis()).toString()); return false; } @@ -244,14 +243,15 @@ public final class HandbookHandler implements Router { // Parse the request body into a class. var request = ctx.bodyAsClass(HandbookBody.SpawnEntity.class); // Check the entity limit. - var entityLimit = HANDBOOK.limits.enabled ? - Math.max(HANDBOOK.limits.maxEntities, 0) : - Long.MAX_VALUE; + var entityLimit = + HANDBOOK.limits.enabled ? Math.max(HANDBOOK.limits.maxEntities, 0) : Long.MAX_VALUE; if (request.getAmount() > entityLimit) { - ctx.status(400).result(JObject.c() - .add("timestamp", System.currentTimeMillis()) - .add("error", "Entity limit exceeded.") - .toString()); + ctx.status(400) + .result( + JObject.c() + .add("timestamp", System.currentTimeMillis()) + .add("error", "Entity limit exceeded.") + .toString()); return; } diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index 727a855b4..142bc78cf 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -1,5 +1,8 @@ package emu.grasscutter.utils; +import static emu.grasscutter.utils.FileUtils.getResourcePath; +import static emu.grasscutter.utils.lang.Language.translate; + import emu.grasscutter.Grasscutter; import emu.grasscutter.config.ConfigContainer; import emu.grasscutter.data.DataLoader; @@ -7,9 +10,6 @@ import emu.grasscutter.game.world.Position; import io.javalin.http.Context; import io.netty.buffer.*; import it.unimi.dsi.fastutil.ints.*; -import org.slf4j.Logger; - -import javax.annotation.Nullable; import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.*; @@ -17,9 +17,8 @@ import java.time.*; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.concurrent.ThreadLocalRandom; - -import static emu.grasscutter.utils.FileUtils.getResourcePath; -import static emu.grasscutter.utils.lang.Language.translate; +import javax.annotation.Nullable; +import org.slf4j.Logger; @SuppressWarnings({"UnusedReturnValue", "BooleanMethodIsAlwaysInverted"}) public final class Utils { diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index e0c1df11f..25bf8bdbd 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -1,5 +1,8 @@ package emu.grasscutter.utils.lang; +import static emu.grasscutter.config.Configuration.FALLBACK_LANGUAGE; +import static emu.grasscutter.utils.FileUtils.*; + import com.google.gson.*; import emu.grasscutter.Grasscutter; import emu.grasscutter.data.*; @@ -8,8 +11,6 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.utils.*; import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.objects.*; -import lombok.EqualsAndHashCode; - import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.*; @@ -17,9 +18,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.*; import java.util.stream.*; - -import static emu.grasscutter.config.Configuration.FALLBACK_LANGUAGE; -import static emu.grasscutter.utils.FileUtils.*; +import lombok.EqualsAndHashCode; public final class Language { private static final Map cachedLanguages = new ConcurrentHashMap<>();