From 43fa6efec95b03f3a6e417d35ce5424f965eb99e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 18:26:45 +0000 Subject: [PATCH] Format code [skip actions] --- .../java/emu/grasscutter/Grasscutter.java | 18 +++---- .../command/commands/QuestCommand.java | 15 +++--- .../data/excels/TalkConfigData.java | 8 +-- .../grasscutter/database/DatabaseHelper.java | 10 ++-- .../emu/grasscutter/game/avatar/Avatar.java | 23 ++++----- .../emu/grasscutter/game/player/TeamInfo.java | 5 +- .../grasscutter/game/quest/GameMainQuest.java | 5 +- .../emu/grasscutter/game/quest/GameQuest.java | 5 +- .../quest/content/ContentCompleteTalk.java | 4 +- .../game/quest/exec/ExecNotifyGroupLua.java | 7 ++- .../grasscutter/game/talk/TalkManager.java | 10 ++-- .../emu/grasscutter/game/world/Scene.java | 7 ++- .../emu/grasscutter/plugin/PluginManager.java | 9 ++-- .../scripts/SceneScriptManager.java | 50 +++++++++---------- .../grasscutter/server/game/GameServer.java | 20 ++++---- .../grasscutter/server/game/GameSession.java | 9 ++-- .../server/game/GameSessionManager.java | 5 +- .../server/http/handlers/GachaHandler.java | 7 ++- .../java/emu/grasscutter/utils/Utils.java | 11 ++-- .../grasscutter/utils/objects/FieldFetch.java | 4 +- 20 files changed, 108 insertions(+), 124 deletions(-) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index bf5a15b9c..a42cfa3df 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"); @@ -199,7 +198,8 @@ public final class Grasscutter { if (!dbExecutor.awaitTermination(5, TimeUnit.SECONDS)) { dbExecutor.shutdownNow(); } - } catch (InterruptedException ignored) { } + } catch (InterruptedException ignored) { + } } /* diff --git a/src/main/java/emu/grasscutter/command/commands/QuestCommand.java b/src/main/java/emu/grasscutter/command/commands/QuestCommand.java index 4f5ce7796..ad81f428d 100644 --- a/src/main/java/emu/grasscutter/command/commands/QuestCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/QuestCommand.java @@ -1,14 +1,13 @@ package emu.grasscutter.command.commands; +import static emu.grasscutter.utils.lang.Language.translate; + import emu.grasscutter.command.*; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.quest.GameQuest; - import java.util.List; import java.util.stream.Collectors; -import static emu.grasscutter.utils.lang.Language.translate; - @Command( label = "quest", aliases = {"q"}, @@ -142,11 +141,11 @@ public final class QuestCommand implements CommandHandler { return; } - CommandHandler.sendMessage(sender, - group.triggers.entrySet().stream() - .map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue())) - .collect(Collectors.joining(", ")) - ); + CommandHandler.sendMessage( + sender, + group.triggers.entrySet().stream() + .map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue())) + .collect(Collectors.joining(", "))); } default -> this.sendUsageMessage(sender); } diff --git a/src/main/java/emu/grasscutter/data/excels/TalkConfigData.java b/src/main/java/emu/grasscutter/data/excels/TalkConfigData.java index 8a5db6f67..5cc84fb64 100644 --- a/src/main/java/emu/grasscutter/data/excels/TalkConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/TalkConfigData.java @@ -3,9 +3,8 @@ package emu.grasscutter.data.excels; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; import emu.grasscutter.game.talk.TalkExec; -import lombok.*; - import java.util.List; +import lombok.*; @ResourceType(name = "TalkExcelConfigData.json") @EqualsAndHashCode(callSuper = false) @@ -40,10 +39,7 @@ public final class TalkConfigData extends GameResource { if (this.questId <= 0) { var id = String.valueOf(this.getId()); - this.questId = Integer.parseInt( - id.length() < 5 ? "0" : - id.substring(0, 3) - ); + this.questId = Integer.parseInt(id.length() < 5 ? "0" : id.substring(0, 3)); } } diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index 6dbda15ac..421eeb509 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -1,5 +1,7 @@ package emu.grasscutter.database; +import static com.mongodb.client.model.Filters.eq; + import dev.morphia.query.*; import dev.morphia.query.experimental.filters.Filters; import emu.grasscutter.*; @@ -19,16 +21,14 @@ import emu.grasscutter.game.quest.GameMainQuest; import emu.grasscutter.game.world.SceneGroupInstance; import emu.grasscutter.utils.objects.Returnable; import io.netty.util.concurrent.FastThreadLocalThread; -import lombok.Getter; - import java.util.List; import java.util.concurrent.*; import java.util.stream.Stream; - -import static com.mongodb.client.model.Filters.eq; +import lombok.Getter; public final class DatabaseHelper { - @Getter private static final ExecutorService eventExecutor = + @Getter + private static final ExecutorService eventExecutor = new ThreadPoolExecutor( 6, 6, diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 2838a7697..167698206 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -1,5 +1,7 @@ package emu.grasscutter.game.avatar; +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; + import dev.morphia.annotations.*; import emu.grasscutter.GameConstants; import emu.grasscutter.data.GameData; @@ -30,14 +32,11 @@ import emu.grasscutter.net.proto.TrialAvatarInfoOuterClass.TrialAvatarInfo; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.helpers.ProtoHelper; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; -import org.bson.types.ObjectId; - -import javax.annotation.*; import java.util.*; import java.util.stream.Stream; - -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; +import javax.annotation.*; +import lombok.*; +import org.bson.types.ObjectId; @Entity(value = "avatars", useDiscriminator = false) public class Avatar { @@ -1246,12 +1245,12 @@ public class Avatar { // Add costume if avatar has a costume. if (GAME_OPTIONS.trialCostumes) { GameData.getAvatarCostumeDataItemIdMap() - .values() - .forEach( - costumeData -> { - if (costumeData.getCharacterId() != this.getAvatarId()) return; - this.setCostume(costumeData.getId()); - }); + .values() + .forEach( + costumeData -> { + if (costumeData.getCharacterId() != this.getAvatarId()) return; + this.setCostume(costumeData.getId()); + }); } } diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 516abe766..794f36501 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -1,13 +1,12 @@ package emu.grasscutter.game.player; +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; + import dev.morphia.annotations.Entity; import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; - import java.util.*; -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; - @Entity public final class TeamInfo { private String name; diff --git a/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java b/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java index 2814b09ea..38cf6f154 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameMainQuest.java @@ -16,11 +16,10 @@ import emu.grasscutter.net.proto.ChildQuestOuterClass.ChildQuest; import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.ConversionUtils; -import lombok.*; -import org.bson.types.ObjectId; - import java.util.*; import java.util.stream.Collectors; +import lombok.*; +import org.bson.types.ObjectId; @Entity(value = "quests", useDiscriminator = false) public class GameMainQuest { diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index 4d3011705..32fd60fc8 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -15,10 +15,9 @@ import emu.grasscutter.scripts.data.SceneGroup; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.IntIntImmutablePair; -import lombok.*; - -import javax.script.Bindings; import java.util.*; +import javax.script.Bindings; +import lombok.*; @Entity public class GameQuest { diff --git a/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java index 73ed389da..5378d4ba3 100644 --- a/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java +++ b/src/main/java/emu/grasscutter/game/quest/content/ContentCompleteTalk.java @@ -1,11 +1,11 @@ package emu.grasscutter.game.quest.content; +import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK; + import emu.grasscutter.data.excels.quest.QuestData; import emu.grasscutter.game.quest.*; import lombok.val; -import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK; - @QuestValueContent(QUEST_CONTENT_COMPLETE_TALK) public class ContentCompleteTalk extends BaseContent { @Override diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecNotifyGroupLua.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecNotifyGroupLua.java index 09c7e2897..e2a5b2375 100644 --- a/src/main/java/emu/grasscutter/game/quest/exec/ExecNotifyGroupLua.java +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecNotifyGroupLua.java @@ -53,8 +53,11 @@ public class ExecNotifyGroupLua extends QuestExecHandler { ? EventType.EVENT_QUEST_FINISH : EventType.EVENT_QUEST_START; scriptManager.callEvent( - new ScriptArgs(groupId, eventType, quest.getSubQuestId(), - quest.getState() == QuestState.QUEST_STATE_FINISHED ? 1 : 0) + new ScriptArgs( + groupId, + eventType, + quest.getSubQuestId(), + quest.getState() == QuestState.QUEST_STATE_FINISHED ? 1 : 0) .setEventSource(quest.getSubQuestId())); }); diff --git a/src/main/java/emu/grasscutter/game/talk/TalkManager.java b/src/main/java/emu/grasscutter/game/talk/TalkManager.java index 0ca762842..963020819 100644 --- a/src/main/java/emu/grasscutter/game/talk/TalkManager.java +++ b/src/main/java/emu/grasscutter/game/talk/TalkManager.java @@ -1,13 +1,13 @@ package emu.grasscutter.game.talk; +import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK; +import static emu.grasscutter.game.quest.enums.QuestContent.*; + import emu.grasscutter.data.GameData; import emu.grasscutter.data.binout.MainQuestData.TalkData; import emu.grasscutter.game.player.*; import lombok.NonNull; -import static emu.grasscutter.game.quest.enums.QuestCond.QUEST_COND_COMPLETE_TALK; -import static emu.grasscutter.game.quest.enums.QuestContent.*; - public final class TalkManager extends BasePlayerManager { public TalkManager(@NonNull Player player) { super(player); @@ -33,8 +33,8 @@ public final class TalkManager extends BasePlayerManager { // Execute the talk action on associated handlers. talkData - .getFinishExec() - .forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e)); + .getFinishExec() + .forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e)); // Save the talk value to the quest's data. this.saveTalkToQuest(talkId, talkData.getQuestId()); diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 2e50c1b4a..db6d525bf 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -22,8 +22,8 @@ import emu.grasscutter.game.props.*; import emu.grasscutter.game.quest.QuestGroupSuite; import emu.grasscutter.game.world.data.TeleportProperties; import emu.grasscutter.net.packet.BasePacket; -import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult; import emu.grasscutter.net.proto.*; +import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult; import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType; import emu.grasscutter.scripts.*; import emu.grasscutter.scripts.constants.EventType; @@ -33,12 +33,11 @@ import emu.grasscutter.server.event.player.PlayerTeleportEvent; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.objects.KahnsSort; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import lombok.*; - -import javax.annotation.Nullable; import java.util.*; import java.util.concurrent.*; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import lombok.*; public final class Scene { @Getter private final World world; diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 1c91babd1..09fd56413 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -1,18 +1,17 @@ package emu.grasscutter.plugin; +import static emu.grasscutter.utils.lang.Language.translate; + import emu.grasscutter.Grasscutter; import emu.grasscutter.server.event.*; import emu.grasscutter.utils.*; -import lombok.*; - -import javax.annotation.Nullable; import java.io.*; import java.lang.reflect.Method; import java.net.*; import java.util.*; import java.util.jar.*; - -import static emu.grasscutter.utils.lang.Language.translate; +import javax.annotation.Nullable; +import lombok.*; /** Manages the server's plugins and the event system. */ public final class PluginManager { diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 747e0fb0f..8e692670f 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -1,5 +1,7 @@ package emu.grasscutter.scripts; +import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT; + import com.github.davidmoten.rtreemulti.RTree; import com.github.davidmoten.rtreemulti.geometry.Geometry; import emu.grasscutter.Grasscutter; @@ -19,20 +21,17 @@ import emu.grasscutter.server.packet.send.PacketGroupSuiteNotify; import emu.grasscutter.utils.*; import io.netty.util.concurrent.FastThreadLocalThread; import it.unimi.dsi.fastutil.ints.*; -import kotlin.Pair; -import lombok.val; -import org.luaj.vm2.*; -import org.luaj.vm2.lib.jse.CoerceJavaToLua; - -import javax.annotation.*; import java.io.*; import java.nio.file.Files; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; - -import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT; +import javax.annotation.*; +import kotlin.Pair; +import lombok.val; +import org.luaj.vm2.*; +import org.luaj.vm2.lib.jse.CoerceJavaToLua; public class SceneScriptManager { private final Scene scene; @@ -804,23 +803,24 @@ public class SceneScriptManager { ScriptLoader.getScriptLib().setSceneScriptManager(this); var eventType = params.type; - var relevantTriggers = switch (eventType) { - case EventType.EVENT_ENTER_REGION, EventType.EVENT_LEAVE_REGION -> - this.getTriggersByEvent(eventType).stream() - .filter( - t -> - t.getCondition().contains(String.valueOf(params.param1)) - && (t.getSource().isEmpty() - || t.getSource().equals(params.getEventSource()))) - .collect(Collectors.toSet()); - default -> - this.getTriggersByEvent(eventType).stream() - .filter( - t -> params.getGroupId() == 0 || t.getCurrentGroup().id == params.getGroupId()) - .filter( - t -> (t.getSource().isEmpty() || t.getSource().equals(params.getEventSource()))) - .collect(Collectors.toSet()); - }; + var relevantTriggers = + switch (eventType) { + case EventType.EVENT_ENTER_REGION, EventType.EVENT_LEAVE_REGION -> this + .getTriggersByEvent(eventType) + .stream() + .filter( + t -> + t.getCondition().contains(String.valueOf(params.param1)) + && (t.getSource().isEmpty() + || t.getSource().equals(params.getEventSource()))) + .collect(Collectors.toSet()); + default -> this.getTriggersByEvent(eventType).stream() + .filter( + t -> params.getGroupId() == 0 || t.getCurrentGroup().id == params.getGroupId()) + .filter( + t -> (t.getSource().isEmpty() || t.getSource().equals(params.getEventSource()))) + .collect(Collectors.toSet()); + }; for (SceneTrigger trigger : relevantTriggers) { handleEventForTrigger(params, trigger); diff --git a/src/main/java/emu/grasscutter/server/game/GameServer.java b/src/main/java/emu/grasscutter/server/game/GameServer.java index 7bb95b1d5..138511c2c 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServer.java +++ b/src/main/java/emu/grasscutter/server/game/GameServer.java @@ -1,5 +1,8 @@ package emu.grasscutter.server.game; +import static emu.grasscutter.config.Configuration.*; +import static emu.grasscutter.utils.lang.Language.translate; + import emu.grasscutter.*; import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.database.DatabaseHelper; @@ -30,17 +33,13 @@ import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.scheduler.ServerTaskScheduler; import emu.grasscutter.task.TaskMap; import emu.grasscutter.utils.Utils; -import kcp.highway.*; -import lombok.*; -import org.jetbrains.annotations.NotNull; - import java.net.*; import java.time.*; import java.util.*; import java.util.concurrent.*; - -import static emu.grasscutter.config.Configuration.*; -import static emu.grasscutter.utils.lang.Language.translate; +import kcp.highway.*; +import lombok.*; +import org.jetbrains.annotations.NotNull; @Getter public final class GameServer extends KcpServer implements Iterable { @@ -331,9 +330,7 @@ public final class GameServer extends KcpServer implements Iterable { var event = new ServerStopEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); event.call(); - this.getPlayers() - .forEach( - (uid, player) -> player.getSession().close()); + this.getPlayers().forEach((uid, player) -> player.getSession().close()); this.getWorlds().forEach(World::save); @@ -348,7 +345,8 @@ public final class GameServer extends KcpServer implements Iterable { if (!threadPool.awaitTermination(5, TimeUnit.SECONDS)) { Grasscutter.getLogger().error("Logic thread did not terminate!"); } - } catch (InterruptedException ignored) { } + } catch (InterruptedException ignored) { + } } @NotNull @Override diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 0038db015..e21e0fb48 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -1,5 +1,8 @@ package emu.grasscutter.server.game; +import static emu.grasscutter.config.Configuration.*; +import static emu.grasscutter.utils.lang.Language.translate; + import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.game.Account; @@ -8,14 +11,10 @@ import emu.grasscutter.net.packet.*; import emu.grasscutter.server.event.game.SendPacketEvent; import emu.grasscutter.utils.*; import io.netty.buffer.*; -import lombok.*; - import java.io.File; import java.net.InetSocketAddress; import java.nio.file.Path; - -import static emu.grasscutter.config.Configuration.*; -import static emu.grasscutter.utils.lang.Language.translate; +import lombok.*; public class GameSession implements GameSessionManager.KcpChannel { private final GameServer server; diff --git a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java index d529f7579..5c6ef7770 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java +++ b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java @@ -4,11 +4,10 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.utils.Utils; import io.netty.buffer.*; import io.netty.channel.DefaultEventLoop; -import kcp.highway.*; -import lombok.Getter; - import java.net.InetSocketAddress; import java.util.concurrent.ConcurrentHashMap; +import kcp.highway.*; +import lombok.Getter; public class GameSessionManager { @Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop(); diff --git a/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java b/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java index 00ea482ff..512cc4f1e 100644 --- a/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java +++ b/src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.http.handlers; +import static emu.grasscutter.utils.lang.Language.translate; + import com.google.gson.JsonObject; import emu.grasscutter.Grasscutter; import emu.grasscutter.database.DatabaseHelper; @@ -8,14 +10,11 @@ import emu.grasscutter.server.http.Router; import emu.grasscutter.utils.*; import io.javalin.Javalin; import io.javalin.http.*; -import lombok.Getter; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.*; import java.util.*; - -import static emu.grasscutter.utils.lang.Language.translate; +import lombok.Getter; /** Handles all gacha-related HTTP requests. */ public final class GachaHandler implements Router { diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index b0a27c3fb..435d6d0f1 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; @@ -8,9 +11,6 @@ import emu.grasscutter.utils.objects.Returnable; 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.lang.reflect.Field; import java.nio.charset.StandardCharsets; @@ -19,9 +19,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/objects/FieldFetch.java b/src/main/java/emu/grasscutter/utils/objects/FieldFetch.java index 24207f6da..6af162463 100644 --- a/src/main/java/emu/grasscutter/utils/objects/FieldFetch.java +++ b/src/main/java/emu/grasscutter/utils/objects/FieldFetch.java @@ -3,7 +3,6 @@ package emu.grasscutter.utils.objects; import com.google.gson.*; import emu.grasscutter.server.dispatch.IDispatcher; import emu.grasscutter.utils.Utils; - import java.lang.reflect.Field; import java.util.*; @@ -18,8 +17,7 @@ public interface FieldFetch { // Prepare field properties. var fieldValues = new JsonObject(); var fieldMap = new HashMap(); - Utils.getAllFields(this.getClass()) - .forEach(field -> fieldMap.put(field.getName(), field)); + Utils.getAllFields(this.getClass()).forEach(field -> fieldMap.put(field.getName(), field)); // Find the values of all requested fields. for (var fieldName : fields) {