Format code [skip actions]

This commit is contained in:
github-actions 2023-06-02 18:26:45 +00:00
parent d9e8810a5c
commit 43fa6efec9
20 changed files with 108 additions and 124 deletions

View File

@ -1,5 +1,8 @@
package emu.grasscutter; package emu.grasscutter;
import static emu.grasscutter.config.Configuration.SERVER;
import static emu.grasscutter.utils.lang.Language.translate;
import ch.qos.logback.classic.*; import ch.qos.logback.classic.*;
import emu.grasscutter.auth.*; import emu.grasscutter.auth.*;
import emu.grasscutter.command.*; import emu.grasscutter.command.*;
@ -18,20 +21,16 @@ import emu.grasscutter.tools.Tools;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import emu.grasscutter.utils.lang.Language; import emu.grasscutter.utils.lang.Language;
import io.netty.util.concurrent.FastThreadLocalThread; import io.netty.util.concurrent.FastThreadLocalThread;
import java.io.*;
import java.util.Calendar;
import java.util.concurrent.*;
import javax.annotation.Nullable;
import lombok.*; import lombok.*;
import org.jline.reader.*; import org.jline.reader.*;
import org.jline.terminal.*; import org.jline.terminal.*;
import org.reflections.Reflections; import org.reflections.Reflections;
import org.slf4j.LoggerFactory; 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 final class Grasscutter {
public static final File configFile = new File("./config.json"); public static final File configFile = new File("./config.json");
public static final Reflections reflector = new Reflections("emu.grasscutter"); public static final Reflections reflector = new Reflections("emu.grasscutter");
@ -199,7 +198,8 @@ public final class Grasscutter {
if (!dbExecutor.awaitTermination(5, TimeUnit.SECONDS)) { if (!dbExecutor.awaitTermination(5, TimeUnit.SECONDS)) {
dbExecutor.shutdownNow(); dbExecutor.shutdownNow();
} }
} catch (InterruptedException ignored) { } } catch (InterruptedException ignored) {
}
} }
/* /*

View File

@ -1,14 +1,13 @@
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import static emu.grasscutter.utils.lang.Language.translate;
import emu.grasscutter.command.*; import emu.grasscutter.command.*;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameQuest; import emu.grasscutter.game.quest.GameQuest;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static emu.grasscutter.utils.lang.Language.translate;
@Command( @Command(
label = "quest", label = "quest",
aliases = {"q"}, aliases = {"q"},
@ -142,11 +141,11 @@ public final class QuestCommand implements CommandHandler {
return; return;
} }
CommandHandler.sendMessage(sender, CommandHandler.sendMessage(
group.triggers.entrySet().stream() sender,
.map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue())) group.triggers.entrySet().stream()
.collect(Collectors.joining(", ")) .map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue()))
); .collect(Collectors.joining(", ")));
} }
default -> this.sendUsageMessage(sender); default -> this.sendUsageMessage(sender);
} }

View File

@ -3,9 +3,8 @@ package emu.grasscutter.data.excels;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.game.talk.TalkExec; import emu.grasscutter.game.talk.TalkExec;
import lombok.*;
import java.util.List; import java.util.List;
import lombok.*;
@ResourceType(name = "TalkExcelConfigData.json") @ResourceType(name = "TalkExcelConfigData.json")
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ -40,10 +39,7 @@ public final class TalkConfigData extends GameResource {
if (this.questId <= 0) { if (this.questId <= 0) {
var id = String.valueOf(this.getId()); var id = String.valueOf(this.getId());
this.questId = Integer.parseInt( this.questId = Integer.parseInt(id.length() < 5 ? "0" : id.substring(0, 3));
id.length() < 5 ? "0" :
id.substring(0, 3)
);
} }
} }

View File

@ -1,5 +1,7 @@
package emu.grasscutter.database; package emu.grasscutter.database;
import static com.mongodb.client.model.Filters.eq;
import dev.morphia.query.*; import dev.morphia.query.*;
import dev.morphia.query.experimental.filters.Filters; import dev.morphia.query.experimental.filters.Filters;
import emu.grasscutter.*; import emu.grasscutter.*;
@ -19,16 +21,14 @@ import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.world.SceneGroupInstance; import emu.grasscutter.game.world.SceneGroupInstance;
import emu.grasscutter.utils.objects.Returnable; import emu.grasscutter.utils.objects.Returnable;
import io.netty.util.concurrent.FastThreadLocalThread; import io.netty.util.concurrent.FastThreadLocalThread;
import lombok.Getter;
import java.util.List; import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
import static com.mongodb.client.model.Filters.eq;
public final class DatabaseHelper { public final class DatabaseHelper {
@Getter private static final ExecutorService eventExecutor = @Getter
private static final ExecutorService eventExecutor =
new ThreadPoolExecutor( new ThreadPoolExecutor(
6, 6,
6, 6,

View File

@ -1,5 +1,7 @@
package emu.grasscutter.game.avatar; package emu.grasscutter.game.avatar;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.GameConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.data.GameData; 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.server.packet.send.*;
import emu.grasscutter.utils.helpers.ProtoHelper; import emu.grasscutter.utils.helpers.ProtoHelper;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.*;
import org.bson.types.ObjectId;
import javax.annotation.*;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.*;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS; import lombok.*;
import org.bson.types.ObjectId;
@Entity(value = "avatars", useDiscriminator = false) @Entity(value = "avatars", useDiscriminator = false)
public class Avatar { public class Avatar {
@ -1246,12 +1245,12 @@ public class Avatar {
// Add costume if avatar has a costume. // Add costume if avatar has a costume.
if (GAME_OPTIONS.trialCostumes) { if (GAME_OPTIONS.trialCostumes) {
GameData.getAvatarCostumeDataItemIdMap() GameData.getAvatarCostumeDataItemIdMap()
.values() .values()
.forEach( .forEach(
costumeData -> { costumeData -> {
if (costumeData.getCharacterId() != this.getAvatarId()) return; if (costumeData.getCharacterId() != this.getAvatarId()) return;
this.setCostume(costumeData.getId()); this.setCostume(costumeData.getId());
}); });
} }
} }

View File

@ -1,13 +1,12 @@
package emu.grasscutter.game.player; package emu.grasscutter.game.player;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
import java.util.*; import java.util.*;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
@Entity @Entity
public final class TeamInfo { public final class TeamInfo {
private String name; private String name;

View File

@ -16,11 +16,10 @@ import emu.grasscutter.net.proto.ChildQuestOuterClass.ChildQuest;
import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest; import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.ConversionUtils; import emu.grasscutter.utils.ConversionUtils;
import lombok.*;
import org.bson.types.ObjectId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.*;
import org.bson.types.ObjectId;
@Entity(value = "quests", useDiscriminator = false) @Entity(value = "quests", useDiscriminator = false)
public class GameMainQuest { public class GameMainQuest {

View File

@ -15,10 +15,9 @@ import emu.grasscutter.scripts.data.SceneGroup;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair; import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
import lombok.*;
import javax.script.Bindings;
import java.util.*; import java.util.*;
import javax.script.Bindings;
import lombok.*;
@Entity @Entity
public class GameQuest { public class GameQuest {

View File

@ -1,11 +1,11 @@
package emu.grasscutter.game.quest.content; 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.data.excels.quest.QuestData;
import emu.grasscutter.game.quest.*; import emu.grasscutter.game.quest.*;
import lombok.val; import lombok.val;
import static emu.grasscutter.game.quest.enums.QuestContent.QUEST_CONTENT_COMPLETE_TALK;
@QuestValueContent(QUEST_CONTENT_COMPLETE_TALK) @QuestValueContent(QUEST_CONTENT_COMPLETE_TALK)
public class ContentCompleteTalk extends BaseContent { public class ContentCompleteTalk extends BaseContent {
@Override @Override

View File

@ -53,8 +53,11 @@ public class ExecNotifyGroupLua extends QuestExecHandler {
? EventType.EVENT_QUEST_FINISH ? EventType.EVENT_QUEST_FINISH
: EventType.EVENT_QUEST_START; : EventType.EVENT_QUEST_START;
scriptManager.callEvent( scriptManager.callEvent(
new ScriptArgs(groupId, eventType, quest.getSubQuestId(), new ScriptArgs(
quest.getState() == QuestState.QUEST_STATE_FINISHED ? 1 : 0) groupId,
eventType,
quest.getSubQuestId(),
quest.getState() == QuestState.QUEST_STATE_FINISHED ? 1 : 0)
.setEventSource(quest.getSubQuestId())); .setEventSource(quest.getSubQuestId()));
}); });

View File

@ -1,13 +1,13 @@
package emu.grasscutter.game.talk; 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.GameData;
import emu.grasscutter.data.binout.MainQuestData.TalkData; import emu.grasscutter.data.binout.MainQuestData.TalkData;
import emu.grasscutter.game.player.*; import emu.grasscutter.game.player.*;
import lombok.NonNull; 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 final class TalkManager extends BasePlayerManager {
public TalkManager(@NonNull Player player) { public TalkManager(@NonNull Player player) {
super(player); super(player);
@ -33,8 +33,8 @@ public final class TalkManager extends BasePlayerManager {
// Execute the talk action on associated handlers. // Execute the talk action on associated handlers.
talkData talkData
.getFinishExec() .getFinishExec()
.forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e)); .forEach(e -> player.getServer().getTalkSystem().triggerExec(player, talkData, e));
// Save the talk value to the quest's data. // Save the talk value to the quest's data.
this.saveTalkToQuest(talkId, talkData.getQuestId()); this.saveTalkToQuest(talkId, talkData.getQuestId());

View File

@ -22,8 +22,8 @@ import emu.grasscutter.game.props.*;
import emu.grasscutter.game.quest.QuestGroupSuite; import emu.grasscutter.game.quest.QuestGroupSuite;
import emu.grasscutter.game.world.data.TeleportProperties; import emu.grasscutter.game.world.data.TeleportProperties;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
import emu.grasscutter.net.proto.*; import emu.grasscutter.net.proto.*;
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType; import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
import emu.grasscutter.scripts.*; import emu.grasscutter.scripts.*;
import emu.grasscutter.scripts.constants.EventType; 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.server.packet.send.*;
import emu.grasscutter.utils.objects.KahnsSort; import emu.grasscutter.utils.objects.KahnsSort;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.*;
import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.*;
public final class Scene { public final class Scene {
@Getter private final World world; @Getter private final World world;

View File

@ -1,18 +1,17 @@
package emu.grasscutter.plugin; package emu.grasscutter.plugin;
import static emu.grasscutter.utils.lang.Language.translate;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.server.event.*; import emu.grasscutter.server.event.*;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import lombok.*;
import javax.annotation.Nullable;
import java.io.*; import java.io.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.jar.*; import java.util.jar.*;
import javax.annotation.Nullable;
import static emu.grasscutter.utils.lang.Language.translate; import lombok.*;
/** Manages the server's plugins and the event system. */ /** Manages the server's plugins and the event system. */
public final class PluginManager { public final class PluginManager {

View File

@ -1,5 +1,7 @@
package emu.grasscutter.scripts; 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.RTree;
import com.github.davidmoten.rtreemulti.geometry.Geometry; import com.github.davidmoten.rtreemulti.geometry.Geometry;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
@ -19,20 +21,17 @@ import emu.grasscutter.server.packet.send.PacketGroupSuiteNotify;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import io.netty.util.concurrent.FastThreadLocalThread; import io.netty.util.concurrent.FastThreadLocalThread;
import it.unimi.dsi.fastutil.ints.*; 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.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.*;
import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT; import kotlin.Pair;
import lombok.val;
import org.luaj.vm2.*;
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
public class SceneScriptManager { public class SceneScriptManager {
private final Scene scene; private final Scene scene;
@ -804,23 +803,24 @@ public class SceneScriptManager {
ScriptLoader.getScriptLib().setSceneScriptManager(this); ScriptLoader.getScriptLib().setSceneScriptManager(this);
var eventType = params.type; var eventType = params.type;
var relevantTriggers = switch (eventType) { var relevantTriggers =
case EventType.EVENT_ENTER_REGION, EventType.EVENT_LEAVE_REGION -> switch (eventType) {
this.getTriggersByEvent(eventType).stream() case EventType.EVENT_ENTER_REGION, EventType.EVENT_LEAVE_REGION -> this
.filter( .getTriggersByEvent(eventType)
t -> .stream()
t.getCondition().contains(String.valueOf(params.param1)) .filter(
&& (t.getSource().isEmpty() t ->
|| t.getSource().equals(params.getEventSource()))) t.getCondition().contains(String.valueOf(params.param1))
.collect(Collectors.toSet()); && (t.getSource().isEmpty()
default -> || t.getSource().equals(params.getEventSource())))
this.getTriggersByEvent(eventType).stream() .collect(Collectors.toSet());
.filter( default -> this.getTriggersByEvent(eventType).stream()
t -> params.getGroupId() == 0 || t.getCurrentGroup().id == params.getGroupId()) .filter(
.filter( t -> params.getGroupId() == 0 || t.getCurrentGroup().id == params.getGroupId())
t -> (t.getSource().isEmpty() || t.getSource().equals(params.getEventSource()))) .filter(
.collect(Collectors.toSet()); t -> (t.getSource().isEmpty() || t.getSource().equals(params.getEventSource())))
}; .collect(Collectors.toSet());
};
for (SceneTrigger trigger : relevantTriggers) { for (SceneTrigger trigger : relevantTriggers) {
handleEventForTrigger(params, trigger); handleEventForTrigger(params, trigger);

View File

@ -1,5 +1,8 @@
package emu.grasscutter.server.game; 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.*;
import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.Grasscutter.ServerRunMode;
import emu.grasscutter.database.DatabaseHelper; 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.server.scheduler.ServerTaskScheduler;
import emu.grasscutter.task.TaskMap; import emu.grasscutter.task.TaskMap;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import kcp.highway.*;
import lombok.*;
import org.jetbrains.annotations.NotNull;
import java.net.*; import java.net.*;
import java.time.*; import java.time.*;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import kcp.highway.*;
import static emu.grasscutter.config.Configuration.*; import lombok.*;
import static emu.grasscutter.utils.lang.Language.translate; import org.jetbrains.annotations.NotNull;
@Getter @Getter
public final class GameServer extends KcpServer implements Iterable<Player> { public final class GameServer extends KcpServer implements Iterable<Player> {
@ -331,9 +330,7 @@ public final class GameServer extends KcpServer implements Iterable<Player> {
var event = new ServerStopEvent(ServerEvent.Type.GAME, OffsetDateTime.now()); var event = new ServerStopEvent(ServerEvent.Type.GAME, OffsetDateTime.now());
event.call(); event.call();
this.getPlayers() this.getPlayers().forEach((uid, player) -> player.getSession().close());
.forEach(
(uid, player) -> player.getSession().close());
this.getWorlds().forEach(World::save); this.getWorlds().forEach(World::save);
@ -348,7 +345,8 @@ public final class GameServer extends KcpServer implements Iterable<Player> {
if (!threadPool.awaitTermination(5, TimeUnit.SECONDS)) { if (!threadPool.awaitTermination(5, TimeUnit.SECONDS)) {
Grasscutter.getLogger().error("Logic thread did not terminate!"); Grasscutter.getLogger().error("Logic thread did not terminate!");
} }
} catch (InterruptedException ignored) { } } catch (InterruptedException ignored) {
}
} }
@NotNull @Override @NotNull @Override

View File

@ -1,5 +1,8 @@
package emu.grasscutter.server.game; 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;
import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.Grasscutter.ServerDebugMode;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
@ -8,14 +11,10 @@ import emu.grasscutter.net.packet.*;
import emu.grasscutter.server.event.game.SendPacketEvent; import emu.grasscutter.server.event.game.SendPacketEvent;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import io.netty.buffer.*; import io.netty.buffer.*;
import lombok.*;
import java.io.File; import java.io.File;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.nio.file.Path; import java.nio.file.Path;
import lombok.*;
import static emu.grasscutter.config.Configuration.*;
import static emu.grasscutter.utils.lang.Language.translate;
public class GameSession implements GameSessionManager.KcpChannel { public class GameSession implements GameSessionManager.KcpChannel {
private final GameServer server; private final GameServer server;

View File

@ -4,11 +4,10 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import io.netty.buffer.*; import io.netty.buffer.*;
import io.netty.channel.DefaultEventLoop; import io.netty.channel.DefaultEventLoop;
import kcp.highway.*;
import lombok.Getter;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import kcp.highway.*;
import lombok.Getter;
public class GameSessionManager { public class GameSessionManager {
@Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop(); @Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop();

View File

@ -1,5 +1,7 @@
package emu.grasscutter.server.http.handlers; package emu.grasscutter.server.http.handlers;
import static emu.grasscutter.utils.lang.Language.translate;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
@ -8,14 +10,11 @@ import emu.grasscutter.server.http.Router;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import io.javalin.Javalin; import io.javalin.Javalin;
import io.javalin.http.*; import io.javalin.http.*;
import lombok.Getter;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.*; import java.nio.file.*;
import java.util.*; import java.util.*;
import lombok.Getter;
import static emu.grasscutter.utils.lang.Language.translate;
/** Handles all gacha-related HTTP requests. */ /** Handles all gacha-related HTTP requests. */
public final class GachaHandler implements Router { public final class GachaHandler implements Router {

View File

@ -1,5 +1,8 @@
package emu.grasscutter.utils; 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.Grasscutter;
import emu.grasscutter.config.ConfigContainer; import emu.grasscutter.config.ConfigContainer;
import emu.grasscutter.data.DataLoader; import emu.grasscutter.data.DataLoader;
@ -8,9 +11,6 @@ import emu.grasscutter.utils.objects.Returnable;
import io.javalin.http.Context; import io.javalin.http.Context;
import io.netty.buffer.*; import io.netty.buffer.*;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import org.slf4j.Logger;
import javax.annotation.Nullable;
import java.io.*; import java.io.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -19,9 +19,8 @@ import java.time.*;
import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nullable;
import static emu.grasscutter.utils.FileUtils.getResourcePath; import org.slf4j.Logger;
import static emu.grasscutter.utils.lang.Language.translate;
@SuppressWarnings({"UnusedReturnValue", "BooleanMethodIsAlwaysInverted"}) @SuppressWarnings({"UnusedReturnValue", "BooleanMethodIsAlwaysInverted"})
public final class Utils { public final class Utils {

View File

@ -3,7 +3,6 @@ package emu.grasscutter.utils.objects;
import com.google.gson.*; import com.google.gson.*;
import emu.grasscutter.server.dispatch.IDispatcher; import emu.grasscutter.server.dispatch.IDispatcher;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
@ -18,8 +17,7 @@ public interface FieldFetch {
// Prepare field properties. // Prepare field properties.
var fieldValues = new JsonObject(); var fieldValues = new JsonObject();
var fieldMap = new HashMap<String, Field>(); var fieldMap = new HashMap<String, Field>();
Utils.getAllFields(this.getClass()) Utils.getAllFields(this.getClass()).forEach(field -> fieldMap.put(field.getName(), field));
.forEach(field -> fieldMap.put(field.getName(), field));
// Find the values of all requested fields. // Find the values of all requested fields.
for (var fieldName : fields) { for (var fieldName : fields) {