diff --git a/src/main/java/emu/grasscutter/DebugConstants.java b/src/main/java/emu/grasscutter/DebugConstants.java index f0f111de9..1957f2f32 100644 --- a/src/main/java/emu/grasscutter/DebugConstants.java +++ b/src/main/java/emu/grasscutter/DebugConstants.java @@ -9,10 +9,10 @@ public final class DebugConstants { public static boolean LOG_MISSING_ABILITY_HANDLERS = true; /** - * WARNING: THIS IS A DANGEROUS SETTING. DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING. - * This allows the *client* to send *ANY* token and UID pair to the server. - * The server will then accept the token and UID pair as valid, and set the account's token to the client specified one. - * This can allow for IMPERSONATION and HIJACKING of accounts/servers. + * WARNING: THIS IS A DANGEROUS SETTING. DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING. This + * allows the *client* to send *ANY* token and UID pair to the server. The server will then accept + * the token and UID pair as valid, and set the account's token to the client specified one. This + * can allow for IMPERSONATION and HIJACKING of accounts/servers. */ public static final boolean ACCEPT_CLIENT_TOKEN = false; diff --git a/src/main/java/emu/grasscutter/command/commands/DebugCommand.java b/src/main/java/emu/grasscutter/command/commands/DebugCommand.java index e7ea8a989..c4aac96af 100644 --- a/src/main/java/emu/grasscutter/command/commands/DebugCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/DebugCommand.java @@ -3,7 +3,6 @@ package emu.grasscutter.command.commands; import emu.grasscutter.Grasscutter; import emu.grasscutter.command.*; import emu.grasscutter.game.player.Player; - import java.util.List; @Command( @@ -33,9 +32,10 @@ public final class DebugCommand implements CommandHandler { var scene = sender.getScene(); var entityId = Integer.parseInt(args.get(0)); - var entity = args.size() > 1 && args.get(1).equals("config") ? - scene.getEntityByConfigId(entityId) : - scene.getEntityById(entityId); + var entity = + args.size() > 1 && args.get(1).equals("config") + ? scene.getEntityByConfigId(entityId) + : scene.getEntityById(entityId); if (entity == null) { sender.dropMessage("Entity not found."); return; @@ -46,8 +46,12 @@ public final class DebugCommand implements CommandHandler { for (var i = 0; i < abilities.size(); i++) { try { var ability = abilities.get(i); - Grasscutter.getLogger().debug("Ability #{}: {}; Modifiers: {}", - i, ability.toString(), ability.getModifiers().keySet()); + Grasscutter.getLogger() + .debug( + "Ability #{}: {}; Modifiers: {}", + i, + ability.toString(), + ability.getModifiers().keySet()); } catch (Exception exception) { Grasscutter.getLogger().warn("Failed to print ability #{}.", i, exception); } diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 4773ff115..aa989a7ea 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -1,5 +1,8 @@ package emu.grasscutter.data; +import static emu.grasscutter.utils.FileUtils.*; +import static emu.grasscutter.utils.lang.Language.translate; + import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import emu.grasscutter.Grasscutter; @@ -20,10 +23,6 @@ import emu.grasscutter.scripts.*; import emu.grasscutter.utils.*; import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; -import org.reflections.Reflections; - -import javax.script.*; import java.io.*; import java.nio.file.*; import java.util.*; @@ -31,9 +30,9 @@ import java.util.Map.Entry; import java.util.concurrent.*; import java.util.regex.Pattern; import java.util.stream.*; - -import static emu.grasscutter.utils.FileUtils.*; -import static emu.grasscutter.utils.lang.Language.translate; +import javax.script.*; +import lombok.*; +import org.reflections.Reflections; public final class ResourceLoader { diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 9a962b558..41d2279e0 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -3,9 +3,8 @@ package emu.grasscutter.data.binout; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.game.props.ElementType; -import lombok.ToString; - import java.io.Serializable; +import lombok.ToString; public class AbilityModifier implements Serializable { private static final long serialVersionUID = -2001232313615923575L; diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 68f08b62c..07fb0dbbd 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -19,11 +19,10 @@ import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType; import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry; import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction; import io.netty.util.concurrent.FastThreadLocalThread; -import lombok.Getter; -import org.reflections.Reflections; - import java.util.HashMap; import java.util.concurrent.*; +import lombok.Getter; +import org.reflections.Reflections; public final class AbilityManager extends BasePlayerManager { private static final HashMap actionHandlers = @@ -103,7 +102,7 @@ public final class AbilityManager extends BasePlayerManager { () -> { if (!handler.execute(ability, action, abilityData, target)) { Grasscutter.getLogger() - .debug("Ability execute action failed for {} at {}.", action.type, ability); + .debug("Ability execute action failed for {} at {}.", action.type, ability); } }); } @@ -182,8 +181,8 @@ public final class AbilityManager extends BasePlayerManager { case ABILITY_INVOKE_ARGUMENT_META_SET_KILLED_SETATE -> this.handleKillState(invoke); default -> { if (DebugConstants.LOG_MISSING_ABILITIES) { - Grasscutter.getLogger().trace("Missing invoke handler for ability {}.", - invoke.getArgumentType().name()); + Grasscutter.getLogger() + .trace("Missing invoke handler for ability {}.", invoke.getArgumentType().name()); } } } diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionCopyGlobalValue.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionCopyGlobalValue.java index 92889d6d1..cbca32af7 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionCopyGlobalValue.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionCopyGlobalValue.java @@ -33,8 +33,10 @@ public final class ActionCopyGlobalValue extends AbilityActionHandler { destination.onAbilityValueUpdate(); // Send a value update packet. - entity.getScene().getHost().sendPacket( - new PacketServerGlobalValueChangeNotify(entity, action.dstKey, value)); + entity + .getScene() + .getHost() + .sendPacket(new PacketServerGlobalValueChangeNotify(entity, action.dstKey, value)); return true; } diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionServerLuaCall.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionServerLuaCall.java index 6c678b579..26f9134ad 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionServerLuaCall.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionServerLuaCall.java @@ -6,9 +6,8 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.game.ability.Ability; import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.scripts.ScriptLoader; -import org.luaj.vm2.LuaFunction; - import javax.script.Bindings; +import org.luaj.vm2.LuaFunction; @AbilityAction(AbilityModifierAction.Type.ServerLuaCall) public final class ActionServerLuaCall extends AbilityActionHandler { diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValue.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValue.java index c779b76d3..f85e91ff5 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValue.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValue.java @@ -10,7 +10,7 @@ import emu.grasscutter.server.packet.send.PacketServerGlobalValueChangeNotify; public final class ActionSetGlobalValue extends AbilityActionHandler { @Override public boolean execute( - Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) { + Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) { // Get the key & value. var valueKey = action.key; var value = action.ratio; @@ -21,8 +21,10 @@ public final class ActionSetGlobalValue extends AbilityActionHandler { target.onAbilityValueUpdate(); // Send a value update packet. - target.getScene().getHost().sendPacket( - new PacketServerGlobalValueChangeNotify(target, valueKey, value.get(ability))); + target + .getScene() + .getHost() + .sendPacket(new PacketServerGlobalValueChangeNotify(target, valueKey, value.get(ability))); return true; } diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java index 4cc33a628..6432948e2 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java @@ -40,8 +40,10 @@ public final class ActionSetGlobalValueToOverrideMap extends AbilityActionHandle entity.onAbilityValueUpdate(); // Send a value update packet. - entity.getScene().getHost().sendPacket( - new PacketServerGlobalValueChangeNotify(entity, globalValueKey, globalValue)); + entity + .getScene() + .getHost() + .sendPacket(new PacketServerGlobalValueChangeNotify(entity, globalValueKey, globalValue)); return true; } diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievement.java b/src/main/java/emu/grasscutter/game/achievement/Achievement.java index 5e554d24c..f4b14a3ac 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievement.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievement.java @@ -15,11 +15,7 @@ public class Achievement { @Setter private int finishTimestampSec; public Achievement( - Status status, - int id, - int totalProgress, - int curProgress, - int finishTimestampSec) { + Status status, int id, int totalProgress, int curProgress, int finishTimestampSec) { this.status = status; this.id = id; this.totalProgress = totalProgress; diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index c81da5ec4..77db3627a 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievements.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievements.java @@ -10,6 +10,7 @@ import emu.grasscutter.game.inventory.GameItem; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.net.proto.AchievementOuterClass.Achievement.Status; +import emu.grasscutter.server.event.player.PlayerCompleteAchievementEvent; import emu.grasscutter.server.packet.send.*; import lombok.*; import org.bson.types.ObjectId; @@ -25,8 +26,7 @@ import java.util.function.IntSupplier; public class Achievements { private static final IntSupplier currentTimeSecs = () -> (int) (System.currentTimeMillis() / 1000L); - private static final Achievement INVALID = - new Achievement(Status.STATUS_INVALID, -1, 0, 0, 0); + private static final Achievement INVALID = new Achievement(Status.STATUS_INVALID, -1, 0, 0, 0); @Id private ObjectId id; private int uid; @Transient private Player player; @@ -65,8 +65,7 @@ public class Achievements { a -> { map.put( a.getId(), - new Achievement( - Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0)); + new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0)); }); return map; } @@ -126,10 +125,13 @@ public class Achievements { } private boolean update(Achievement a) { - if (a.getStatus() == Status.STATUS_UNFINISHED - && a.getCurProgress() >= a.getTotalProgress()) { + if (a.getStatus() == Status.STATUS_UNFINISHED && a.getCurProgress() >= a.getTotalProgress()) { a.setStatus(Status.STATUS_FINISHED); a.setFinishTimestampSec(currentTimeSecs.getAsInt()); + + // Call PlayerCompleteAchievementEvent. + new PlayerCompleteAchievementEvent(this.player, a).call(); + return true; } else if (this.isFinished(a.getId()) && a.getCurProgress() < a.getTotalProgress()) { a.setStatus(Status.STATUS_UNFINISHED); @@ -197,8 +199,7 @@ public class Achievements { public boolean isFinished(int achievementId) { var status = this.getStatus(achievementId); - return status == Status.STATUS_FINISHED - || status == Status.STATUS_REWARD_TAKEN; + return status == Status.STATUS_FINISHED || status == Status.STATUS_REWARD_TAKEN; } public void takeReward(List ids) { diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/WorldChallenge.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/WorldChallenge.java index bb3ddf993..b755566e6 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/WorldChallenge.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/WorldChallenge.java @@ -9,10 +9,9 @@ import emu.grasscutter.game.world.Scene; import emu.grasscutter.scripts.constants.EventType; import emu.grasscutter.scripts.data.*; import emu.grasscutter.server.packet.send.*; -import lombok.*; - import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import lombok.*; @Getter @Setter diff --git a/src/main/java/emu/grasscutter/game/entity/GameEntity.java b/src/main/java/emu/grasscutter/game/entity/GameEntity.java index 1b0854f25..3574825af 100644 --- a/src/main/java/emu/grasscutter/game/entity/GameEntity.java +++ b/src/main/java/emu/grasscutter/game/entity/GameEntity.java @@ -15,9 +15,8 @@ import emu.grasscutter.scripts.data.controller.EntityController; import emu.grasscutter.server.event.entity.*; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; - import java.util.*; +import lombok.*; public abstract class GameEntity { @Getter private final Scene scene; diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/platform/BaseRoute.java b/src/main/java/emu/grasscutter/game/entity/gadget/platform/BaseRoute.java index e6949f979..d3b27e71a 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/platform/BaseRoute.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/platform/BaseRoute.java @@ -69,12 +69,12 @@ public abstract class BaseRoute { val pitch = Math.toRadians(startRot.getY()); val yaw = Math.toRadians(startRot.getZ()); - val cr = (float)Math.cos(roll * 0.5); - val sr = (float)Math.sin(roll * 0.5); - val cp = (float)Math.cos(pitch * 0.5); - val sp = (float)Math.sin(pitch * 0.5); - val cy = (float)Math.cos(yaw * 0.5); - val sy = (float)Math.sin(yaw * 0.5); + val cr = (float) Math.cos(roll * 0.5); + val sr = (float) Math.sin(roll * 0.5); + val cp = (float) Math.cos(pitch * 0.5); + val sp = (float) Math.sin(pitch * 0.5); + val cy = (float) Math.cos(yaw * 0.5); + val sy = (float) Math.sin(yaw * 0.5); result.setW(cr * cp * cy + sr * sp * sy); result.setX(sr * cp * cy - cr * sp * sy); diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index c25b95bcc..cf38cc8e3 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -1,5 +1,7 @@ package emu.grasscutter.game.player; +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; + import dev.morphia.annotations.*; import emu.grasscutter.*; import emu.grasscutter.data.GameData; @@ -21,28 +23,19 @@ import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import lombok.*; - import java.util.*; import java.util.stream.Stream; - -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; +import lombok.*; @Entity public final class TeamManager extends BasePlayerDataManager { @Transient private final List avatars; @Transient @Getter private final Set gadgets; @Transient @Getter private final IntSet teamResonances; - @Transient - @Getter - private final IntSet teamResonancesConfig; - @Transient - @Getter - @Setter - private Set teamAbilityEmbryos; + @Transient @Getter private final IntSet teamResonancesConfig; + @Transient @Getter @Setter private Set teamAbilityEmbryos; // This needs to be a LinkedHashMap to guarantee insertion order. - @Getter - private LinkedHashMap teams; + @Getter private LinkedHashMap teams; private int currentTeamIndex; @Getter @Setter private int currentCharacterIndex; @Transient @Getter @Setter private TeamInfo mpTeam; @@ -82,20 +75,24 @@ public final class TeamManager extends BasePlayerDataManager { // Add team ability embryos, NOT to be confused with avatarAbilties. // These should include the ones in LevelEntity (according to levelEntityConfig field in sceneId) - // rn only apply to big world defaults, but will fix scaramouch domain circles (BinOutput/LevelEntity/Level_Monster_Nada_setting) + // rn only apply to big world defaults, but will fix scaramouch domain circles + // (BinOutput/LevelEntity/Level_Monster_Nada_setting) public AbilityControlBlockOuterClass.AbilityControlBlock getAbilityControlBlock() { - AbilityControlBlockOuterClass.AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlockOuterClass.AbilityControlBlock.newBuilder(); + AbilityControlBlockOuterClass.AbilityControlBlock.Builder abilityControlBlock = + AbilityControlBlockOuterClass.AbilityControlBlock.newBuilder(); int embryoId = 0; // add from default if (Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).count() > 0) { - List teamAbilties = Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).toList(); + List teamAbilties = + Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).toList(); for (String skill : teamAbilties) { - AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() - .setAbilityId(++embryoId) - .setAbilityNameHash(Utils.abilityHash(skill)) - .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME) - .build(); + AbilityEmbryoOuterClass.AbilityEmbryo emb = + AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() + .setAbilityId(++embryoId) + .setAbilityNameHash(Utils.abilityHash(skill)) + .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME) + .build(); abilityControlBlock.addAbilityEmbryoList(emb); } } @@ -103,11 +100,12 @@ public final class TeamManager extends BasePlayerDataManager { // same as avatar ability hash (add frm levelEntityConfig data) if (this.getTeamAbilityEmbryos().size() > 0) { for (String skill : this.getTeamAbilityEmbryos()) { - AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() - .setAbilityId(++embryoId) - .setAbilityNameHash(Utils.abilityHash(skill)) - .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME) - .build(); + AbilityEmbryoOuterClass.AbilityEmbryo emb = + AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() + .setAbilityId(++embryoId) + .setAbilityNameHash(Utils.abilityHash(skill)) + .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME) + .build(); abilityControlBlock.addAbilityEmbryoList(emb); } } diff --git a/src/main/java/emu/grasscutter/game/props/PlayerProperty.java b/src/main/java/emu/grasscutter/game/props/PlayerProperty.java index fed9065c2..4c5995873 100644 --- a/src/main/java/emu/grasscutter/game/props/PlayerProperty.java +++ b/src/main/java/emu/grasscutter/game/props/PlayerProperty.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.stream.Stream; +import lombok.Getter; public enum PlayerProperty { PROP_NONE(0), @@ -62,8 +61,10 @@ public enum PlayerProperty { PROP_PLAYER_WAIT_SUB_GCG_COIN(10046), // New; unknown/un-used. PROP_PLAYER_ONLINE_TIME(10047), // New; unknown/un-used. PROP_PLAYER_CAN_DIVE(10048, 0, 1), // Can the player dive? [0, 1] - PROP_DIVE_MAX_STAMINA(10049, 0, 10000), // The maximum stamina of the player when diving. [0, 10000] - PROP_DIVE_CUR_STAMINA(10050, 0, 10000); // The current stamina of the player when diving. [0, 10000] + PROP_DIVE_MAX_STAMINA( + 10049, 0, 10000), // The maximum stamina of the player when diving. [0, 10000] + PROP_DIVE_CUR_STAMINA( + 10050, 0, 10000); // The current stamina of the player when diving. [0, 10000] private static final int inf = Integer.MAX_VALUE; // Maybe this should be something else? private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 55bfc22be..a5f7b6837 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -23,8 +23,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; @@ -35,12 +35,11 @@ import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.scheduler.ServerTaskScheduler; 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/scripts/EntityControllerScriptManager.java b/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java index 05dbf1b50..1e4a84e92 100644 --- a/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java @@ -1,15 +1,14 @@ package emu.grasscutter.scripts; +import static emu.grasscutter.utils.FileUtils.getScriptPath; + import emu.grasscutter.Grasscutter; import emu.grasscutter.scripts.data.controller.EntityController; -import lombok.val; - import java.io.IOException; import java.nio.file.Files; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - -import static emu.grasscutter.utils.FileUtils.getScriptPath; +import lombok.val; public class EntityControllerScriptManager { private static final Map gadgetController = new ConcurrentHashMap<>(); diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java index 23d6bedc3..2f52d3472 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java @@ -8,18 +8,17 @@ import emu.grasscutter.scripts.constants.*; import emu.grasscutter.scripts.data.SceneMeta; import emu.grasscutter.scripts.serializer.*; import emu.grasscutter.utils.FileUtils; -import lombok.Getter; -import org.luaj.vm2.*; -import org.luaj.vm2.lib.OneArgFunction; -import org.luaj.vm2.lib.jse.CoerceJavaToLua; -import org.luaj.vm2.script.LuajContext; - -import javax.script.*; import java.lang.ref.SoftReference; import java.nio.file.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; +import javax.script.*; +import lombok.Getter; +import org.luaj.vm2.*; +import org.luaj.vm2.lib.OneArgFunction; +import org.luaj.vm2.lib.jse.CoerceJavaToLua; +import org.luaj.vm2.script.LuajContext; public class ScriptLoader { private static ScriptEngineManager sm; @@ -34,8 +33,7 @@ public class ScriptLoader { /** sceneId - SceneMeta */ private static Map> sceneMetaCache = new ConcurrentHashMap<>(); - private static final AtomicReference currentBindings - = new AtomicReference<>(null); + private static final AtomicReference currentBindings = new AtomicReference<>(null); public static synchronized void init() throws Exception { if (sm != null) { @@ -110,17 +108,13 @@ public class ScriptLoader { } /** - * Performs a smart evaluation. - * This allows for 'require' to work. + * Performs a smart evaluation. This allows for 'require' to work. * * @param script The script to evaluate. * @param bindings The bindings to use. * @return The result of the evaluation. */ - public static Object eval( - CompiledScript script, - Bindings bindings) - throws ScriptException { + public static Object eval(CompiledScript script, Bindings bindings) throws ScriptException { // Set the current bindings. currentBindings.set(bindings); // Evaluate the script. diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index dc71c4e3a..c135ef020 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -5,11 +5,10 @@ import com.github.davidmoten.rtreemulti.geometry.*; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.Position; import emu.grasscutter.scripts.*; -import lombok.*; - -import javax.script.*; import java.util.Map; import java.util.stream.Collectors; +import javax.script.*; +import lombok.*; @ToString @Setter diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index 32835f9af..f67f48264 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -3,12 +3,11 @@ package emu.grasscutter.scripts.data; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.Position; import emu.grasscutter.scripts.ScriptLoader; -import lombok.*; -import org.luaj.vm2.*; - -import javax.script.*; import java.util.*; import java.util.stream.Collectors; +import javax.script.*; +import lombok.*; +import org.luaj.vm2.*; @ToString @Setter diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java b/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java index 4377053a2..93038eec2 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java @@ -4,11 +4,10 @@ import com.github.davidmoten.rtreemulti.RTree; import com.github.davidmoten.rtreemulti.geometry.Geometry; import emu.grasscutter.Grasscutter; import emu.grasscutter.scripts.*; -import lombok.*; - -import javax.script.*; import java.util.*; import java.util.stream.Collectors; +import javax.script.*; +import lombok.*; @ToString @Setter diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java index 7052a0c4a..5f25512fc 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.packet.recv; +import static emu.grasscutter.config.Configuration.ACCOUNT; + import emu.grasscutter.*; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; @@ -11,12 +13,9 @@ import emu.grasscutter.server.game.GameSession.SessionState; import emu.grasscutter.server.packet.send.PacketGetPlayerTokenRsp; import emu.grasscutter.utils.*; import emu.grasscutter.utils.helpers.ByteHelper; - -import javax.crypto.Cipher; import java.nio.ByteBuffer; import java.security.Signature; - -import static emu.grasscutter.config.Configuration.ACCOUNT; +import javax.crypto.Cipher; @Opcodes(PacketOpcodes.GetPlayerTokenReq) public class HandlerGetPlayerTokenReq extends PacketHandler { diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index 6d9e9e357..a611acb89 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -1,5 +1,8 @@ package emu.grasscutter.tools; +import static emu.grasscutter.utils.FileUtils.getResourcePath; +import static emu.grasscutter.utils.lang.Language.getTextMapKey; + import emu.grasscutter.*; import emu.grasscutter.command.*; import emu.grasscutter.data.*; @@ -11,8 +14,6 @@ import emu.grasscutter.utils.*; import emu.grasscutter.utils.lang.Language; import emu.grasscutter.utils.lang.Language.TextStrings; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; - import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.*; @@ -21,9 +22,7 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.function.Function; import java.util.stream.*; - -import static emu.grasscutter.utils.FileUtils.getResourcePath; -import static emu.grasscutter.utils.lang.Language.getTextMapKey; +import lombok.*; public final class Tools { /** @@ -422,8 +421,7 @@ public final class Tools { case "ver" -> resourceInfo.version(value); case "patches" -> resourceInfo.patches(value); case "scripts" -> resourceInfo.scripts(ScriptsType.valueOf(value.toUpperCase())); - case "hasnolocals" -> resourceInfo.hasNoLocals( - Boolean.parseBoolean(value)); + case "hasnolocals" -> resourceInfo.hasNoLocals(Boolean.parseBoolean(value)); case "hasserverres" -> resourceInfo.hasServerResources( Boolean.parseBoolean(value)); case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData(