From 6bb349d92bcf836e17735154776c6cf588bb6509 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:47:56 -0300 Subject: [PATCH 01/59] fix: make those fields final --- .../java/emu/grasscutter/data/GameData.java | 4 +- .../java/emu/grasscutter/data/GameDepot.java | 8 +-- .../data/binout/OpenConfigEntry.java | 4 +- .../emu/grasscutter/data/excels/ItemData.java | 10 +-- .../data/excels/PlayerLevelData.java | 2 +- .../data/excels/ProudSkillData.java | 2 +- .../excels/achievement/AchievementData.java | 2 +- .../data/excels/avatar/AvatarData.java | 2 +- .../data/excels/tower/TowerLevelData.java | 10 +-- .../emu/grasscutter/data/server/Grid.java | 2 +- .../java/emu/grasscutter/game/Account.java | 2 +- .../emu/grasscutter/game/ability/Ability.java | 18 +++--- .../ability/AbilityModifierController.java | 6 +- .../game/achievement/Achievement.java | 4 +- .../emu/grasscutter/game/avatar/Avatar.java | 6 +- .../game/dungeons/DungeonEndStats.java | 8 +-- .../game/entity/EntityClientGadget.java | 10 +-- .../game/entity/EntityMonster.java | 4 +- .../grasscutter/game/entity/EntityTeam.java | 2 +- .../game/entity/EntityVehicle.java | 2 +- .../grasscutter/game/entity/EntityWorld.java | 2 +- .../grasscutter/game/entity/GameEntity.java | 6 +- .../game/entity/gadget/GadgetAbility.java | 2 +- .../game/friends/PlayerProfile.java | 4 +- .../grasscutter/game/gacha/GachaBanner.java | 50 +++++++-------- .../game/managers/mapmark/MapMark.java | 4 +- .../emu/grasscutter/game/player/Player.java | 64 +++++++++---------- .../grasscutter/game/player/PlayerCodex.java | 14 ++-- .../game/player/PlayerProgress.java | 10 +-- .../emu/grasscutter/game/player/TeamInfo.java | 2 +- .../grasscutter/game/quest/QuestManager.java | 2 +- .../emu/grasscutter/game/world/Scene.java | 2 +- .../game/world/SceneGroupInstance.java | 6 +- .../game/world/SpawnDataEntry.java | 8 +-- .../emu/grasscutter/game/world/World.java | 2 +- .../scripts/SceneScriptManager.java | 2 +- .../emu/grasscutter/scripts/ScriptLoader.java | 6 +- .../data/controller/EntityController.java | 4 +- .../event/game/SceneBlockLoadedEvent.java | 2 +- .../server/event/game/SceneMetaLoadEvent.java | 2 +- 40 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index a1ef20a8e..1a8597694 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -569,8 +569,8 @@ public final class GameData { private static final Int2IntMap trialAvatarIndexIdTrialActivityDataDataMap = new Int2IntOpenHashMap(); - private static Map> fetters = new HashMap<>(); - private static Map> shopGoods = new HashMap<>(); + private static final Map> fetters = new HashMap<>(); + private static final Map> shopGoods = new HashMap<>(); // Getters with different names that stay for now public static Int2ObjectMap getMainQuestDataMap() { diff --git a/src/main/java/emu/grasscutter/data/GameDepot.java b/src/main/java/emu/grasscutter/data/GameDepot.java index b3c43bb21..34cfd57ee 100644 --- a/src/main/java/emu/grasscutter/data/GameDepot.java +++ b/src/main/java/emu/grasscutter/data/GameDepot.java @@ -13,17 +13,17 @@ import lombok.*; public class GameDepot { public static final int[] BLOCK_SIZE = new int[] {50, 500}; // Scales - private static Int2ObjectMap> relicRandomMainPropDepot = + private static final Int2ObjectMap> relicRandomMainPropDepot = new Int2ObjectOpenHashMap<>(); - private static Int2ObjectMap> relicMainPropDepot = + private static final Int2ObjectMap> relicMainPropDepot = new Int2ObjectOpenHashMap<>(); - private static Int2ObjectMap> relicAffixDepot = + private static final Int2ObjectMap> relicAffixDepot = new Int2ObjectOpenHashMap<>(); @Getter @Setter private static Map playerAbilities = new HashMap<>(); @Getter - private static HashMap> spawnLists = + private static final HashMap> spawnLists = new HashMap<>(); @Getter @Setter private static BlossomConfig blossomConfig; diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index 25f8055bf..6270eb601 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -51,8 +51,8 @@ public class OpenConfigEntry { } public static class SkillPointModifier { - private int skillId; - private int delta; + private final int skillId; + private final int delta; public SkillPointModifier(int skillId, int delta) { this.skillId = skillId; diff --git a/src/main/java/emu/grasscutter/data/excels/ItemData.java b/src/main/java/emu/grasscutter/data/excels/ItemData.java index de77a4ba6..edce795e1 100644 --- a/src/main/java/emu/grasscutter/data/excels/ItemData.java +++ b/src/main/java/emu/grasscutter/data/excels/ItemData.java @@ -24,7 +24,7 @@ public class ItemData extends GameResource { @Getter(onMethod_ = @Override) private int id; - private int stackLimit = 1; + private final int stackLimit = 1; private int maxUseCount; private int rankLevel; private String effectName; @@ -37,7 +37,7 @@ public class ItemData extends GameResource { private int[] destroyReturnMaterialCount; // Enums - private ItemType itemType = ItemType.ITEM_NONE; + private final ItemType itemType = ItemType.ITEM_NONE; private MaterialType materialType = MaterialType.MATERIAL_NONE; private EquipType equipType = EquipType.EQUIP_NONE; private String effectType; @@ -48,10 +48,10 @@ public class ItemData extends GameResource { private int[] satiationParams; // Usable item - private ItemUseTarget useTarget = ItemUseTarget.ITEM_USE_TARGET_NONE; + private final ItemUseTarget useTarget = ItemUseTarget.ITEM_USE_TARGET_NONE; private List itemUse; private List itemUseActions; - private boolean useOnGain = false; + private final boolean useOnGain = false; // Relic private int mainPropDepotId; @@ -79,7 +79,7 @@ public class ItemData extends GameResource { private int comfort; private List furnType; private List furnitureGadgetID; - private SpecialFurnitureType specialFurnitureType = SpecialFurnitureType.NOT_SPECIAL; + private final SpecialFurnitureType specialFurnitureType = SpecialFurnitureType.NOT_SPECIAL; @SerializedName( value = "roomSceneId", diff --git a/src/main/java/emu/grasscutter/data/excels/PlayerLevelData.java b/src/main/java/emu/grasscutter/data/excels/PlayerLevelData.java index 35632c990..59da00fe7 100644 --- a/src/main/java/emu/grasscutter/data/excels/PlayerLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/PlayerLevelData.java @@ -9,7 +9,7 @@ public class PlayerLevelData extends GameResource { private int level; private int exp; private int rewardId; - private int expeditionLimitAdd = 0; + private final int expeditionLimitAdd = 0; private int unlockWorldLevel; private long unlockDescTextMapHash; diff --git a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java index 51d4ae288..fb17b3594 100644 --- a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java +++ b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java @@ -25,7 +25,7 @@ public class ProudSkillData extends GameResource { @Getter private long nameTextMapHash; @Transient private Iterable totalCostItems; - @Transient @Getter private Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); + @Transient @Getter private final Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/achievement/AchievementData.java b/src/main/java/emu/grasscutter/data/excels/achievement/AchievementData.java index 3a3b7836d..d67cab89f 100644 --- a/src/main/java/emu/grasscutter/data/excels/achievement/AchievementData.java +++ b/src/main/java/emu/grasscutter/data/excels/achievement/AchievementData.java @@ -14,7 +14,7 @@ public class AchievementData extends GameResource { private static final AtomicBoolean isDivided = new AtomicBoolean(); private int goalId; private int preStageAchievementId; - private Set groupAchievementIdList = new HashSet<>(); + private final Set groupAchievementIdList = new HashSet<>(); private boolean isParent; private long titleTextMapHash; private long descTextMapHash; diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarData.java index d897fc4e7..1b0823328 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarData.java @@ -55,7 +55,7 @@ public class AvatarData extends GameResource { @Getter private IntList abilities; @Getter - private List abilitieNames = new ArrayList<>(); + private final List abilitieNames = new ArrayList<>(); @Getter private List fetters; diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerLevelData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerLevelData.java index e9fd62ff6..de36bd3b1 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerLevelData.java @@ -30,8 +30,8 @@ public class TowerLevelData extends GameResource { // Just packaging condition parameters for convenience. @Getter public class TowerCondTimeParams { - private int param1; - private int minimumTimeInSeconds; + private final int param1; + private final int minimumTimeInSeconds; public TowerCondTimeParams(int param1, int minimumTimeInSeconds) { this.param1 = param1; @@ -41,9 +41,9 @@ public class TowerLevelData extends GameResource { @Getter public class TowerCondHpParams { - private int sceneId; - private int configId; - private int minimumHpPercentage; + private final int sceneId; + private final int configId; + private final int minimumHpPercentage; public TowerCondHpParams(int sceneId, int configId, int minimumHpPercentage) { this.sceneId = sceneId; diff --git a/src/main/java/emu/grasscutter/data/server/Grid.java b/src/main/java/emu/grasscutter/data/server/Grid.java index 624556d48..25f84559b 100644 --- a/src/main/java/emu/grasscutter/data/server/Grid.java +++ b/src/main/java/emu/grasscutter/data/server/Grid.java @@ -9,7 +9,7 @@ import java.util.*; public class Grid { public transient RTree>, Geometry> gridOptimized = null; - private transient Set nearbyGroups = new HashSet<>(100); + private final transient Set nearbyGroups = new HashSet<>(100); public Map> grid = new LinkedHashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index c796b9981..e13475705 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -24,7 +24,7 @@ public class Account { private String token; private String sessionKey; // Session token for dispatch server - private List permissions; + private final List permissions; private Locale locale; private String banReason; diff --git a/src/main/java/emu/grasscutter/game/ability/Ability.java b/src/main/java/emu/grasscutter/game/ability/Ability.java index 0c7f5337e..76263f87c 100644 --- a/src/main/java/emu/grasscutter/game/ability/Ability.java +++ b/src/main/java/emu/grasscutter/game/ability/Ability.java @@ -12,20 +12,20 @@ import java.util.*; import lombok.Getter; public class Ability { - @Getter private AbilityData data; - @Getter private GameEntity owner; - @Getter private Player playerOwner; + @Getter private final AbilityData data; + @Getter private final GameEntity owner; + @Getter private final Player playerOwner; - @Getter private AbilityManager manager; + @Getter private final AbilityManager manager; - @Getter private Map modifiers = new HashMap<>(); - @Getter private Object2FloatMap abilitySpecials = new Object2FloatOpenHashMap<>(); + @Getter private final Map modifiers = new HashMap<>(); + @Getter private final Object2FloatMap abilitySpecials = new Object2FloatOpenHashMap<>(); @Getter - private static Map> abilitySpecialsModified = new HashMap<>(); + private static final Map> abilitySpecialsModified = new HashMap<>(); - @Getter private int hash; - @Getter private Set avatarSkillStartIds; + @Getter private final int hash; + @Getter private final Set avatarSkillStartIds; public Ability(AbilityData data, GameEntity owner, Player playerOwner) { this.data = data; diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java b/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java index 370412fe5..a95c4fbda 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java @@ -4,10 +4,10 @@ import emu.grasscutter.data.binout.*; import lombok.Getter; public class AbilityModifierController { - @Getter private Ability ability; + @Getter private final Ability ability; - @Getter private AbilityData abilityData; - @Getter private AbilityModifier modifierData; + @Getter private final AbilityData abilityData; + @Getter private final AbilityModifier modifierData; public AbilityModifierController( Ability ability, AbilityData abilityData, AbilityModifier modifierData) { diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievement.java b/src/main/java/emu/grasscutter/game/achievement/Achievement.java index 6f3a7dae1..2e935e111 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievement.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievement.java @@ -9,8 +9,8 @@ import lombok.*; @Getter public class Achievement { @Setter private Status status; - private int id; - private int totalProgress; + private final int id; + private final int totalProgress; @Setter private int curProgress; @Setter private int finishTimestampSec; diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index be5774ed0..0bae0a2b4 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -61,13 +61,13 @@ public class Avatar { private List fetters; - private Map skillLevelMap = new Int2IntArrayMap(7); // Talent levels + private final Map skillLevelMap = new Int2IntArrayMap(7); // Talent levels @Transient @Getter - private Map skillExtraChargeMap = new Int2IntArrayMap(2); // Charges + private final Map skillExtraChargeMap = new Int2IntArrayMap(2); // Charges @Transient - private Map proudSkillBonusMap = + private final Map proudSkillBonusMap = new Int2IntArrayMap(2); // Talent bonus levels (from const) @Getter private int skillDepotId; diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java index f22eb78dc..f204860a7 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java @@ -4,10 +4,10 @@ import emu.grasscutter.game.dungeons.dungeon_results.BaseDungeonResult; import lombok.Getter; public class DungeonEndStats { - @Getter private int killedMonsters; - @Getter private int timeTaken; - @Getter private int openChestCount; - @Getter private BaseDungeonResult.DungeonEndReason dungeonResult; + @Getter private final int killedMonsters; + @Getter private final int timeTaken; + @Getter private final int openChestCount; + @Getter private final BaseDungeonResult.DungeonEndReason dungeonResult; public DungeonEndStats( int killedMonsters, diff --git a/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java b/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java index 8296c09c9..740e46f60 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java @@ -29,13 +29,13 @@ public class EntityClientGadget extends EntityBaseGadget { @Getter private final Player owner; @Getter(onMethod_ = @Override) - private int gadgetId; + private final int gadgetId; - @Getter private int ownerEntityId; - @Getter private int targetEntityId; - @Getter private boolean asyncLoad; + @Getter private final int ownerEntityId; + @Getter private final int targetEntityId; + @Getter private final boolean asyncLoad; - @Getter private int originalOwnerEntityId; + @Getter private final int originalOwnerEntityId; @Getter private final GadgetData gadgetData; private ConfigEntityGadget configGadget; diff --git a/src/main/java/emu/grasscutter/game/entity/EntityMonster.java b/src/main/java/emu/grasscutter/game/entity/EntityMonster.java index f60f17c13..37392a3e8 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityMonster.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityMonster.java @@ -50,13 +50,13 @@ public class EntityMonster extends GameEntity { @Getter private final Position bornPos; @Getter private final int level; @Getter private EntityWeapon weaponEntity; - @Getter private Map summonTagMap; + @Getter private final Map summonTagMap; @Getter @Setter private int summonedTag; @Getter @Setter private int ownerEntityId; @Getter @Setter private int poseId; @Getter @Setter private int aiId = -1; - @Getter private List playerOnBattle; + @Getter private final List playerOnBattle; @Nullable @Getter @Setter private SceneMonster metaMonster; public EntityMonster( diff --git a/src/main/java/emu/grasscutter/game/entity/EntityTeam.java b/src/main/java/emu/grasscutter/game/entity/EntityTeam.java index 949b003ab..a7b541891 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityTeam.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityTeam.java @@ -10,7 +10,7 @@ import it.unimi.dsi.fastutil.ints.*; public class EntityTeam extends GameEntity { - private Player player; + private final Player player; public EntityTeam(Player player) { super(player.getScene()); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityVehicle.java b/src/main/java/emu/grasscutter/game/entity/EntityVehicle.java index 88db87bfa..78a3df4ee 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityVehicle.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityVehicle.java @@ -36,7 +36,7 @@ public class EntityVehicle extends EntityBaseGadget { @Getter private final int gadgetId; @Getter @Setter private float curStamina; - @Getter private List vehicleMembers; + @Getter private final List vehicleMembers; @Nullable @Getter private ConfigEntityGadget configGadget; public EntityVehicle( diff --git a/src/main/java/emu/grasscutter/game/entity/EntityWorld.java b/src/main/java/emu/grasscutter/game/entity/EntityWorld.java index 50692cd72..da6fbd7ae 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityWorld.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityWorld.java @@ -8,7 +8,7 @@ import it.unimi.dsi.fastutil.ints.*; import lombok.Getter; public class EntityWorld extends GameEntity { - @Getter private World world; + @Getter private final World world; public EntityWorld(World world) { super(null); diff --git a/src/main/java/emu/grasscutter/game/entity/GameEntity.java b/src/main/java/emu/grasscutter/game/entity/GameEntity.java index 7e78dbb10..e3b9003ff 100644 --- a/src/main/java/emu/grasscutter/game/entity/GameEntity.java +++ b/src/main/java/emu/grasscutter/game/entity/GameEntity.java @@ -44,13 +44,13 @@ public abstract class GameEntity { @Getter @Setter private EntityController entityController; @Getter private ElementType lastAttackType = ElementType.None; - @Getter private List instancedAbilities = new ArrayList<>(); + @Getter private final List instancedAbilities = new ArrayList<>(); @Getter - private Int2ObjectMap instancedModifiers = + private final Int2ObjectMap instancedModifiers = new Int2ObjectOpenHashMap<>(); - @Getter private Map globalAbilityValues = new HashMap<>(); + @Getter private final Map globalAbilityValues = new HashMap<>(); public GameEntity(Scene scene) { this.scene = scene; diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetAbility.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetAbility.java index 3fc91e587..6775ea4ca 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetAbility.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetAbility.java @@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo; import lombok.val; public class GadgetAbility extends GadgetContent { - private EntityBaseGadget parent; + private final EntityBaseGadget parent; public GadgetAbility(EntityGadget gadget, EntityBaseGadget parent) { super(gadget); diff --git a/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java b/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java index 6d150df5f..509914446 100644 --- a/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java +++ b/src/main/java/emu/grasscutter/game/friends/PlayerProfile.java @@ -24,8 +24,8 @@ public class PlayerProfile { private int worldLevel; private int lastActiveTime; - private boolean isInDuel = false; // TODO: Implement duels. (TCG) - private boolean isDuelObservable = false; // TODO: Implement duels. (TCG) + private final boolean isInDuel = false; // TODO: Implement duels. (TCG) + private final boolean isDuelObservable = false; // TODO: Implement duels. (TCG) @Getter private int enterHomeOption; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index b1bdaeef2..7d3405fab 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -39,24 +39,24 @@ public class GachaBanner { @Getter private String previewPrefabPath; @Getter private String titlePath; private int costItemId = 0; - private int costItemAmount = 1; + private final int costItemAmount = 1; private int costItemId10 = 0; - private int costItemAmount10 = 10; - @Getter private int beginTime = 0; - @Getter private int endTime = 1924992000; - @Getter private int gachaTimesLimit = Integer.MAX_VALUE; - @Getter private int[] rateUpItems4 = {}; - @Getter private int[] rateUpItems5 = {}; + private final int costItemAmount10 = 10; + @Getter private final int beginTime = 0; + @Getter private final int endTime = 1924992000; + @Getter private final int gachaTimesLimit = Integer.MAX_VALUE; + @Getter private final int[] rateUpItems4 = {}; + @Getter private final int[] rateUpItems5 = {}; // This now handles default values for the fields below - @Getter private BannerType bannerType = BannerType.STANDARD; + @Getter private final BannerType bannerType = BannerType.STANDARD; // These don't change between banner types (apart from Standard having three extra 4star avatars) @Getter - private int[] fallbackItems3 = { + private final int[] fallbackItems3 = { 11301, 11302, 11306, 12301, 12302, 12305, 13303, 14301, 14302, 14304, 15301, 15302, 15304 }; - @Getter private int[] fallbackItems4Pool1 = DEFAULT_FALLBACK_ITEMS_4_POOL_1; - @Getter private int[] fallbackItems4Pool2 = DEFAULT_FALLBACK_ITEMS_4_POOL_2; + @Getter private final int[] fallbackItems4Pool1 = DEFAULT_FALLBACK_ITEMS_4_POOL_1; + @Getter private final int[] fallbackItems4Pool2 = DEFAULT_FALLBACK_ITEMS_4_POOL_2; // Different banner types have different defaults, see above for default values and the enum for // which are used where. @Getter private int[] fallbackItems5Pool1; @@ -66,33 +66,33 @@ public class GachaBanner { private int eventChance4 = -1; // Chance to win a featured event item private int eventChance5 = -1; // Chance to win a featured event item // - @Getter private boolean removeC6FromPool = false; + @Getter private final boolean removeC6FromPool = false; @Getter - private boolean autoStripRateUpFromFallback = + private final boolean autoStripRateUpFromFallback = true; // Ensures that featured items won't "double dip" into the losing pool - private int[][] poolBalanceWeights4 = { + private final int[][] poolBalanceWeights4 = { {1, 255}, {17, 255}, {21, 10455} }; // Used to ensure that players won't go too many rolls without getting something from pool 1 // (avatar) or pool 2 (weapon) - private int[][] poolBalanceWeights5 = {{1, 30}, {147, 150}, {181, 10230}}; - @Getter private int wishMaxProgress = 2; + private final int[][] poolBalanceWeights5 = {{1, 30}, {147, 150}, {181, 10230}}; + @Getter private final int wishMaxProgress = 2; // Deprecated fields that were tolerated in early May 2022 but have apparently still being // circulating in new custom configs // For now, throw up big scary errors on load telling people that they will be banned outright in // a future version - @Deprecated private int[] rateUpItems1 = {}; - @Deprecated private int[] rateUpItems2 = {}; - @Deprecated private int eventChance = -1; - @Deprecated private int costItem = 0; - @Deprecated private int softPity = -1; - @Deprecated private int hardPity = -1; - @Deprecated private int minItemType = -1; - @Deprecated private int maxItemType = -1; + @Deprecated private final int[] rateUpItems1 = {}; + @Deprecated private final int[] rateUpItems2 = {}; + @Deprecated private final int eventChance = -1; + @Deprecated private final int costItem = 0; + @Deprecated private final int softPity = -1; + @Deprecated private final int hardPity = -1; + @Deprecated private final int minItemType = -1; + @Deprecated private final int maxItemType = -1; @Getter private boolean deprecated = false; - @Getter private boolean disabled = false; + @Getter private final boolean disabled = false; private void warnDeprecated(String name, String replacement) { Grasscutter.getLogger() diff --git a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java index 930737bda..6960a8595 100644 --- a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java +++ b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java @@ -11,9 +11,9 @@ public class MapMark { private int sceneId; private String name; private Position position; - private MapMarkPointType mapMarkPointType; + private final MapMarkPointType mapMarkPointType; private int monsterId; - private MapMarkFromType mapMarkFromType; + private final MapMarkFromType mapMarkFromType; private int questId; @Deprecated // Morhpia diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 571da1f91..1f8c87c03 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -78,17 +78,17 @@ public class Player implements PlayerHook, FieldFetch { @Getter private String signature; @Getter private int headImage; @Getter private int nameCardId = 210001; - @Getter private Position position; + @Getter private final Position position; @Getter @Setter private Position prevPos; @Getter @Setter private Position prevPosForHome; @Getter @Setter private int prevScene; - @Getter private Position rotation; + @Getter private final Position rotation; @Getter private PlayerBirthday birthday; @Getter private PlayerCodex codex; @Getter @Setter private boolean showAvatars; @Getter @Setter private List showAvatarList; @Getter @Setter private List showNameCardList; - @Getter private Map properties; + @Getter private final Map properties; @Getter @Setter private int currentRealmId; @Getter @Setter private transient boolean isInEditMode; @Getter @Setter private int widgetId; @@ -98,25 +98,25 @@ public class Player implements PlayerHook, FieldFetch { @Getter @Setter private boolean inGodMode; @Getter @Setter private boolean unlimitedStamina; - @Getter private Set nameCardList; - @Getter private Set flyCloakList; - @Getter private Set costumeList; - @Getter private Set personalLineList; + @Getter private final Set nameCardList; + @Getter private final Set flyCloakList; + @Getter private final Set costumeList; + @Getter private final Set personalLineList; @Getter @Setter private Set rewardedLevels; @Getter @Setter private Set homeRewardedLevels; @Getter @Setter private Set realmList; @Getter @Setter private Set seenRealmList; - @Getter private Set unlockedForgingBlueprints; - @Getter private Set unlockedCombines; - @Getter private Set unlockedFurniture; - @Getter private Set unlockedFurnitureSuite; - @Getter private Map expeditionInfo; - @Getter private Map unlockedRecipies; - @Getter private List activeForges; - @Getter private Map activeCookCompounds; - @Getter private Map questGlobalVariables; - @Getter private Map openStates; - @Getter private Map> sceneTags; + @Getter private final Set unlockedForgingBlueprints; + @Getter private final Set unlockedCombines; + @Getter private final Set unlockedFurniture; + @Getter private final Set unlockedFurnitureSuite; + @Getter private final Map expeditionInfo; + @Getter private final Map unlockedRecipies; + @Getter private final List activeForges; + @Getter private final Map activeCookCompounds; + @Getter private final Map questGlobalVariables; + @Getter private final Map openStates; + @Getter private final Map> sceneTags; @Getter @Setter private Map> unlockedSceneAreas; @Getter @Setter private Map> unlockedScenePoints; @Getter @Setter private List chatEmojiIdList; @@ -133,13 +133,13 @@ public class Player implements PlayerHook, FieldFetch { @Transient @Getter private int areaType = 0; // Player managers go here - @Getter private transient AvatarStorage avatars; - @Getter private transient Inventory inventory; - @Getter private transient FriendsList friendsList; - @Getter private transient MailHandler mailHandler; - @Getter private transient AbilityManager abilityManager; - @Getter private transient QuestManager questManager; - @Getter private transient TowerManager towerManager; + @Getter private final transient AvatarStorage avatars; + @Getter private final transient Inventory inventory; + @Getter private final transient FriendsList friendsList; + @Getter private final transient MailHandler mailHandler; + @Getter private final transient AbilityManager abilityManager; + @Getter private final transient QuestManager questManager; + @Getter private final transient TowerManager towerManager; @Getter private transient SotSManager sotsManager; @Getter private transient MapMarksManager mapMarksManager; @Getter private transient StaminaManager staminaManager; @@ -152,10 +152,10 @@ public class Player implements PlayerHook, FieldFetch { @Getter private transient CookingManager cookingManager; @Getter private transient CookingCompoundManager cookingCompoundManager; @Getter private transient ActivityManager activityManager; - @Getter private transient PlayerBuffManager buffManager; + @Getter private final transient PlayerBuffManager buffManager; @Getter private transient PlayerProgressManager progressManager; @Getter private transient SatiationManager satiationManager; - @Getter private transient TalkManager talkManager; + @Getter private final transient TalkManager talkManager; @Getter @Setter private transient Position lastCheckedPosition = null; @@ -164,9 +164,9 @@ public class Player implements PlayerHook, FieldFetch { private PlayerProfile playerProfile; // Getter has null-check @Getter private TeamManager teamManager; private TowerData towerData; // Getter has null-check - @Getter private PlayerGachaInfo gachaInfo; + @Getter private final PlayerGachaInfo gachaInfo; private PlayerCollectionRecords collectionRecordStore; // Getter has null-check - @Getter private ArrayList shopLimit; + @Getter private final ArrayList shopLimit; @Getter private transient GameHome home; @@ -194,11 +194,11 @@ public class Player implements PlayerHook, FieldFetch { @Getter @Setter private int nextResinRefresh; @Getter @Setter private int resinBuyCount; @Getter @Setter private int lastDailyReset; - @Getter private transient MpSettingType mpSetting = MpSettingType.MP_SETTING_TYPE_ENTER_AFTER_APPLY; + @Getter private final transient MpSettingType mpSetting = MpSettingType.MP_SETTING_TYPE_ENTER_AFTER_APPLY; @Getter private long playerGameTime = 540000; // 9 in-game hours. Present at the start of the game. - @Getter private PlayerProgress playerProgress; - @Getter private Set activeQuestTimers; + @Getter private final PlayerProgress playerProgress; + @Getter private final Set activeQuestTimers; @Getter @Setter private ElementType mainCharacterElement = ElementType.None; diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java index 646ef22d1..4981d4794 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java @@ -14,14 +14,14 @@ public class PlayerCodex { @Transient private Player player; // itemId is not codexId! - @Getter private Set unlockedWeapon; - @Getter private Map unlockedAnimal; - @Getter private Set unlockedMaterial; - @Getter private Set unlockedBook; - @Getter private Set unlockedTip; - @Getter private Set unlockedView; + @Getter private final Set unlockedWeapon; + @Getter private final Map unlockedAnimal; + @Getter private final Set unlockedMaterial; + @Getter private final Set unlockedBook; + @Getter private final Set unlockedTip; + @Getter private final Set unlockedView; @Getter private Set unlockedReliquary; - @Getter private Set unlockedReliquarySuitCodex; + @Getter private final Set unlockedReliquarySuitCodex; public PlayerCodex() { this.unlockedWeapon = new HashSet<>(); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerProgress.java b/src/main/java/emu/grasscutter/game/player/PlayerProgress.java index f66b957ef..43ce48554 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerProgress.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerProgress.java @@ -14,21 +14,21 @@ import lombok.*; @Entity public class PlayerProgress { @Setter @Transient private Player player; - private Map itemHistory; + private final Map itemHistory; /* * A list of dungeon IDs which have been completed. * This only applies to one-time dungeons. */ - private IntArrayList completedDungeons; + private final IntArrayList completedDungeons; // keep track of EXEC_ADD_QUEST_PROGRESS count, will be used in CONTENT_ADD_QUEST_PROGRESS // not sure where to put this, this should be saved to DB but not to individual quest, since // it will be hard to loop and compare - private Map questProgressCountMap; + private final Map questProgressCountMap; - private Map itemGivings; - private Map bargains; + private final Map itemGivings; + private final Map bargains; public PlayerProgress() { this.questProgressCountMap = new ConcurrentHashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 794f36501..397682cde 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -10,7 +10,7 @@ import java.util.*; @Entity public final class TeamInfo { private String name; - private List avatars; + private final List avatars; public TeamInfo() { this.name = ""; diff --git a/src/main/java/emu/grasscutter/game/quest/QuestManager.java b/src/main/java/emu/grasscutter/game/quest/QuestManager.java index 2ac3601ab..cdd40945d 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestManager.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestManager.java @@ -26,7 +26,7 @@ public final class QuestManager extends BasePlayerManager { @Getter private final Player player; @Getter private final Int2ObjectMap mainQuests; - @Getter private Int2ObjectMap acceptProgressLists; + @Getter private final Int2ObjectMap acceptProgressLists; @Getter private final List loggedQuests; private long lastHourCheck = 0; diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 98047d1fc..65fedff48 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -79,7 +79,7 @@ public class Scene { private final List afterLoadedCallbacks = new ArrayList<>(); private final List afterHostInitCallbacks = new ArrayList<>(); - @Getter private GameEntity sceneEntity; + @Getter private final GameEntity sceneEntity; @Getter private final ServerTaskScheduler scheduler; public Scene(World world, SceneData sceneData) { diff --git a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java index fe443e234..a57dc5830 100644 --- a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java +++ b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java @@ -19,11 +19,11 @@ public final class SceneGroupInstance { @Getter private transient SceneGroup luaGroup; @Getter @Setter private int targetSuiteId; @Getter @Setter private int activeSuiteId; - @Getter private Set deadEntities; // Config_ids + @Getter private final Set deadEntities; // Config_ids private boolean isCached; - @Getter private Map cachedGadgetStates; - @Getter private Map cachedVariables; + @Getter private final Map cachedGadgetStates; + @Getter private final Map cachedVariables; @Getter @Setter private int lastTimeRefreshed; diff --git a/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java b/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java index 27865e1ae..8e903c469 100644 --- a/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java +++ b/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java @@ -33,10 +33,10 @@ public class SpawnDataEntry { } public static class GridBlockId { - @Getter private int sceneId; - @Getter private int scale; - @Getter private int x; - @Getter private int z; + @Getter private final int sceneId; + @Getter private final int scale; + @Getter private final int x; + @Getter private final int z; public GridBlockId(int sceneId, int scale, int x, int z) { this.sceneId = sceneId; diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index 434583f6f..f0ca384de 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -48,7 +48,7 @@ public class World implements Iterable { @Getter private final List players; @Getter private final Int2ObjectMap scenes; - @Getter private EntityWorld entity; + @Getter private final EntityWorld entity; private int nextEntityId = 0; private int nextPeerId = 0; private int worldLevel; diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 4e5229600..2a9776a1d 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -55,7 +55,7 @@ public class SceneScriptManager { private final Map sceneGroupsInstances; private final Map cachedSceneGroupsInstances; private ScriptMonsterTideService scriptMonsterTideService; - private ScriptMonsterSpawnService scriptMonsterSpawnService; + private final ScriptMonsterSpawnService scriptMonsterSpawnService; /** blockid - loaded groupSet */ private final Map> loadedGroupSetPerBlock; diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java index de5e14b5c..eaea56215 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java @@ -29,12 +29,12 @@ public class ScriptLoader { @Getter private static ScriptLib scriptLib; @Getter private static LuaValue scriptLibLua; /** suggest GC to remove it if the memory is less */ - private static Map> scriptSources = new ConcurrentHashMap<>(); + private static final Map> scriptSources = new ConcurrentHashMap<>(); - private static Map> scriptsCache = + private static final Map> scriptsCache = new ConcurrentHashMap<>(); /** sceneId - SceneMeta */ - private static Map> sceneMetaCache = new ConcurrentHashMap<>(); + private static final Map> sceneMetaCache = new ConcurrentHashMap<>(); private static final AtomicReference currentBindings = new AtomicReference<>(null); private static final AtomicReference currentContext = new AtomicReference<>(null); diff --git a/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java b/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java index 82b7c2a65..5256ae952 100644 --- a/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java +++ b/src/main/java/emu/grasscutter/scripts/data/controller/EntityController.java @@ -11,8 +11,8 @@ import org.luaj.vm2.*; public class EntityController { private static final Set SERVER_CALLED = Set.of("OnBeHurt", "OnDie", "OnTimer"); - private transient CompiledScript entityController; - private transient Bindings entityControllerBindings; + private final transient CompiledScript entityController; + private final transient Bindings entityControllerBindings; public EntityController(CompiledScript entityController, Bindings entityControllerBindings) { this.entityController = entityController; diff --git a/src/main/java/emu/grasscutter/server/event/game/SceneBlockLoadedEvent.java b/src/main/java/emu/grasscutter/server/event/game/SceneBlockLoadedEvent.java index 1155b018b..2eb711825 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SceneBlockLoadedEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SceneBlockLoadedEvent.java @@ -6,7 +6,7 @@ import lombok.*; @Getter public final class SceneBlockLoadedEvent extends ServerEvent { - private SceneBlock block; + private final SceneBlock block; public SceneBlockLoadedEvent(SceneBlock block) { super(Type.GAME); diff --git a/src/main/java/emu/grasscutter/server/event/game/SceneMetaLoadEvent.java b/src/main/java/emu/grasscutter/server/event/game/SceneMetaLoadEvent.java index 0e5768a00..c0ae72ba7 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SceneMetaLoadEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SceneMetaLoadEvent.java @@ -6,7 +6,7 @@ import lombok.*; @Getter public final class SceneMetaLoadEvent extends ServerEvent { - private Scene scene; + private final Scene scene; @Setter private boolean override; public SceneMetaLoadEvent(Scene scene) { From da61d30f444cbf6bb9d2107908ec40ff97d5cf76 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:50:40 -0300 Subject: [PATCH 02/59] refactor: make getGoodsLimit one liner --- src/main/java/emu/grasscutter/game/player/Player.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 1f8c87c03..c6735d82d 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -896,10 +896,8 @@ public class Player implements PlayerHook, FieldFetch { } public ShopLimit getGoodsLimit(int goodsId) { - Optional shopLimit = this.shopLimit.stream().filter(x -> x.getShopGoodId() == goodsId).findFirst(); - if (shopLimit.isEmpty()) - return null; - return shopLimit.get(); + Optional limitOptional = this.shopLimit.stream().filter(x -> x.getShopGoodId() == goodsId).findFirst(); + return limitOptional.orElse(null); } public void addShopLimit(int goodsId, int boughtCount, int nextRefreshTime) { From ef58ab3e5a56f9e3164c88a4ea0a600bfbdf72c3 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:54:37 -0300 Subject: [PATCH 03/59] refactor: replace `size() == 0` with isEmpty() --- .../command/commands/AchievementCommand.java | 6 +++--- .../command/commands/AnnounceCommand.java | 2 +- .../grasscutter/command/commands/ClearCommand.java | 2 +- .../command/commands/EnterDungeonCommand.java | 2 +- .../grasscutter/command/commands/GiveCommand.java | 4 ++-- .../grasscutter/command/commands/ListCommand.java | 4 ++-- .../command/commands/ResetConstCommand.java | 2 +- .../command/commands/SendMailCommand.java | 2 +- .../command/commands/SendMessageCommand.java | 2 +- .../command/commands/SetConstCommand.java | 2 +- .../grasscutter/command/commands/SpawnCommand.java | 2 +- .../command/commands/TalentCommand.java | 2 +- src/main/java/emu/grasscutter/data/GameDepot.java | 2 +- .../java/emu/grasscutter/data/ResourceLoader.java | 4 ++-- .../grasscutter/data/binout/OpenConfigEntry.java | 4 ++-- .../data/excels/EnvAnimalGatherConfigData.java | 2 +- .../data/excels/RefreshPolicyExcelConfigData.java | 2 +- .../data/excels/avatar/AvatarSkillDepotData.java | 2 +- .../data/excels/tower/TowerScheduleData.java | 2 +- .../grasscutter/game/ability/AbilityManager.java | 14 ++++++-------- .../java/emu/grasscutter/game/avatar/Avatar.java | 8 ++++---- .../game/battlepass/BattlePassManager.java | 2 +- .../java/emu/grasscutter/game/chat/ChatSystem.java | 12 ++++++------ .../grasscutter/game/drop/DropSystemLegacy.java | 2 +- .../grasscutter/game/dungeons/DungeonSystem.java | 2 +- .../emu/grasscutter/game/entity/EntityAvatar.java | 2 +- .../game/expedition/ExpeditionSystem.java | 2 +- .../emu/grasscutter/game/inventory/GameItem.java | 6 +++--- .../emu/grasscutter/game/inventory/Inventory.java | 2 +- .../emu/grasscutter/game/player/InvokeHandler.java | 6 +++--- .../grasscutter/game/player/PlayerBuffManager.java | 2 +- .../emu/grasscutter/game/player/TeamManager.java | 10 +++++----- .../java/emu/grasscutter/game/quest/GameQuest.java | 8 ++++---- .../java/emu/grasscutter/game/shop/ShopSystem.java | 2 +- .../game/systems/AnnouncementSystem.java | 2 +- .../grasscutter/game/systems/InventorySystem.java | 4 ++-- .../emu/grasscutter/game/tower/TowerManager.java | 2 +- .../java/emu/grasscutter/game/world/Scene.java | 8 ++++---- .../java/emu/grasscutter/game/world/World.java | 2 +- .../grasscutter/scripts/SceneScriptManager.java | 2 +- .../scripts/serializer/LuaSerializer.java | 2 +- .../server/http/dispatch/RegionHandler.java | 4 ++-- .../server/http/documentation/HandbookHandler.java | 2 +- ...dlerClientAbilitiesInitFinishCombineNotify.java | 2 +- .../recv/HandlerClientAbilityInitFinishNotify.java | 2 +- .../server/packet/recv/HandlerQueryPathReq.java | 2 +- .../packet/recv/HandlerSetPlayerNameReq.java | 2 +- .../packet/recv/HandlerSetPlayerSignatureReq.java | 2 +- .../send/PacketClientAbilityInitFinishNotify.java | 2 +- .../packet/send/PacketGetAllMailResultNotify.java | 2 +- .../packet/send/PacketGetOnlinePlayerListRsp.java | 2 +- .../server/packet/send/PacketGetScenePointRsp.java | 2 +- .../server/scheduler/ServerTaskScheduler.java | 2 +- src/main/java/emu/grasscutter/tools/Dumpers.java | 2 +- 54 files changed, 89 insertions(+), 91 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index 85603931d..7510895e5 100644 --- a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java @@ -69,7 +69,7 @@ public final class AchievementCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); return; } @@ -88,7 +88,7 @@ public final class AchievementCommand implements CommandHandler { private void grant( Player sender, Player targetPlayer, Achievements achievements, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); } @@ -109,7 +109,7 @@ public final class AchievementCommand implements CommandHandler { private void revoke( Player sender, Player targetPlayer, Achievements achievements, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); } diff --git a/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java b/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java index 9cd76ba13..9433a8a57 100644 --- a/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java @@ -19,7 +19,7 @@ public final class AnnounceCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { var manager = Grasscutter.getGameServer().getAnnouncementSystem(); - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java index 792ce1b3b..bbfb47078 100644 --- a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java @@ -51,7 +51,7 @@ public final class ClearCommand implements CommandHandler { // Extract any tagged int arguments (e.g. "lv90", "x100", "r5") parseIntParameters(args, param, intCommandHandlers); - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java b/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java index c61923452..6bce736f8 100644 --- a/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java @@ -16,7 +16,7 @@ public final class EnterDungeonCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index d5134af34..f7b02892b 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java @@ -279,7 +279,7 @@ public final class GiveCommand implements CommandHandler { parseIntParameters(args, param, intCommandHandlers); // At this point, first remaining argument MUST be itemId/avatarId - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar throw new IllegalArgumentException(); } @@ -362,7 +362,7 @@ public final class GiveCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { // *No args* + if (args.isEmpty()) { // *No args* sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java index ce0259e09..a4831eed6 100644 --- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java @@ -19,14 +19,14 @@ public final class ListCommand implements CommandHandler { Map playersMap = Grasscutter.getGameServer().getPlayers(); boolean needUID = false; - if (args.size() > 0) { + if (!args.isEmpty()) { needUID = args.get(0).equals("uid"); } CommandHandler.sendMessage( sender, translate(sender, "commands.list.success", playersMap.size())); - if (playersMap.size() != 0) { + if (!playersMap.isEmpty()) { StringBuilder playerSet = new StringBuilder(); boolean finalNeedUID = needUID; diff --git a/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java b/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java index acecf334d..1ea37f8b7 100644 --- a/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java @@ -18,7 +18,7 @@ public final class ResetConstCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) { + if (!args.isEmpty() && args.get(0).equalsIgnoreCase("all")) { targetPlayer.getAvatars().forEach(this::resetConstellation); CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.reset_all")); } else { diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index bf4d96246..b1ed3ad4b 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -69,7 +69,7 @@ public final class SendMailCommand implements CommandHandler { } else { MailBuilder mailBuilder = mailBeingConstructed.get(senderId); - if (args.size() >= 1) { + if (!args.isEmpty()) { switch (args.get(0).toLowerCase()) { case "stop" -> { mailBeingConstructed.remove(senderId); diff --git a/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java index cae221176..69d46e103 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java @@ -17,7 +17,7 @@ public final class SendMessageCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() == 0) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java b/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java index 1e0edd264..a8debd4e6 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java @@ -17,7 +17,7 @@ import java.util.List; public final class SetConstCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java b/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java index d62f8b854..a8a0f13e2 100644 --- a/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java @@ -49,7 +49,7 @@ public final class SpawnCommand implements CommandHandler { parseIntParameters(args, param, intCommandHandlers); // At this point, first remaining argument MUST be the id and the rest the pos - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar throw new IllegalArgumentException(); } diff --git a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java index ff71be1bf..6edd2dd68 100644 --- a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java @@ -27,7 +27,7 @@ public final class TalentCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/data/GameDepot.java b/src/main/java/emu/grasscutter/data/GameDepot.java index 34cfd57ee..0d8711318 100644 --- a/src/main/java/emu/grasscutter/data/GameDepot.java +++ b/src/main/java/emu/grasscutter/data/GameDepot.java @@ -50,7 +50,7 @@ public class GameDepot { list.add(data); } // Let the server owner know if theyre missing weights - if (relicMainPropDepot.size() == 0 || relicAffixDepot.size() == 0) { + if (relicMainPropDepot.isEmpty() || relicAffixDepot.isEmpty()) { Grasscutter.getLogger() .error( "Relic properties are missing weights! Please check your ReliquaryMainPropExcelConfigData or ReliquaryAffixExcelConfigData files in your ExcelBinOutput folder."); diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 8a6c91879..7d1b767f8 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -413,7 +413,7 @@ public final class ResourceLoader { GameData.getAbilityHashes().put(Utils.abilityHash(data.abilityName), data.abilityName); var modifiers = data.modifiers; - if (modifiers == null || modifiers.size() == 0) return; + if (modifiers == null || modifiers.isEmpty()) return; var name = data.abilityName; var modifierEntry = new AbilityModifierEntry(name); @@ -647,7 +647,7 @@ public final class ResourceLoader { path -> { try { val data = JsonUtils.loadToClass(path, SceneNpcBornData.class); - if (data.getBornPosList() == null || data.getBornPosList().size() == 0) { + if (data.getBornPosList() == null || data.getBornPosList().isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index 6270eb601..c5f9c1a40 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -25,11 +25,11 @@ public class OpenConfigEntry { } } - if (abilityList.size() > 0) { + if (!abilityList.isEmpty()) { this.addAbilities = abilityList.toArray(new String[0]); } - if (modList.size() > 0) { + if (!modList.isEmpty()) { this.skillPointModifiers = modList.toArray(new SkillPointModifier[0]); } } diff --git a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java index ebec960cb..002c75141 100644 --- a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java @@ -30,6 +30,6 @@ public class EnvAnimalGatherConfigData extends GameResource { } public ItemParamData getGatherItem() { - return gatherItemId.size() > 0 ? gatherItemId.get(0) : null; + return !gatherItemId.isEmpty() ? gatherItemId.get(0) : null; } } diff --git a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java index a81d3a2c8..6429728f8 100644 --- a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java @@ -72,7 +72,7 @@ public class RefreshPolicyExcelConfigData extends GameResource { return (params.get(upper_bound_idx - 1) - params.get(0)); } case REFRESH_DAYBEGIN_INTERVAL: - if (params.size() == 0) return -1; + if (params.isEmpty()) return -1; return params.get(0) * 60 * 60 * 24; } } catch (Exception e) { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java index 0f844701d..1e055ec2e 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java @@ -52,7 +52,7 @@ public class AvatarSkillDepotData extends GameResource { this.elementType = ElementType.None; } // Set embryo abilities (if player skill depot) - if (getSkillDepotAbilityGroup() != null && getSkillDepotAbilityGroup().length() > 0) { + if (getSkillDepotAbilityGroup() != null && !getSkillDepotAbilityGroup().isEmpty()) { AvatarConfig config = GameDepot.getPlayerAbilities().get(getSkillDepotAbilityGroup()); if (config != null) { diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java index 4a050829f..7652e644b 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java @@ -19,7 +19,7 @@ public class TowerScheduleData extends GameResource { public void onLoad() { super.onLoad(); this.schedules = - this.schedules.stream().filter(item -> item.getFloorList().size() > 0).toList(); + this.schedules.stream().filter(item -> !item.getFloorList().isEmpty()).toList(); } public int getScheduleId() { diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index b5bef4276..3bf06e5ad 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -83,14 +83,12 @@ public final class AbilityManager extends BasePlayerManager { boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; if (modifier.onAdded != null) { skillInvincibility |= - Arrays.stream(modifier.onAdded) - .filter( - action -> - action.type == AbilityModifierAction.Type.AttachAbilityStateResistance - && action.resistanceListID == 11002) - .toList() - .size() - > 0; + !Arrays.stream(modifier.onAdded) + .filter( + action -> + action.type == AbilityModifierAction.Type.AttachAbilityStateResistance + && action.resistanceListID == 11002) + .toList().isEmpty(); } if (this.burstCasterId == entityId diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 0bae0a2b4..fe3b5e424 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -636,7 +636,7 @@ public class Avatar { } } // Add weapon skill from affixes - if (weapon.getAffixes() != null && weapon.getAffixes().size() > 0) { + if (weapon.getAffixes() != null && !weapon.getAffixes().isEmpty()) { // Weapons usually dont have more than one affix but just in case... for (int af : weapon.getAffixes()) { if (af == 0) { @@ -740,7 +740,7 @@ public class Avatar { } public void addToExtraAbilityEmbryos(String openConfig, boolean forceAdd) { - if (openConfig == null || openConfig.length() == 0) { + if (openConfig == null || openConfig.isEmpty()) { return; } @@ -801,7 +801,7 @@ public class Avatar { .filter(Objects::nonNull) .map(AvatarTalentData::getOpenConfig) .filter(Objects::nonNull) - .filter(openConfig -> openConfig.length() > 0) + .filter(openConfig -> !openConfig.isEmpty()) .map(GameData.getOpenConfigEntries()::get) .filter(Objects::nonNull) .forEach(e -> this.calcConstellation(e, false)); @@ -830,7 +830,7 @@ public class Avatar { case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill - case 1 -> (this.skillDepot.getSkills().size() >= 1) + case 1 -> (!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) default -> 0; diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java index 0d48355a5..f72c00e64 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java @@ -176,7 +176,7 @@ public class BattlePassManager extends BasePlayerDataManager { private void takeRewardsFromSelectChest( ItemData rewardItemData, int index, ItemParamData entry, List rewardItems) { // Sanity checks. - if (rewardItemData.getItemUse().size() < 1) { + if (rewardItemData.getItemUse().isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java index dd86b0568..9bd64ba32 100644 --- a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java +++ b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java @@ -88,7 +88,7 @@ public class ChatSystem implements ChatSystemHandler { ********************/ public void sendPrivateMessageFromServer(int targetUid, String message) { // Sanity checks. - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -123,7 +123,7 @@ public class ChatSystem implements ChatSystemHandler { public void sendPrivateMessage(Player player, int targetUid, String message) { // Sanity checks. - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -146,7 +146,7 @@ public class ChatSystem implements ChatSystemHandler { // Fetch the new message. message = event.getMessage(); - if (message == null || message.length() == 0) return; + if (message == null || message.isEmpty()) return; // Create chat packet. var packet = new PacketPrivateChatNotify(player.getUid(), targetUid, message); @@ -200,7 +200,7 @@ public class ChatSystem implements ChatSystemHandler { public void sendTeamMessage(Player player, int channel, String message) { // Sanity checks - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -216,7 +216,7 @@ public class ChatSystem implements ChatSystemHandler { // Fetch the new message. message = event.getMessage(); - if (message == null || message.length() == 0) return; + if (message == null || message.isEmpty()) return; // Fetch the new channel. channel = event.getChannel(); if (channel == -1) return; @@ -254,7 +254,7 @@ public class ChatSystem implements ChatSystemHandler { joinOptions.welcomeEmotes[Utils.randomRange(0, joinOptions.welcomeEmotes.length - 1)]); } - if (joinOptions.welcomeMessage != null && joinOptions.welcomeMessage.length() > 0) { + if (joinOptions.welcomeMessage != null && !joinOptions.welcomeMessage.isEmpty()) { this.sendPrivateMessageFromServer(player.getUid(), joinOptions.welcomeMessage); } } diff --git a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java index d0167ab40..00bdfcb45 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java +++ b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java @@ -31,7 +31,7 @@ public class DropSystemLegacy extends BaseGameSystem { getDropData().clear(); try { List banners = DataLoader.loadList("Drop.json", DropInfo.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (DropInfo di : banners) { getDropData().put(di.getMonsterId(), di.getDropDataList()); } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java index ee56a873c..fdfc92378 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java @@ -68,7 +68,7 @@ public final class DungeonSystem extends BaseGameSystem { // Check if the player has quests with dungeon IDs. var questDungeons = player.getQuestManager().questsForDungeon(entry); - if (questDungeons.size() > 0) { + if (!questDungeons.isEmpty()) { player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData(), questDungeons)); } else { player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData())); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index 2bff768ba..8a4303430 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -363,7 +363,7 @@ public class EntityAvatar extends GameEntity { } } // Add equip abilities - if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) { + if (!this.getAvatar().getExtraAbilityEmbryos().isEmpty()) { for (String skill : this.getAvatar().getExtraAbilityEmbryos()) { AbilityEmbryo emb = AbilityEmbryo.newBuilder() diff --git a/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java b/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java index d58d4cf62..b2fa5916f 100644 --- a/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java +++ b/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java @@ -24,7 +24,7 @@ public class ExpeditionSystem extends BaseGameSystem { try { List banners = DataLoader.loadList("ExpeditionReward.json", ExpeditionRewardInfo.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (ExpeditionRewardInfo di : banners) { getExpeditionRewardDataList().put(di.getExpId(), di.getExpeditionRewardDataList()); } diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index a89f9f30f..239ac8e9f 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -277,9 +277,9 @@ public class GameItem { .setGuid(this.getGuid()) .setLevel(this.getLevel()) .setGadgetId(this.getItemData().getGadgetId()) - .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0)); + .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(!getAffixes().isEmpty())); - if (this.getAffixes() != null && this.getAffixes().size() > 0) { + if (this.getAffixes() != null && !this.getAffixes().isEmpty()) { for (int affix : this.getAffixes()) { weaponInfo.putAffixMap(affix, this.getRefinement()); } @@ -306,7 +306,7 @@ public class GameItem { .setExp(this.getExp()) .setPromoteLevel(this.getPromoteLevel()); - if (this.getAffixes() != null && this.getAffixes().size() > 0) { + if (this.getAffixes() != null && !this.getAffixes().isEmpty()) { for (int affix : this.getAffixes()) { weapon.putAffixMap(affix, this.getRefinement()); } diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 7967617c1..0a5b99999 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -178,7 +178,7 @@ public class Inventory extends BasePlayerManager implements Iterable { changedItems.add(result); } } - if (changedItems.size() == 0) { + if (changedItems.isEmpty()) { return; } if (reason != null) { diff --git a/src/main/java/emu/grasscutter/game/player/InvokeHandler.java b/src/main/java/emu/grasscutter/game/player/InvokeHandler.java index b6e3e4c5a..7bebf19fe 100644 --- a/src/main/java/emu/grasscutter/game/player/InvokeHandler.java +++ b/src/main/java/emu/grasscutter/game/player/InvokeHandler.java @@ -36,13 +36,13 @@ public class InvokeHandler { } try { - if (entryListForwardAll.size() > 0) { + if (!entryListForwardAll.isEmpty()) { BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAll); player.getScene().broadcastPacket(packet); this.entryListForwardAll.clear(); } - if (entryListForwardAllExceptCur.size() > 0) { + if (!entryListForwardAllExceptCur.isEmpty()) { BasePacket packet = packetClass .getDeclaredConstructor(List.class) @@ -50,7 +50,7 @@ public class InvokeHandler { player.getScene().broadcastPacketToOthers(player, packet); this.entryListForwardAllExceptCur.clear(); } - if (entryListForwardHost.size() > 0) { + if (!entryListForwardHost.isEmpty()) { BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardHost); player.getWorld().getHost().sendPacket(packet); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java b/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java index 9fc66d37e..ca7a2dbdd 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java @@ -178,7 +178,7 @@ public final class PlayerBuffManager extends BasePlayerManager { return true; }); - if (this.pendingBuffs.size() > 0) { + if (!this.pendingBuffs.isEmpty()) { // Send packet getPlayer() .sendPacket( diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index 86d7a0d45..0e19dfd90 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -98,7 +98,7 @@ public final class TeamManager extends BasePlayerDataManager { } // same as avatar ability hash (add frm levelEntityConfig data) - if (this.getTeamAbilityEmbryos().size() > 0) { + if (!this.getTeamAbilityEmbryos().isEmpty()) { for (String skill : this.getTeamAbilityEmbryos()) { AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() @@ -495,7 +495,7 @@ public final class TeamManager extends BasePlayerDataManager { public void setupMpTeam(List list) { // Sanity checks - if (list.size() == 0 + if (list.isEmpty() || list.size() > this.getMaxTeamSize() || !this.getPlayer().isInMultiplayer()) { return; @@ -696,7 +696,7 @@ public final class TeamManager extends BasePlayerDataManager { .map( list -> { // Sanity checks - if (list.size() == 0 || list.size() > this.getMaxTeamSize()) { + if (list.isEmpty() || list.size() > this.getMaxTeamSize()) { return null; } @@ -744,7 +744,7 @@ public final class TeamManager extends BasePlayerDataManager { // Get team TeamInfo teamInfo = this.getTeams().get(teamId); - if (teamInfo == null || teamInfo.getAvatars().size() == 0) { + if (teamInfo == null || teamInfo.getAvatars().isEmpty()) { return; } @@ -1054,7 +1054,7 @@ public final class TeamManager extends BasePlayerDataManager { var avatarIds = scene.getSceneData().getSpecifiedAvatarList(); var specifiedAvatarList = this.getActiveTeam(); - if (avatarIds != null && avatarIds.size() > 0) { + if (avatarIds != null && !avatarIds.isEmpty()) { // certain scene could limit specific avatars' entry specifiedAvatarList.clear(); for (int id : avatarIds) { diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index 7888e4701..6ac1d1313 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -67,7 +67,7 @@ public class GameQuest { questData.getFinishCond().stream() .filter(p -> p.getType() == QuestContent.QUEST_CONTENT_TRIGGER_FIRE) .toList(); - if (triggerCond.size() > 0) { + if (!triggerCond.isEmpty()) { for (val cond : triggerCond) { var newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]); if (newTrigger != null) { @@ -158,14 +158,14 @@ public class GameQuest { public boolean clearProgress(boolean notifyDelete) { // TODO improve var oldState = state; - if (questData.getAcceptCond() != null && questData.getAcceptCond().size() != 0) { + if (questData.getAcceptCond() != null && !questData.getAcceptCond().isEmpty()) { this.getMainQuest() .getQuestManager() .getAcceptProgressLists() .put(this.getSubQuestId(), new int[questData.getAcceptCond().size()]); } - if (questData.getFinishCond() != null && questData.getFinishCond().size() != 0) { + if (questData.getFinishCond() != null && !questData.getFinishCond().isEmpty()) { for (var condition : questData.getFinishCond()) { if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) { this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr()); @@ -174,7 +174,7 @@ public class GameQuest { this.finishProgressList = new int[questData.getFinishCond().size()]; } - if (questData.getFailCond() != null && questData.getFailCond().size() != 0) { + if (questData.getFailCond() != null && !questData.getFailCond().isEmpty()) { for (var condition : questData.getFailCond()) { if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) { this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr()); diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index f3ce4679a..613834f45 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -48,7 +48,7 @@ public class ShopSystem extends BaseGameSystem { getShopData().clear(); try { List banners = DataLoader.loadList("Shop.json", ShopTable.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (ShopTable shopTable : banners) { shopTable.getItems().forEach(ShopInfo::removeVirtualCosts); getShopData().put(shopTable.getShopId(), shopTable.getItems()); diff --git a/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java b/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java index 16bf1b23f..6d21eb052 100644 --- a/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java +++ b/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java @@ -44,7 +44,7 @@ public class AnnouncementSystem extends BaseGameSystem { } public void broadcast(List tpl) { - if (tpl == null || tpl.size() == 0) { + if (tpl == null || tpl.isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 3072eebab..568872e23 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -482,7 +482,7 @@ public class InventorySystem extends BaseGameSystem { if (weapon.getRefinement() >= 4 || weapon.getAffixes() == null - || weapon.getAffixes().size() == 0) { + || weapon.getAffixes().isEmpty()) { return; } @@ -818,7 +818,7 @@ public class InventorySystem extends BaseGameSystem { } // Give back items - if (returnMaterialMap.size() > 0) { + if (!returnMaterialMap.isEmpty()) { returnMaterialMap.forEach((id, count) -> inventory.addItem(new GameItem(id, count))); } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerManager.java b/src/main/java/emu/grasscutter/game/tower/TowerManager.java index 505543c12..b81d206ab 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerManager.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerManager.java @@ -71,7 +71,7 @@ public class TowerManager extends BasePlayerManager { public Map getRecordMap() { Map recordMap = getTowerData().recordMap; - if (recordMap == null || recordMap.size() == 0) { + if (recordMap == null || recordMap.isEmpty()) { recordMap = new HashMap<>(); recordMap.put(1001, new TowerLevelRecord(1001)); getTowerData().recordMap = recordMap; diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 65fedff48..125188838 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -882,12 +882,12 @@ public class Scene { } } - if (toAdd.size() > 0) { + if (!toAdd.isEmpty()) { toAdd.forEach(this::addEntityDirectly); this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_TYPE_BORN)); } - if (toRemove.size() > 0) { + if (!toRemove.isEmpty()) { toRemove.forEach(this::removeEntityDirectly); this.broadcastPacket( new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE)); @@ -1110,7 +1110,7 @@ public class Scene { .filter(e -> e != null && (e.getBlockId() == block.id && e.getGroupId() == group_id)) .toList(); - if (toRemove.size() > 0) { + if (!toRemove.isEmpty()) { toRemove.forEach(this::removeEntityDirectly); this.broadcastPacket( new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE)); @@ -1253,7 +1253,7 @@ public class Scene { sceneNpcBornEntries.add(i); }); - if (sceneNpcBornEntries.size() > 0) { + if (!sceneNpcBornEntries.isEmpty()) { this.broadcastPacket(new PacketGroupSuiteNotify(sceneNpcBornEntries)); Grasscutter.getLogger().trace("Loaded Npc Group Suite {}", sceneNpcBornEntries); } diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index f0ca384de..115a57c80 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -296,7 +296,7 @@ public class World implements Iterable { scene.removePlayer(player); // Info packet for other players - if (this.getPlayers().size() > 0) { + if (!this.getPlayers().isEmpty()) { this.updatePlayerInfos(player); } diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 2a9776a1d..ca5113167 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -678,7 +678,7 @@ public class SceneScriptManager { } public void checkRegions() { - if (this.regions.size() == 0) { + if (this.regions.isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java b/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java index cc7c44556..c3839f2e7 100644 --- a/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java +++ b/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java @@ -239,7 +239,7 @@ public class LuaSerializer implements Serializer { } public String getSetterName(String fieldName) { - if (fieldName == null || fieldName.length() == 0) { + if (fieldName == null || fieldName.isEmpty()) { return null; } if (fieldName.length() == 1) { diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index 37e30a6a3..94d1ba60e 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -53,12 +53,12 @@ public final class RegionHandler implements Router { var usedNames = new ArrayList(); // List to check for potential naming conflicts. var configuredRegions = new ArrayList<>(DISPATCH_INFO.regions); - if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.size() == 0) { + if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.isEmpty()) { Grasscutter.getLogger() .error( "[Dispatch] There are no game servers available. Exiting due to unplayable state."); System.exit(1); - } else if (configuredRegions.size() == 0) + } else if (configuredRegions.isEmpty()) configuredRegions.add( new Region( "os_usa", 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 e4de100e0..5b1f406a4 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -26,7 +26,7 @@ public final class HandbookHandler implements Router { */ public HandbookHandler() { this.handbook = new String(FileUtils.readResource("/html/handbook.html")); - this.serve = HANDBOOK.enable && this.handbook.length() > 0; + this.serve = HANDBOOK.enable && !this.handbook.isEmpty(); var server = HANDBOOK.server; if (this.serve && server.enforced) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java index 626f8f097..7b794f220 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java @@ -26,7 +26,7 @@ public class HandlerClientAbilitiesInitFinishCombineNotify extends PacketHandler player.getClientAbilityInitFinishHandler().addEntry(ability.getForwardType(), ability); } - if (entry.getInvokesList().size() > 0) { + if (!entry.getInvokesList().isEmpty()) { session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer()); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java index a9cb1ccdb..f8c80383b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java @@ -23,7 +23,7 @@ public class HandlerClientAbilityInitFinishNotify extends PacketHandler { player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry); } - if (notif.getInvokesList().size() > 0) { + if (!notif.getInvokesList().isEmpty()) { session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer()); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java index 3bfd7bd17..6b4efa4be 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java @@ -13,7 +13,7 @@ public class HandlerQueryPathReq extends PacketHandler { var req = QueryPathReq.parseFrom(payload); /** It is not the actual work */ - if (req.getDestinationPosList().size() > 0) { + if (!req.getDestinationPosList().isEmpty()) { session.send(new PacketQueryPathRsp(req)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java index 2ceb23653..107cce89a 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java @@ -13,7 +13,7 @@ public class HandlerSetPlayerNameReq extends PacketHandler { // Auto template SetPlayerNameReq req = SetPlayerNameReq.parseFrom(payload); - if (req.getNickName() != null && req.getNickName().length() > 0) { + if (req.getNickName() != null && !req.getNickName().isEmpty()) { session.getPlayer().setNickname(req.getNickName()); session.send(new PacketSetPlayerNameRsp(session.getPlayer())); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java index 335d63b99..868dd81f7 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java @@ -13,7 +13,7 @@ public class HandlerSetPlayerSignatureReq extends PacketHandler { // Auto template SetPlayerSignatureReq req = SetPlayerSignatureReq.parseFrom(payload); - if (req.getSignature() != null && req.getSignature().length() > 0) { + if (req.getSignature() != null && !req.getSignature().isEmpty()) { session.getPlayer().setSignature(req.getSignature()); session.send(new PacketSetPlayerSignatureRsp(session.getPlayer())); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java index 8d1b9a3b1..255c9ff03 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java @@ -12,7 +12,7 @@ public class PacketClientAbilityInitFinishNotify extends BasePacket { int entityId = 0; - if (entries.size() > 0) { + if (!entries.isEmpty()) { AbilityInvokeEntry entry = entries.get(0); entityId = entry.getEntityId(); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java index 2c6fc2009..cda3a8048 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java @@ -23,7 +23,7 @@ public final class PacketGetAllMailResultNotify extends BasePacket { .setPacketNum(1); var inbox = player.getAllMail(); - if (!gifts && inbox.size() > 0) { + if (!gifts && !inbox.isEmpty()) { packet.addAllMailList( inbox.stream() .filter(mail -> mail.stateValue == 1) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java index ab691f46b..c0ad15beb 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java @@ -15,7 +15,7 @@ public class PacketGetOnlinePlayerListRsp extends BasePacket { GetOnlinePlayerListRsp.Builder proto = GetOnlinePlayerListRsp.newBuilder(); - if (players.size() != 0) { + if (!players.isEmpty()) { for (Player player : players) { if (player.getUid() == session.getUid()) continue; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java index 609376fb1..8d0c1c57b 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java @@ -12,7 +12,7 @@ public class PacketGetScenePointRsp extends BasePacket { GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder().setSceneId(sceneId); - if (GameData.getScenePointIdList().size() == 0) { + if (GameData.getScenePointIdList().isEmpty()) { for (int i = 1; i < 1000; i++) { p.addUnlockedPointList(i); p.addUnhidePointList(i); diff --git a/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java b/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java index 4474cc5cb..6fd7f2f61 100644 --- a/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java +++ b/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java @@ -23,7 +23,7 @@ public final class ServerTaskScheduler { */ public void runTasks() { // Skip if there are no tasks. - if (this.tasks.size() == 0) return; + if (this.tasks.isEmpty()) return; // Run all tasks. for (ServerTask task : this.tasks.values()) { diff --git a/src/main/java/emu/grasscutter/tools/Dumpers.java b/src/main/java/emu/grasscutter/tools/Dumpers.java index d3e7b35e5..47c0e663b 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ public interface Dumpers { Language.getTextMapKey(item.getNameTextMapHash()).get(locale), Quality.from(item.getRankLevel()), item.getItemType(), - item.getIcon().length() > 0 ? item.getIcon().substring(3) : ""))); + !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); // Create a new dump with filtered duplicates. var names = new ArrayList(); From c3eafba07213e4a373bca603e985d42cbb2aa143 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:55:58 -0300 Subject: [PATCH 04/59] refactor: remove unnecessary toString call --- src/main/java/emu/grasscutter/utils/lang/Language.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 25bf8bdbd..5cfd173c2 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -361,7 +361,7 @@ public final class Language { } catch (NoSuchFileException ignored) { // Cache doesn't exist, generate it. } catch (Exception exception) { - Grasscutter.getLogger().error("Error loading textmaps cache: " + exception.toString()); + Grasscutter.getLogger().error("Error loading textmaps cache: " + exception); } // Regenerate cache From 029ef823e1d6002a431a5240b5e9fd40c2f408d2 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:56:58 -0300 Subject: [PATCH 05/59] refactor: remove unnecessary semicolons --- src/main/java/emu/grasscutter/data/ResourceLoader.java | 3 --- .../java/emu/grasscutter/data/binout/AbilityMixinData.java | 2 +- src/main/java/emu/grasscutter/data/binout/AbilityModifier.java | 2 +- src/main/java/emu/grasscutter/data/binout/TalentData.java | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 7d1b767f8..734d51d1a 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -837,7 +837,6 @@ public final class ResourceLoader { try { JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class) .forEach(entry -> subfieldMap.put(entry.getEntityId(), entry)); - ; } catch (IOException | NullPointerException ignored) { } Grasscutter.getLogger().debug("Loaded {} subfield mappings.", subfieldMap.size()); @@ -851,7 +850,6 @@ public final class ResourceLoader { JsonUtils.loadToList( getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class) .forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry)); - ; } catch (IOException | NullPointerException ignored) { } Grasscutter.getLogger().debug("Loaded {} drop subfield mappings.", dropSubfieldMap.size()); @@ -866,7 +864,6 @@ public final class ResourceLoader { getResourcePath("Server/DropTableExcelConfigData.json"), DropTableExcelConfigData.class) .forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry)); - ; } catch (IOException | NullPointerException ignored) { } Grasscutter.getLogger() diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java index 50388dec3..649478655 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java @@ -13,7 +13,7 @@ public class AbilityMixinData implements Serializable { AttachToGadgetStateMixin, AttachToStateIDMixin, ShieldBarMixin, - TileAttackManagerMixin; + TileAttackManagerMixin } @SerializedName("$type") diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 562616bb4..fe08cccf5 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -264,7 +264,7 @@ public class AbilityModifier implements Serializable { TurnDirectionToPos, UpdateReactionDamage, UseSkillEliteSet, - WidgetSkillStart; + WidgetSkillStart } @SerializedName("$type") diff --git a/src/main/java/emu/grasscutter/data/binout/TalentData.java b/src/main/java/emu/grasscutter/data/binout/TalentData.java index 29b0b93b4..ae2994020 100644 --- a/src/main/java/emu/grasscutter/data/binout/TalentData.java +++ b/src/main/java/emu/grasscutter/data/binout/TalentData.java @@ -10,7 +10,7 @@ public class TalentData implements Serializable { ModifySkillCD, UnlockTalentParam, AddTalentExtraLevel, - ModifyAbility; + ModifyAbility } @SerializedName("$type") From 9fa0f2bcad5eaf9e33b58f6eb14b373274c08008 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:58:01 -0300 Subject: [PATCH 06/59] refactor: unwrap redundant code block --- .../command/commands/GroupCommand.java | 4 +- .../command/commands/SendMailCommand.java | 14 +++---- .../command/commands/TalentCommand.java | 4 +- .../grasscutter/game/player/PlayerCodex.java | 38 +++++++++---------- .../packet/recv/HandlerTryEnterHomeReq.java | 28 ++++++-------- .../packet/send/PacketVehicleInteractRsp.java | 12 ++---- 6 files changed, 40 insertions(+), 60 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GroupCommand.java b/src/main/java/emu/grasscutter/command/commands/GroupCommand.java index 97359285f..4e44ec558 100644 --- a/src/main/java/emu/grasscutter/command/commands/GroupCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GroupCommand.java @@ -63,9 +63,7 @@ public final class GroupCommand implements CommandHandler { CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId)); } - default -> { - sendUsageMessage(sender); - } + default -> sendUsageMessage(sender); } } } diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index b1ed3ad4b..c4c0e6a4f 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -106,14 +106,12 @@ public final class SendMailCommand implements CommandHandler { getConstructionArgs(mailBuilder.constructionStage, sender))); } } - case "help" -> { - CommandHandler.sendMessage( - sender, - translate( - sender, - "commands.sendMail.please_use", - getConstructionArgs(mailBuilder.constructionStage, sender))); - } + case "help" -> CommandHandler.sendMessage( + sender, + translate( + sender, + "commands.sendMail.please_use", + getConstructionArgs(mailBuilder.constructionStage, sender))); default -> { switch (mailBuilder.constructionStage) { case 0 -> { diff --git a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java index 6edd2dd68..fb071e564 100644 --- a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java @@ -45,9 +45,7 @@ public final class TalentCommand implements CommandHandler { String cmdSwitch = args.get(0).toLowerCase(); switch (cmdSwitch) { - default -> { - sendUsageMessage(sender); - } + default -> sendUsageMessage(sender); case "set" -> { if (args.size() < 3) { sendUsageMessage(sender); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java index 4981d4794..f724d5d5e 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java @@ -48,16 +48,14 @@ public class PlayerCodex { val itemData = item.getItemData(); val itemId = item.getItemId(); switch (itemData.getItemType()) { - case ITEM_WEAPON -> { - Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId)) - .ifPresent( - codexData -> { - if (this.getUnlockedWeapon().add(itemId)) { - this.player.save(); - this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId())); - } - }); - } + case ITEM_WEAPON -> Optional.ofNullable(GameData.getCodexWeaponDataIdMap().get(itemId)) + .ifPresent( + codexData -> { + if (this.getUnlockedWeapon().add(itemId)) { + this.player.save(); + this.player.sendPacket(new PacketCodexDataUpdateNotify(2, codexData.getId())); + } + }); case ITEM_MATERIAL -> { switch (itemData.getMaterialType()) { // Is this check even needed? @@ -65,17 +63,15 @@ public class PlayerCodex { MATERIAL_WIDGET, MATERIAL_EXCHANGE, MATERIAL_AVATAR_MATERIAL, - MATERIAL_NOTICE_ADD_HP -> { - Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId)) - .ifPresent( - codexData -> { - if (this.getUnlockedMaterial().add(itemId)) { - this.player.save(); - this.player.sendPacket( - new PacketCodexDataUpdateNotify(4, codexData.getId())); - } - }); - } + MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId)) + .ifPresent( + codexData -> { + if (this.getUnlockedMaterial().add(itemId)) { + this.player.save(); + this.player.sendPacket( + new PacketCodexDataUpdateNotify(4, codexData.getId())); + } + }); default -> {} } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index 6eaebaaa7..e2425fc36 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -43,24 +43,20 @@ public class HandlerTryEnterHomeReq extends PacketHandler { } } case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption - .FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> { - session.send( - new PacketTryEnterHomeRsp( - RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, - req.getTargetUid())); - } + .FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> session.send( + new PacketTryEnterHomeRsp( + RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, + req.getTargetUid())); case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption - .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { - session - .getServer() - .getHomeWorldMPSystem() - .enterHome( - session.getPlayer(), - targetPlayer, - req.getTargetPoint(), - req.getIsTransferToSafePoint()); - } + .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> session + .getServer() + .getHomeWorldMPSystem() + .enterHome( + session.getPlayer(), + targetPlayer, + req.getTargetPoint(), + req.getIsTransferToSafePoint()); } return; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java index d97be81c9..f1df152c9 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java @@ -37,9 +37,7 @@ public class PacketVehicleInteractRsp extends BasePacket { QuestContent.QUEST_CONTENT_ENTER_VEHICLE, ((EntityVehicle) vehicle).getGadgetId()); } - case VEHICLE_INTERACT_TYPE_OUT -> { - ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember); - } + case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember); default -> {} } } @@ -57,12 +55,8 @@ public class PacketVehicleInteractRsp extends BasePacket { proto.setMember(vehicleMember); switch (interactType) { - case VEHICLE_INTERACT_TYPE_IN -> { - vehicle.getVehicleMembers().add(vehicleMember); - } - case VEHICLE_INTERACT_TYPE_OUT -> { - vehicle.getVehicleMembers().remove(vehicleMember); - } + case VEHICLE_INTERACT_TYPE_IN -> vehicle.getVehicleMembers().add(vehicleMember); + case VEHICLE_INTERACT_TYPE_OUT -> vehicle.getVehicleMembers().remove(vehicleMember); default -> {} } } From 7d3abb083bf94c8d0ff76dffb4c691f8a4bb9d62 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:00:39 -0300 Subject: [PATCH 07/59] refactor: this can also be final --- .../java/emu/grasscutter/DebugConstants.java | 12 +- .../java/emu/grasscutter/GameConstants.java | 4 +- .../command/commands/SetPropCommand.java | 6 +- .../command/commands/SetStatsCommand.java | 4 +- .../grasscutter/config/ConfigContainer.java | 246 +++++++++--------- .../data/binout/AbilityModifierEntry.java | 6 +- .../grasscutter/data/common/DynamicFloat.java | 2 +- .../dungeons/dungeon_results/TowerResult.java | 10 +- .../TrialAvatarDungeonResult.java | 2 +- .../java/emu/grasscutter/game/mail/Mail.java | 14 +- .../props/ItemUseAction/UseItemParams.java | 4 +- .../grasscutter/net/packet/BasePacket.java | 2 +- .../emu/grasscutter/plugin/PluginManager.java | 2 +- .../http/objects/ComboTokenResJson.java | 2 +- .../server/http/objects/LoginResultJson.java | 4 +- .../task/tasks/AnnouncementTask.java | 2 +- .../java/emu/grasscutter/utils/Crypto.java | 4 +- .../utils/algorithms/KahnsSort.java | 9 +- 18 files changed, 168 insertions(+), 167 deletions(-) diff --git a/src/main/java/emu/grasscutter/DebugConstants.java b/src/main/java/emu/grasscutter/DebugConstants.java index 474db035f..1338fcbc7 100644 --- a/src/main/java/emu/grasscutter/DebugConstants.java +++ b/src/main/java/emu/grasscutter/DebugConstants.java @@ -1,12 +1,12 @@ package emu.grasscutter; public final class DebugConstants { - public static boolean LOG_ABILITIES = false; - public static boolean LOG_LUA_SCRIPTS = false; - public static boolean LOG_QUEST_START = false; - public static boolean LOG_MISSING_ABILITIES = false; - public static boolean LOG_MISSING_LUA_SCRIPTS = false; - public static boolean LOG_MISSING_ABILITY_HANDLERS = false; + public static final boolean LOG_ABILITIES = false; + public static final boolean LOG_LUA_SCRIPTS = false; + public static final boolean LOG_QUEST_START = false; + public static final boolean LOG_MISSING_ABILITIES = false; + public static final boolean LOG_MISSING_LUA_SCRIPTS = false; + public static final boolean LOG_MISSING_ABILITY_HANDLERS = false; /** * WARNING: THIS IS A DANGEROUS SETTING. DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING. This diff --git a/src/main/java/emu/grasscutter/GameConstants.java b/src/main/java/emu/grasscutter/GameConstants.java index 8923b3380..30a4ce31e 100644 --- a/src/main/java/emu/grasscutter/GameConstants.java +++ b/src/main/java/emu/grasscutter/GameConstants.java @@ -7,8 +7,8 @@ import emu.grasscutter.utils.objects.SparseSet; import java.util.Arrays; public final class GameConstants { - public static String VERSION = "4.0.0"; - public static int[] VERSION_PARTS = {4, 0, 0}; + public static final String VERSION = "4.0.0"; + public static final int[] VERSION_PARTS = {4, 0, 0}; public static boolean DEBUG = false; public static final int DEFAULT_TEAMS = 4; diff --git a/src/main/java/emu/grasscutter/command/commands/SetPropCommand.java b/src/main/java/emu/grasscutter/command/commands/SetPropCommand.java index 6cd5b0f14..992899c1e 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetPropCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetPropCommand.java @@ -291,9 +291,9 @@ public final class SetPropCommand implements CommandHandler { } static class Prop { - String name; - PlayerProperty prop; - PseudoProp pseudoProp; + final String name; + final PlayerProperty prop; + final PseudoProp pseudoProp; public Prop(PlayerProperty prop) { this(prop.toString(), prop, PseudoProp.NONE); diff --git a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java index f88239926..1cc63d35c 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetStatsCommand.java @@ -171,8 +171,8 @@ public final class SetStatsCommand implements CommandHandler { } private static class Stat { - String name; - FightProperty prop; + final String name; + final FightProperty prop; public Stat(FightProperty prop) { this.name = prop.toString(); diff --git a/src/main/java/emu/grasscutter/config/ConfigContainer.java b/src/main/java/emu/grasscutter/config/ConfigContainer.java index 2b6d20978..1cb60fe91 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -78,11 +78,11 @@ public class ConfigContainer { } } - public Structure folderStructure = new Structure(); - public Database databaseInfo = new Database(); - public Language language = new Language(); - public Account account = new Account(); - public Server server = new Server(); + public final Structure folderStructure = new Structure(); + public final Database databaseInfo = new Database(); + public final Language language = new Language(); + public final Account account = new Account(); + public final Server server = new Server(); // DO NOT. TOUCH. THE VERSION NUMBER. public int version = version(); @@ -90,99 +90,99 @@ public class ConfigContainer { /* Option containers. */ public static class Database { - public DataStore server = new DataStore(); - public DataStore game = new DataStore(); + public final DataStore server = new DataStore(); + public final DataStore game = new DataStore(); public static class DataStore { - public String connectionUri = "mongodb://localhost:27017"; - public String collection = "grasscutter"; + public final String connectionUri = "mongodb://localhost:27017"; + public final String collection = "grasscutter"; } } public static class Structure { - public String resources = "./resources/"; - public String data = "./data/"; - public String packets = "./packets/"; - public String scripts = "resources:Scripts/"; - public String plugins = "./plugins/"; - public String cache = "./cache/"; + public final String resources = "./resources/"; + public final String data = "./data/"; + public final String packets = "./packets/"; + public final String scripts = "resources:Scripts/"; + public final String plugins = "./plugins/"; + public final String cache = "./cache/"; // UNUSED (potentially added later?) // public String dumps = "./dumps/"; } public static class Server { - public Set debugWhitelist = Set.of(); - public Set debugBlacklist = Set.of(); - public ServerRunMode runMode = ServerRunMode.HYBRID; - public boolean logCommands = false; + public final Set debugWhitelist = Set.of(); + public final Set debugBlacklist = Set.of(); + public final ServerRunMode runMode = ServerRunMode.HYBRID; + public final boolean logCommands = false; /** * If enabled, the 'require' Lua function will load the script's compiled varient into the context. (faster; doesn't work as well) * If disabled, all 'require' calls will be replaced with the referenced script's source. (slower; works better) */ - public boolean fastRequire = true; + public final boolean fastRequire = true; - public HTTP http = new HTTP(); - public Game game = new Game(); + public final HTTP http = new HTTP(); + public final Game game = new Game(); - public Dispatch dispatch = new Dispatch(); - public DebugMode debugMode = new DebugMode(); + public final Dispatch dispatch = new Dispatch(); + public final DebugMode debugMode = new DebugMode(); } public static class Language { public Locale language = Locale.getDefault(); - public Locale fallback = Locale.US; - public String document = "EN"; + public final Locale fallback = Locale.US; + public final String document = "EN"; } public static class Account { - public boolean autoCreate = false; - public boolean EXPERIMENTAL_RealPassword = false; - public String[] defaultPermissions = {}; - public String playerEmail = "grasscutter.io"; - public int maxPlayer = -1; + public final boolean autoCreate = false; + public final boolean EXPERIMENTAL_RealPassword = false; + public final String[] defaultPermissions = {}; + public final String playerEmail = "grasscutter.io"; + public final int maxPlayer = -1; } /* Server options. */ public static class HTTP { /* This starts the HTTP server before the game server. */ - public boolean startImmediately = false; + public final boolean startImmediately = false; - public String bindAddress = "0.0.0.0"; - public int bindPort = 443; + public final String bindAddress = "0.0.0.0"; + public final int bindPort = 443; /* This is the address used in URLs. */ - public String accessAddress = "127.0.0.1"; + public final String accessAddress = "127.0.0.1"; /* This is the port used in URLs. */ - public int accessPort = 0; + public final int accessPort = 0; - public Encryption encryption = new Encryption(); - public Policies policies = new Policies(); - public Files files = new Files(); + public final Encryption encryption = new Encryption(); + public final Policies policies = new Policies(); + public final Files files = new Files(); } public static class Game { - public String bindAddress = "0.0.0.0"; - public int bindPort = 22102; + public final String bindAddress = "0.0.0.0"; + public final int bindPort = 22102; /* This is the address used in the default region. */ - public String accessAddress = "127.0.0.1"; + public final String accessAddress = "127.0.0.1"; /* This is the port used in the default region. */ - public int accessPort = 0; + public final int accessPort = 0; /* Enabling this will generate a unique packet encryption key for each player. */ - public boolean useUniquePacketKey = true; + public final boolean useUniquePacketKey = true; /* Entities within a certain range will be loaded for the player */ - public int loadEntitiesForPlayerRange = 300; + public final int loadEntitiesForPlayerRange = 300; /* Start in 'unstable-quests', Lua scripts will be enabled by default. */ - public boolean enableScriptInBigWorld = true; + public final boolean enableScriptInBigWorld = true; public boolean enableConsole = true; /* Kcp internal work interval (milliseconds) */ - public int kcpInterval = 20; + public final int kcpInterval = 20; /* Controls whether packets should be logged in console or not */ public ServerDebugMode logPackets = ServerDebugMode.NONE; /* Show packet payload in console or no (in any case the payload is shown in encrypted view) */ @@ -190,13 +190,13 @@ public class ConfigContainer { /* Show annoying loop packets or no */ public boolean isShowLoopPackets = false; - public boolean cacheSceneEntitiesEveryRun = false; + public final boolean cacheSceneEntitiesEveryRun = false; - public GameOptions gameOptions = new GameOptions(); - public JoinOptions joinOptions = new JoinOptions(); - public ConsoleAccount serverAccount = new ConsoleAccount(); + public final GameOptions gameOptions = new GameOptions(); + public final JoinOptions joinOptions = new JoinOptions(); + public final ConsoleAccount serverAccount = new ConsoleAccount(); - public VisionOptions[] visionOptions = new VisionOptions[] { + public final VisionOptions[] visionOptions = new VisionOptions[] { new VisionOptions("VISION_LEVEL_NORMAL" , 80 , 20), new VisionOptions("VISION_LEVEL_LITTLE_REMOTE" , 16 , 40), new VisionOptions("VISION_LEVEL_REMOTE" , 1000 , 250), @@ -210,17 +210,17 @@ public class ConfigContainer { public static class Dispatch { /* An array of servers. */ - public List regions = List.of(); + public final List regions = List.of(); /* The URL used to make HTTP requests to the dispatch server. */ - public String dispatchUrl = "ws://127.0.0.1:1111"; + public final String dispatchUrl = "ws://127.0.0.1:1111"; /* A unique key used for encryption. */ - public byte[] encryptionKey = Crypto.createSessionKey(32); + public final byte[] encryptionKey = Crypto.createSessionKey(32); /* A unique key used for authentication. */ - public String dispatchKey = Utils.base64Encode( + public final String dispatchKey = Utils.base64Encode( Crypto.createSessionKey(32)); - public String defaultName = "Grasscutter"; + public final String defaultName = "Grasscutter"; /* Controls whether http requests should be logged in console or not */ public ServerDebugMode logRequests = ServerDebugMode.NONE; @@ -230,127 +230,127 @@ public class ConfigContainer { * (see StartupArguments.enableDebug) */ public static class DebugMode { /* Log level of the main server code (works only with -debug arg) */ - public Level serverLoggerLevel = Level.DEBUG; + public final Level serverLoggerLevel = Level.DEBUG; /* Log level of the third-party services (works only with -debug arg): javalin, quartz, reflections, jetty, mongodb.driver */ - public Level servicesLoggersLevel = Level.INFO; + public final Level servicesLoggersLevel = Level.INFO; /* Controls whether packets should be logged in console or not */ - public ServerDebugMode logPackets = ServerDebugMode.ALL; + public final ServerDebugMode logPackets = ServerDebugMode.ALL; /* Show packet payload in console or no (in any case the payload is shown in encrypted view) */ - public boolean isShowPacketPayload = false; + public final boolean isShowPacketPayload = false; /* Show annoying loop packets or no */ - public boolean isShowLoopPackets = false; + public final boolean isShowLoopPackets = false; /* Controls whether http requests should be logged in console or not */ - public ServerDebugMode logRequests = ServerDebugMode.ALL; + public final ServerDebugMode logRequests = ServerDebugMode.ALL; } public static class Encryption { public boolean useEncryption = true; /* Should 'https' be appended to URLs? */ public boolean useInRouting = true; - public String keystore = "./keystore.p12"; - public String keystorePassword = "123456"; + public final String keystore = "./keystore.p12"; + public final String keystorePassword = "123456"; } public static class Policies { - public Policies.CORS cors = new Policies.CORS(); + public final Policies.CORS cors = new Policies.CORS(); public static class CORS { - public boolean enabled = true; - public String[] allowedOrigins = new String[]{"*"}; + public final boolean enabled = true; + public final String[] allowedOrigins = new String[]{"*"}; } } public static class GameOptions { - public InventoryLimits inventoryLimits = new InventoryLimits(); - public AvatarLimits avatarLimits = new AvatarLimits(); - public int sceneEntityLimit = 1000; // Unenforced. TODO: Implement. + public final InventoryLimits inventoryLimits = new InventoryLimits(); + public final AvatarLimits avatarLimits = new AvatarLimits(); + public final int sceneEntityLimit = 1000; // Unenforced. TODO: Implement. - public boolean watchGachaConfig = false; - public boolean enableShopItems = true; - public boolean staminaUsage = true; - public boolean energyUsage = true; - public boolean fishhookTeleport = true; - public boolean trialCostumes = false; + public final boolean watchGachaConfig = false; + public final boolean enableShopItems = true; + public final boolean staminaUsage = true; + public final boolean energyUsage = true; + public final boolean fishhookTeleport = true; + public final boolean trialCostumes = false; @SerializedName(value = "questing", alternate = "questOptions") - public Questing questing = new Questing(); - public ResinOptions resinOptions = new ResinOptions(); - public Rates rates = new Rates(); + public final Questing questing = new Questing(); + public final ResinOptions resinOptions = new ResinOptions(); + public final Rates rates = new Rates(); - public HandbookOptions handbook = new HandbookOptions(); + public final HandbookOptions handbook = new HandbookOptions(); public static class InventoryLimits { - public int weapons = 2000; - public int relics = 2000; - public int materials = 2000; - public int furniture = 2000; - public int all = 30000; + public final int weapons = 2000; + public final int relics = 2000; + public final int materials = 2000; + public final int furniture = 2000; + public final int all = 30000; } public static class AvatarLimits { - public int singlePlayerTeam = 4; - public int multiplayerTeam = 4; + public final int singlePlayerTeam = 4; + public final int multiplayerTeam = 4; } public static class Rates { - public float adventureExp = 1.0f; + public final float adventureExp = 1.0f; public float mora = 1.0f; public float leyLines = 1.0f; } public static class ResinOptions { - public boolean resinUsage = false; - public int cap = 160; - public int rechargeTime = 480; + public final boolean resinUsage = false; + public final int cap = 160; + public final int rechargeTime = 480; } public static class Questing { /* Should questing behavior be used? */ - public boolean enabled = true; + public final boolean enabled = true; } public static class HandbookOptions { - public boolean enable = false; - public boolean allowCommands = true; + public final boolean enable = false; + public final boolean allowCommands = true; - public Limits limits = new Limits(); - public Server server = new Server(); + public final Limits limits = new Limits(); + public final Server server = new Server(); public static class Limits { /* Are rate limits checked? */ - public boolean enabled = false; + public final boolean enabled = false; /* The time for limits to expire. */ - public int interval = 3; + public final int interval = 3; /* The maximum amount of normal requests. */ - public int maxRequests = 10; + public final int maxRequests = 10; /* The maximum amount of entities to be spawned in one request. */ - public int maxEntities = 25; + public final int maxEntities = 25; } public static class Server { /* Are the server settings sent to the handbook? */ - public boolean enforced = false; + public final boolean enforced = false; /* The default server address for the handbook's authentication. */ - public String address = "127.0.0.1"; + public final String address = "127.0.0.1"; /* The default server port for the handbook's authentication. */ - public int port = 443; + public final int port = 443; /* Should the defaults be enforced? */ - public boolean canChange = true; + public final boolean canChange = true; } } } public static class VisionOptions { - public String name; - public int visionRange; - public int gridWidth; + public final String name; + public final int visionRange; + public final int gridWidth; public VisionOptions(String name, int visionRange, int gridWidth) { this.name = name; @@ -360,21 +360,21 @@ public class ConfigContainer { } public static class JoinOptions { - public int[] welcomeEmotes = {2007, 1002, 4010}; - public String welcomeMessage = "Welcome to a Grasscutter server."; - public JoinOptions.Mail welcomeMail = new JoinOptions.Mail(); + public final int[] welcomeEmotes = {2007, 1002, 4010}; + public final String welcomeMessage = "Welcome to a Grasscutter server."; + public final JoinOptions.Mail welcomeMail = new JoinOptions.Mail(); public static class Mail { - public String title = "Welcome to Grasscutter!"; - public String content = """ + public final String title = "Welcome to Grasscutter!"; + public final String content = """ Hi there!\r First of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r \r Check out our:\r """; - public String sender = "Lawnmower"; - public emu.grasscutter.game.mail.Mail.MailItem[] items = { + public final String sender = "Lawnmower"; + public final emu.grasscutter.game.mail.Mail.MailItem[] items = { new emu.grasscutter.game.mail.Mail.MailItem(13509, 1, 1), new emu.grasscutter.game.mail.Mail.MailItem(201, 99999, 1) }; @@ -382,18 +382,18 @@ public class ConfigContainer { } public static class ConsoleAccount { - public int avatarId = 10000007; - public int nameCardId = 210001; - public int adventureRank = 1; - public int worldLevel = 0; + public final int avatarId = 10000007; + public final int nameCardId = 210001; + public final int adventureRank = 1; + public final int worldLevel = 0; - public String nickName = "Server"; - public String signature = "Welcome to Grasscutter!"; + public final String nickName = "Server"; + public final String signature = "Welcome to Grasscutter!"; } public static class Files { - public String indexFile = "./index.html"; - public String errorFile = "./404.html"; + public final String indexFile = "./index.html"; + public final String errorFile = "./404.html"; } /* Objects. */ diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java index 9b519ab9c..9087b94cc 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java @@ -4,9 +4,9 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import java.util.*; public class AbilityModifierEntry { - public List onModifierAdded; - public List onThinkInterval; - public List onRemoved; + public final List onModifierAdded; + public final List onThinkInterval; + public final List onRemoved; private final String name; // Custom value public AbilityModifierEntry(String name) { diff --git a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java index 99dc12433..5a035f632 100644 --- a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java +++ b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java @@ -92,7 +92,7 @@ public class DynamicFloat { } public static class StackOp { - public Op op; + public final Op op; public float fValue; public String sValue; diff --git a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TowerResult.java b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TowerResult.java index b42e041ec..1c87e908f 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TowerResult.java +++ b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TowerResult.java @@ -9,11 +9,11 @@ import emu.grasscutter.net.proto.TowerLevelEndNotifyOuterClass.TowerLevelEndNoti import emu.grasscutter.net.proto.TowerLevelEndNotifyOuterClass.TowerLevelEndNotify.ContinueStateType; public class TowerResult extends BaseDungeonResult { - WorldChallenge challenge; - boolean canJump; - boolean hasNextLevel; - int nextFloorId; - int currentStars; + final WorldChallenge challenge; + final boolean canJump; + final boolean hasNextLevel; + final int nextFloorId; + final int currentStars; public TowerResult( DungeonData dungeonData, diff --git a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TrialAvatarDungeonResult.java b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TrialAvatarDungeonResult.java index dd20fec49..c344d4d90 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TrialAvatarDungeonResult.java +++ b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/TrialAvatarDungeonResult.java @@ -6,7 +6,7 @@ import emu.grasscutter.net.proto.DungeonSettleNotifyOuterClass; import emu.grasscutter.net.proto.TrialAvatarFirstPassDungeonNotifyOuterClass.TrialAvatarFirstPassDungeonNotify; public class TrialAvatarDungeonResult extends BaseDungeonResult { - int trialCharacterIndexId; + final int trialCharacterIndexId; public TrialAvatarDungeonResult( DungeonData dungeonData, DungeonEndStats dungeonStats, int trialCharacterIndexId) { diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index 89161b950..9f9404091 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -17,14 +17,14 @@ import org.bson.types.ObjectId; public final class Mail { @Id private ObjectId id; @Indexed private int ownerUid; - public MailContent mailContent; - public List itemList; - public long sendTime; + public final MailContent mailContent; + public final List itemList; + public final long sendTime; public long expireTime; public int importance; public boolean isRead; public boolean isAttachmentGot; - public int stateValue; + public final int stateValue; @Transient private boolean shouldDelete; public Mail() { @@ -122,9 +122,9 @@ public final class Mail { @Entity public static class MailItem { - public int itemId; - public int itemCount; - public int itemLevel; + public final int itemId; + public final int itemCount; + public final int itemLevel; public MailItem() { this.itemId = 11101; diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseAction/UseItemParams.java b/src/main/java/emu/grasscutter/game/props/ItemUseAction/UseItemParams.java index d5f946735..da319d3a9 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseAction/UseItemParams.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseAction/UseItemParams.java @@ -6,8 +6,8 @@ import emu.grasscutter.game.props.ItemUseTarget; public class UseItemParams { // Don't want to change 40 method signatures when this gets extended! - public Player player; - public ItemUseTarget itemUseTarget; + public final Player player; + public final ItemUseTarget itemUseTarget; public Avatar targetAvatar = null; public int count = 1; public int optionId = 0; diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index bc65ae184..da9a9436b 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -7,7 +7,7 @@ import java.io.*; public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab - public boolean shouldEncrypt = true; + public final boolean shouldEncrypt = true; private int opcode; private boolean shouldBuildHeader = false; private byte[] header; diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 8ca612061..b085735c8 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -20,7 +20,7 @@ public final class PluginManager { * A 'breaking change' is something which changes the existing logic of the API. */ @SuppressWarnings("FieldCanBeLocal") - public static int API_VERSION = 2; + public static final int API_VERSION = 2; /* All loaded plugins. */ private final Map plugins = new LinkedHashMap<>(); diff --git a/src/main/java/emu/grasscutter/server/http/objects/ComboTokenResJson.java b/src/main/java/emu/grasscutter/server/http/objects/ComboTokenResJson.java index c229a1e19..279f1ab37 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/ComboTokenResJson.java +++ b/src/main/java/emu/grasscutter/server/http/objects/ComboTokenResJson.java @@ -3,7 +3,7 @@ package emu.grasscutter.server.http.objects; public class ComboTokenResJson { public String message; public int retcode; - public LoginData data = new LoginData(); + public final LoginData data = new LoginData(); public static class LoginData { public int account_type = 1; diff --git a/src/main/java/emu/grasscutter/server/http/objects/LoginResultJson.java b/src/main/java/emu/grasscutter/server/http/objects/LoginResultJson.java index 0557c9c05..87d63dafb 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/LoginResultJson.java +++ b/src/main/java/emu/grasscutter/server/http/objects/LoginResultJson.java @@ -3,10 +3,10 @@ package emu.grasscutter.server.http.objects; public class LoginResultJson { public String message; public int retcode; - public VerifyData data = new VerifyData(); + public final VerifyData data = new VerifyData(); public static class VerifyData { - public VerifyAccountData account = new VerifyAccountData(); + public final VerifyAccountData account = new VerifyAccountData(); public boolean device_grant_required = false; public String realname_operation = "NONE"; public boolean realperson_required = false; diff --git a/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java b/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java index 57f574f1b..d9ac86513 100644 --- a/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java +++ b/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java @@ -14,7 +14,7 @@ import org.quartz.*; triggerName = "AnnouncementTrigger") public final class AnnouncementTask extends TaskHandler { - static Map intervalMap = new ConcurrentHashMap<>(); + static final Map intervalMap = new ConcurrentHashMap<>(); @Override public void onEnable() { diff --git a/src/main/java/emu/grasscutter/utils/Crypto.java b/src/main/java/emu/grasscutter/utils/Crypto.java index 597aa4c40..01b515b7b 100644 --- a/src/main/java/emu/grasscutter/utils/Crypto.java +++ b/src/main/java/emu/grasscutter/utils/Crypto.java @@ -19,12 +19,12 @@ public final class Crypto { public static byte[] DISPATCH_SEED; public static byte[] ENCRYPT_KEY; - public static long ENCRYPT_SEED = Long.parseUnsignedLong("11468049314633205968"); + public static final long ENCRYPT_SEED = Long.parseUnsignedLong("11468049314633205968"); public static byte[] ENCRYPT_SEED_BUFFER = new byte[0]; public static PrivateKey CUR_SIGNING_KEY; - public static Map EncryptionKeys = new HashMap<>(); + public static final Map EncryptionKeys = new HashMap<>(); public static void loadKeys() { DISPATCH_KEY = FileUtils.readResource("/keys/dispatchKey.bin"); diff --git a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java index 38dee3c59..1127ef9a4 100644 --- a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java +++ b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java @@ -4,7 +4,8 @@ import java.util.*; public class KahnsSort { public static class Node { - int source, dest; // Dest is a value, and source too + final int source; + final int dest; // Dest is a value, and source too public Node(int source, int dest) { this.source = source; @@ -13,10 +14,10 @@ public class KahnsSort { } public static class Graph { - Map> mainList; - Map degreeList; + final Map> mainList; + final Map degreeList; - List nodeList; + final List nodeList; public Graph(List nodes, List nodeList) { mainList = new HashMap<>(); From ca6ddfd2ccba456f4a55106194332fa390f70e39 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:03:50 -0300 Subject: [PATCH 08/59] refactor: replace protected with private for final class --- src/main/java/emu/grasscutter/data/ResourceLoader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 734d51d1a..5db5d09b8 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -169,8 +169,8 @@ public final class ResourceLoader { } @SuppressWarnings("rawtypes") - protected static void loadFromResource( - Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { + private static void loadFromResource( + Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { val simpleName = c.getSimpleName(); if (doReload || !loadedResources.contains(simpleName)) { for (String name : type.name()) { @@ -181,7 +181,7 @@ public final class ResourceLoader { } @SuppressWarnings({"rawtypes", "unchecked"}) - protected static void loadFromResource(Class c, Path filename, Int2ObjectMap map) + private static void loadFromResource(Class c, Path filename, Int2ObjectMap map) throws Exception { val results = switch (FileUtils.getFileExtension(filename)) { @@ -200,7 +200,7 @@ public final class ResourceLoader { } @SuppressWarnings({"rawtypes", "unchecked"}) - protected static void loadFromResource(Class c, String fileName, Int2ObjectMap map) + private static void loadFromResource(Class c, String fileName, Int2ObjectMap map) throws Exception { JsonUtils.loadToList(getResourcePath("ExcelBinOutput/" + fileName), c) .forEach( From 0161b4d73dcd720448d57a6c77b47bfbdcde06f6 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:04:26 -0300 Subject: [PATCH 09/59] refactor: replace protected with private for final class --- .../emu/grasscutter/utils/objects/ServerLogEventAppender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java index 05a89f170..efb5775e7 100644 --- a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java +++ b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java @@ -7,7 +7,7 @@ import emu.grasscutter.server.event.internal.ServerLogEvent; import java.nio.charset.StandardCharsets; public final class ServerLogEventAppender extends AppenderBase { - protected Encoder encoder; + private Encoder encoder; @Override protected void append(E event) { From 427a1cf5f51e4ceed3b2f30b41a8c88d38658383 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:06:12 -0300 Subject: [PATCH 10/59] fix: variable is assigned to itself --- .../java/emu/grasscutter/data/common/OpenCondData.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/common/OpenCondData.java b/src/main/java/emu/grasscutter/data/common/OpenCondData.java index 51581f13e..b379106a8 100644 --- a/src/main/java/emu/grasscutter/data/common/OpenCondData.java +++ b/src/main/java/emu/grasscutter/data/common/OpenCondData.java @@ -10,15 +10,15 @@ public class OpenCondData { return condType; } - public void setCondType(String condType) { - condType = condType; + public void setCondType(String cType) { + condType = cType; } public List getParamList() { return paramList; } - public void setParamList(List paramList) { - paramList = paramList; + public void setParamList(List pList) { + paramList = pList; } } From 9c946e9d2e62eda262dae630dda5746f0f039539 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:07:54 -0300 Subject: [PATCH 11/59] chore: remove unused import --- src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java | 1 - src/main/java/emu/grasscutter/scripts/data/SceneGroup.java | 2 +- .../server/packet/send/PacketMonsterSummonTagNotify.java | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java index fdfc92378..cefca5e81 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java @@ -8,7 +8,6 @@ import emu.grasscutter.game.dungeons.handlers.DungeonBaseHandler; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.SceneType; import emu.grasscutter.game.world.*; -import emu.grasscutter.net.packet.*; import emu.grasscutter.server.game.*; import emu.grasscutter.server.packet.send.PacketDungeonEntryInfoRsp; import it.unimi.dsi.fastutil.ints.*; diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index ce84e6fa3..5c9a93dba 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -3,7 +3,7 @@ package emu.grasscutter.scripts.data; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.Position; import emu.grasscutter.scripts.ScriptLoader; -import java.io.*; + import java.util.*; import java.util.stream.Collectors; import javax.script.*; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketMonsterSummonTagNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketMonsterSummonTagNotify.java index fb0ffe46f..3eb03886c 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketMonsterSummonTagNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketMonsterSummonTagNotify.java @@ -3,7 +3,6 @@ package emu.grasscutter.server.packet.send; import emu.grasscutter.game.entity.EntityMonster; import emu.grasscutter.net.packet.*; import emu.grasscutter.net.proto.MonsterSummonTagNotifyOuterClass.MonsterSummonTagNotify; -import java.util.*; public class PacketMonsterSummonTagNotify extends BasePacket { From 8c35c89bf5ca8e3d87cf1358a2b89521671df4fc Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:09:45 -0300 Subject: [PATCH 12/59] refactor: replace Collections.sort with list.sort Collections.sort is just a wrapper, so it is better to use an instance method directly. --- src/main/java/emu/grasscutter/game/mail/MailHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index 51ca53698..ab68b6bc6 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -65,7 +65,7 @@ public class MailHandler extends BasePlayerManager { public void deleteMail(List mailList) { List sortedMailList = new ArrayList<>(); sortedMailList.addAll(mailList); - Collections.sort(sortedMailList, Collections.reverseOrder()); + sortedMailList.sort(Collections.reverseOrder()); List deleted = new ArrayList<>(); From 870085fc9136764d01278819212e18b1d900300b Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:10:48 -0300 Subject: [PATCH 13/59] refactor: replace lambda with method reference --- .../java/emu/grasscutter/data/excels/RewardPreviewData.java | 2 +- .../game/props/ItemUseAction/ItemUseGainAvatar.java | 3 ++- .../java/emu/grasscutter/game/systems/InventorySystem.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java b/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java index dad51e911..caba57447 100644 --- a/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java +++ b/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java @@ -25,7 +25,7 @@ public class RewardPreviewData extends GameResource { Arrays.stream(this.previewItems) .filter(d -> d.getId() > 0 && d.getCount() != null && !d.getCount().isEmpty()) .map(ItemParamStringData::toItemParamData) - .toArray(size -> new ItemParamData[size]); + .toArray(ItemParamData[]::new); } else { this.previewItemsArray = new ItemParamData[0]; } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainAvatar.java b/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainAvatar.java index 1dae2822d..add08558d 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainAvatar.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseGainAvatar.java @@ -1,5 +1,6 @@ package emu.grasscutter.game.props.ItemUseAction; +import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData; import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.game.props.ItemUseOp; import emu.grasscutter.game.systems.InventorySystem; @@ -43,7 +44,7 @@ public class ItemUseGainAvatar extends ItemUseInt { int itemId = Optional.ofNullable(params.player.getAvatars().getAvatarById(this.i)) .map(Avatar::getSkillDepot) - .map(depot -> depot.getTalentCostItemId()) + .map(AvatarSkillDepotData::getTalentCostItemId) .orElse((this.i % 1000) + 100); return params.player.getInventory().addItem(itemId); } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 568872e23..f84ae7078 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -58,7 +58,7 @@ public class InventorySystem extends BaseGameSystem { } else { avatarId = Optional.ofNullable(GameData.getItemDataMap().get(id)) - .map(itemData -> itemData.getItemUseActions()) + .map(ItemData::getItemUseActions) .flatMap( actions -> actions.stream() From 3119e0fffc3b071b82500f88aa0d9a3f58496503 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:11:58 -0300 Subject: [PATCH 14/59] refactor: replace lambda with method reference --- src/main/java/emu/grasscutter/data/GameData.java | 6 +++--- .../data/excels/avatar/AvatarSkillDepotData.java | 2 +- .../trialavatar/TrialAvatarActivityChallengeTrigger.java | 2 +- .../emu/grasscutter/game/battlepass/BattlePassManager.java | 2 +- src/main/java/emu/grasscutter/game/inventory/Inventory.java | 5 +++-- .../emu/grasscutter/game/managers/blossom/BlossomType.java | 2 +- src/main/java/emu/grasscutter/game/player/Player.java | 5 +++-- src/main/java/emu/grasscutter/game/player/TeamManager.java | 4 ++-- src/main/java/emu/grasscutter/game/shop/ShopInfo.java | 2 +- .../packet/send/PacketAvatarExpeditionAllDataRsp.java | 2 +- .../packet/send/PacketAvatarExpeditionDataNotify.java | 2 +- src/main/java/emu/grasscutter/tools/Tools.java | 4 ++-- src/main/java/emu/grasscutter/utils/lang/Language.java | 4 ++-- 13 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index 1a8597694..f6d9a48d7 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -630,15 +630,15 @@ public final class GameData { // Non-nullable value getters public static int getAvatarLevelExpRequired(int level) { - return Optional.ofNullable(avatarLevelDataMap.get(level)).map(d -> d.getExp()).orElse(0); + return Optional.ofNullable(avatarLevelDataMap.get(level)).map(AvatarLevelData::getExp).orElse(0); } public static int getAvatarFetterLevelExpRequired(int level) { - return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(d -> d.getExp()).orElse(0); + return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(AvatarFetterLevelData::getExp).orElse(0); } public static int getRelicExpRequired(int rankLevel, int level) { - return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(d -> d.getExp()).orElse(0); + return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(ReliquaryLevelData::getExp).orElse(0); } // Generic getter diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java index 1e055ec2e..474dca103 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java @@ -67,7 +67,7 @@ public class AvatarSkillDepotData extends GameResource { Optional.ofNullable(this.talents) .map(talents -> talents.get(0)) .map(i -> GameData.getAvatarTalentDataMap().get((int) i)) - .map(talentData -> talentData.getMainCostItemId()) + .map(AvatarTalentData::getMainCostItemId) .ifPresent(itemId -> this.talentCostItemId = itemId); } diff --git a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityChallengeTrigger.java b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityChallengeTrigger.java index 1778f4328..b9e7e8c43 100644 --- a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityChallengeTrigger.java +++ b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityChallengeTrigger.java @@ -18,7 +18,7 @@ public class TrialAvatarActivityChallengeTrigger extends ActivityWatcher { if (paramList.isEmpty()) return false; val paramCond = Stream.of(paramList.get(0).split(",")).toList(); - return Stream.of(param).allMatch(x -> paramCond.contains(x)); + return Stream.of(param).allMatch(paramCond::contains); } @Override diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java index f72c00e64..6b2ca8a05 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java @@ -103,7 +103,7 @@ public class BattlePassManager extends BasePlayerDataManager { // Will return a new empty mission if the mission id is not found public BattlePassMission loadMissionById(int id) { - return getMissions().computeIfAbsent(id, i -> new BattlePassMission(i)); + return getMissions().computeIfAbsent(id, BattlePassMission::new); } public boolean hasMission(int id) { diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 0a5b99999..67dcd32ba 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -8,6 +8,7 @@ import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.excels.ItemData; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.avatar.*; +import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.player.*; import emu.grasscutter.game.props.*; import emu.grasscutter.game.props.ItemUseAction.UseItemParams; @@ -370,7 +371,7 @@ public class Inventory extends BasePlayerManager implements Iterable { switch (itemId) { case 101 -> // Character exp this.player.getTeamManager().getActiveTeam().stream() - .map(e -> e.getAvatar()) + .map(EntityAvatar::getAvatar) .forEach( avatar -> this.player @@ -381,7 +382,7 @@ public class Inventory extends BasePlayerManager implements Iterable { this.player.addExpDirectly(count); case 105 -> // Companionship exp this.player.getTeamManager().getActiveTeam().stream() - .map(e -> e.getAvatar()) + .map(EntityAvatar::getAvatar) .forEach( avatar -> this.player diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java index 925e05b0d..069e469c5 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java @@ -11,7 +11,7 @@ public enum BlossomType { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>( - Stream.of(values()).collect(Collectors.toMap(x -> x.getGadgetId(), x -> x))); + Stream.of(values()).collect(Collectors.toMap(BlossomType::getGadgetId, x -> x))); @Getter private final int gadgetId; @Getter private final int circleCampId; @Getter private final int blossomChestId; diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index c6735d82d..83cd2447d 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -4,6 +4,7 @@ import dev.morphia.annotations.*; import emu.grasscutter.*; import emu.grasscutter.data.GameData; import emu.grasscutter.data.excels.PlayerLevelData; +import emu.grasscutter.data.excels.scene.SceneTagData; import emu.grasscutter.data.excels.world.WeatherData; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.*; @@ -596,7 +597,7 @@ public class Player implements PlayerHook, FieldFetch { */ private void applyStartingSceneTags() { GameData.getSceneTagDataMap().values().stream() - .filter(sceneTag -> sceneTag.isDefaultValid()) + .filter(SceneTagData::isDefaultValid) .forEach(sceneTag -> { if (this.getSceneTags().get(sceneTag.getSceneId()) == null) { this.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>()); @@ -1551,7 +1552,7 @@ public class Player implements PlayerHook, FieldFetch { } public void unfreezeUnlockedScenePoints() { - unlockedScenePoints.keySet().forEach(sceneId -> unfreezeUnlockedScenePoints(sceneId)); + unlockedScenePoints.keySet().forEach(this::unfreezeUnlockedScenePoints); } public int getLegendaryKey() { diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index 0e19dfd90..d808fbf44 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -257,7 +257,7 @@ public final class TeamManager extends BasePlayerDataManager { } // Convert avatars into a collection of avatar IDs, then add - team.getAvatars().addAll(avatars.stream().map(a -> a.getAvatarId()).toList()); + team.getAvatars().addAll(avatars.stream().map(Avatar::getAvatarId).toList()); // Update team if (this.getPlayer().isInMultiplayer()) { @@ -332,7 +332,7 @@ public final class TeamManager extends BasePlayerDataManager { // Dual element resonances elementCounts.object2IntEntrySet().stream() .filter(e -> e.getIntValue() >= 2) - .map(e -> e.getKey()) + .map(Map.Entry::getKey) .filter(elementType -> elementType.getTeamResonanceId() != 0) .forEach( elementType -> { diff --git a/src/main/java/emu/grasscutter/game/shop/ShopInfo.java b/src/main/java/emu/grasscutter/game/shop/ShopInfo.java index 76119984e..f2418c4c3 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopInfo.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopInfo.java @@ -71,7 +71,7 @@ public class ShopInfo { } public void removeVirtualCosts() { - if (this.costItemList != null) this.costItemList.removeIf(item -> evaluateVirtualCost(item)); + if (this.costItemList != null) this.costItemList.removeIf(this::evaluateVirtualCost); } public enum ShopRefreshType { diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionAllDataRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionAllDataRsp.java index 1ada85f16..b71c510a7 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionAllDataRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionAllDataRsp.java @@ -22,7 +22,7 @@ public class PacketAvatarExpeditionAllDataRsp extends BasePacket { .setExpeditionCountLimit(expeditionCountLimit) .putAllExpeditionInfoMap( expeditionInfo.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toProto()))) + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toProto()))) .build()); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionDataNotify.java index 5067094ad..d2718f31d 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAvatarExpeditionDataNotify.java @@ -14,7 +14,7 @@ public class PacketAvatarExpeditionDataNotify extends BasePacket { AvatarExpeditionDataNotify.newBuilder() .putAllExpeditionInfoMap( expeditionInfo.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().toProto()))) + .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toProto()))) .build()); } } diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index ea88a5296..ab382e59a 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -54,7 +54,7 @@ public final class Tools { GameData.getMainQuestDataMap().int2ObjectEntrySet().stream() .collect( Collectors.toMap( - e -> e.getIntKey(), e -> (int) e.getValue().getTitleTextMapHash()))); + Int2ObjectMap.Entry::getIntKey, e -> (int) e.getValue().getTitleTextMapHash()))); // val questDescs = new // Int2IntRBTreeMap(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash()))); @@ -99,7 +99,7 @@ public final class Tools { newTranslatedLine( template, LongStream.of(hashes) - .mapToObj(hash -> getTextMapKey(hash)) + .mapToObj(Language::getTextMapKey) .toArray(TextStrings[]::new)); } }; diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 5cfd173c2..df141b7b8 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -253,11 +253,11 @@ public final class Language { TextStrings.LIST_LANGUAGES.parallelStream() .collect( Collectors.toConcurrentMap( - s -> TextStrings.MAP_LANGUAGES.getInt(s), + TextStrings.MAP_LANGUAGES::getInt, s -> loadTextMapFile(s, nameHashes))); List> languageMaps = IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(i -> mapLanguageMaps.get(i)) + .mapToObj(mapLanguageMaps::get) .collect(Collectors.toList()); Map canonicalTextStrings = new HashMap<>(); From c7119aae68994a67f9b70e601e9bd99c984e1e07 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:13:18 -0300 Subject: [PATCH 15/59] refactor: simplify map operations we can use computeIfAbsent here --- .../java/emu/grasscutter/game/managers/SotSManager.java | 6 +----- src/main/java/emu/grasscutter/game/player/Player.java | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/SotSManager.java b/src/main/java/emu/grasscutter/game/managers/SotSManager.java index 6427de185..eeafe1a09 100644 --- a/src/main/java/emu/grasscutter/game/managers/SotSManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SotSManager.java @@ -218,11 +218,7 @@ public class SotSManager extends BasePlayerManager { public CityInfoData getCityInfo(int cityId) { if (player.getCityInfoData() == null) player.setCityInfoData(new HashMap<>()); - var cityInfo = player.getCityInfoData().get(cityId); - if (cityInfo == null) { - cityInfo = new CityInfoData(cityId); - player.getCityInfoData().put(cityId, cityInfo); - } + var cityInfo = player.getCityInfoData().computeIfAbsent(cityId, CityInfoData::new); return cityInfo; } diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index 83cd2447d..c8c65aded 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -599,9 +599,7 @@ public class Player implements PlayerHook, FieldFetch { GameData.getSceneTagDataMap().values().stream() .filter(SceneTagData::isDefaultValid) .forEach(sceneTag -> { - if (this.getSceneTags().get(sceneTag.getSceneId()) == null) { - this.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>()); - } + this.getSceneTags().computeIfAbsent(sceneTag.getSceneId(), k -> new HashSet<>()); this.getSceneTags().get(sceneTag.getSceneId()).add(sceneTag.getId()); }); } From fcd409320d8ddfd46d1ad449ee370a80a6443a8f Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:15:22 -0300 Subject: [PATCH 16/59] refactor: replace statement with expression lambda --- .../command/commands/AchievementCommand.java | 26 +++++++------- .../command/commands/SetSceneTagCommand.java | 4 +-- .../emu/grasscutter/data/ResourceLoader.java | 32 ++++++++--------- .../game/achievement/Achievements.java | 22 +++++------- .../emu/grasscutter/game/avatar/Avatar.java | 10 +++--- .../game/combine/CombineManger.java | 4 +-- .../emu/grasscutter/game/home/GameHome.java | 30 ++++++---------- .../game/home/HomeModuleManager.java | 36 +++++++++---------- .../grasscutter/game/home/HomeSceneItem.java | 12 +++---- .../game/managers/energy/EnergyManager.java | 8 ++--- .../emu/grasscutter/game/props/ItemUseOp.java | 4 +-- .../grasscutter/game/props/ItemUseTarget.java | 4 +-- .../game/props/ServerBuffType.java | 4 +-- .../emu/grasscutter/game/quest/GameQuest.java | 4 +-- .../emu/grasscutter/scripts/ScriptLib.java | 4 +-- .../packet/recv/HandlerHomeKickPlayerReq.java | 12 +++---- .../PacketActivityScheduleInfoNotify.java | 18 +++++----- .../PacketBattlePassMissionUpdateNotify.java | 4 +-- .../send/PacketCodexDataFullNotify.java | 8 ++--- .../packet/send/PacketCreateVehicleRsp.java | 18 +++++----- .../packet/send/PacketPlayerDataNotify.java | 6 ++-- .../java/emu/grasscutter/tools/Tools.java | 24 ++++++------- 22 files changed, 118 insertions(+), 176 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index 7510895e5..c78425c90 100644 --- a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java @@ -136,20 +136,18 @@ public final class AchievementCommand implements CommandHandler { parseInt(args.remove(0)) .ifPresentOrElse( - integer -> { - parseInt(args.remove(0)) - .ifPresentOrElse( - progress -> { - var ret = achievements.progress(integer, progress); - switch (ret.getRet()) { - case SUCCESS -> sendSuccessMessage( - sender, "progress", targetPlayer.getNickname(), integer, progress); - case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( - sender, ret.getRet().getKey()); - } - }, - () -> this.sendUsageMessage(sender)); - }, + integer -> parseInt(args.remove(0)) + .ifPresentOrElse( + progress -> { + var ret = achievements.progress(integer, progress); + switch (ret.getRet()) { + case SUCCESS -> sendSuccessMessage( + sender, "progress", targetPlayer.getNickname(), integer, progress); + case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( + sender, ret.getRet().getKey()); + } + }, + () -> this.sendUsageMessage(sender)), () -> this.sendUsageMessage(sender)); } } diff --git a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java index fb743f0f8..d16c97213 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java @@ -95,9 +95,7 @@ public final class SetSceneTagCommand implements CommandHandler { // Only remove for big world as some other scenes only have defaults .filter(sceneTag -> sceneTag.getSceneId() == 3) .forEach( - sceneTag -> { - targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId()); - }); + sceneTag -> targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); this.setSceneTags(targetPlayer); } diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 5db5d09b8..13be4c4a2 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,25 +140,23 @@ public final class ResourceLoader { getResourceDefClassesPrioritySets() .forEach( - classes -> { - classes.stream() - .parallel() - .unordered() - .forEach( - c -> { - val type = c.getAnnotation(ResourceType.class); - if (type == null) return; + classes -> classes.stream() + .parallel() + .unordered() + .forEach( + c -> { + val type = c.getAnnotation(ResourceType.class); + if (type == null) return; - val map = GameData.getMapByResourceDef(c); - if (map == null) return; + val map = GameData.getMapByResourceDef(c); + if (map == null) return; - try { - loadFromResource(c, type, map, doReload); - } catch (Exception e) { - errors.add(Pair.of(Arrays.toString(type.name()), e)); - } - }); - }); + try { + loadFromResource(c, type, map, doReload); + } catch (Exception e) { + errors.add(Pair.of(Arrays.toString(type.name()), e)); + } + })); errors.forEach( pair -> Grasscutter.getLogger() diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index 929c382cb..40b180bb0 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievements.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievements.java @@ -61,11 +61,9 @@ public class Achievements { GameData.getAchievementDataMap().values().stream() .filter(AchievementData::isUsed) .forEach( - a -> { - map.put( - a.getId(), - new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0)); - }); + a -> map.put( + a.getId(), + new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); return map; } @@ -177,14 +175,12 @@ public class Achievements { return this.getAchievementList() .computeIfAbsent( achievementId, - id -> { - return new Achievement( - Status.STATUS_UNFINISHED, - id, - GameData.getAchievementDataMap().get(id.intValue()).getProgress(), - 0, - 0); - }); + id -> new Achievement( + Status.STATUS_UNFINISHED, + id, + GameData.getAchievementDataMap().get(id.intValue()).getProgress(), + 0, + 0)); } public boolean isInvalid(int achievementId) { diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index fe3b5e424..a3070c609 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -776,12 +776,10 @@ public class Avatar { Stream.of(entry.getSkillPointModifiers()) .mapToInt(SkillPointModifier::getSkillId) .forEach( - skillId -> { - this.getPlayer() - .sendPacket( - new PacketAvatarSkillMaxChargeCountNotify( - this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0))); - }); + skillId -> this.getPlayer() + .sendPacket( + new PacketAvatarSkillMaxChargeCountNotify( + this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); } } diff --git a/src/main/java/emu/grasscutter/game/combine/CombineManger.java b/src/main/java/emu/grasscutter/game/combine/CombineManger.java index 08305cae1..9fff60cf2 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineManger.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineManger.java @@ -28,9 +28,7 @@ public class CombineManger extends BaseGameSystem { try { DataLoader.loadList("ReliquaryDecompose.json", ReliquaryDecomposeEntry.class) .forEach( - entry -> { - reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems()); - }); + entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems())); Grasscutter.getLogger() .debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size()); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/home/GameHome.java b/src/main/java/emu/grasscutter/game/home/GameHome.java index 10d488aa2..fd6ce6368 100644 --- a/src/main/java/emu/grasscutter/game/home/GameHome.java +++ b/src/main/java/emu/grasscutter/game/home/GameHome.java @@ -281,12 +281,10 @@ public class GameHome { return this.finishedTalkIdMap.entrySet().stream() .map( - e -> { - return HomeAvatarTalkFinishInfo.newBuilder() - .setAvatarId(e.getKey()) - .addAllFinishTalkIdList(e.getValue()) - .build(); - }) + e -> HomeAvatarTalkFinishInfo.newBuilder() + .setAvatarId(e.getKey()) + .addAllFinishTalkIdList(e.getValue()) + .build()) .toList(); } @@ -395,13 +393,9 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> { - e.getDeployNPCList() - .forEach( - id -> { - invitedAvatars.add(id.getAvatarId()); - }); - }); + (i, e) -> e.getDeployNPCList() + .forEach( + id -> invitedAvatars.add(id.getAvatarId()))); // Check as realm 5 inside is not in defaults and will be null if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { @@ -410,13 +404,9 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> { - e.getDeployNPCList() - .forEach( - id -> { - invitedAvatars.add(id.getAvatarId()); - }); - }); + (i, e) -> e.getDeployNPCList() + .forEach( + id -> invitedAvatars.add(id.getAvatarId()))); } // Add exp to all avatars diff --git a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java index 6d824d584..9297ce1fd 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java +++ b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java @@ -93,26 +93,24 @@ public class HomeModuleManager { .map(HomeBlockItem::getDeployNPCList) .flatMap(Collection::stream) .forEach( - avatar -> { - suites.forEach( - suite -> { - var data = - SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( - avatar.getAvatarId(), suite.getSuiteId()); - if (data == null || this.home.isRewardEventFinished(data.getId())) { - return; - } + avatar -> suites.forEach( + suite -> { + var data = + SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( + avatar.getAvatarId(), suite.getSuiteId()); + if (data == null || this.home.isRewardEventFinished(data.getId())) { + return; + } - this.rewardEvents.add( - new HomeAvatarRewardEvent( - homeOwner, - data.getId(), - data.getRewardID(), - data.getAvatarID(), - data.getSuiteId(), - suite.getGuid())); - }); - }); + this.rewardEvents.add( + new HomeAvatarRewardEvent( + homeOwner, + data.getId(), + data.getRewardID(), + data.getAvatarID(), + data.getSuiteId(), + suite.getGuid())); + })); if (this.summonEvents != null) { var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList(); diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index 111dba9cf..1b0acee86 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -103,13 +103,11 @@ public class HomeSceneItem { homeAnimalItem -> GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId())) .map( - homeAnimalItem -> { - return new EntityHomeAnimal( - scene, - GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), - homeAnimalItem.getSpawnPos(), - homeAnimalItem.getSpawnRot()); - }) + homeAnimalItem -> new EntityHomeAnimal( + scene, + GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), + homeAnimalItem.getSpawnPos(), + homeAnimalItem.getSpawnRot())) .toList(); } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java index 8be641b19..981f87881 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java @@ -46,9 +46,7 @@ public class EnergyManager extends BasePlayerManager { try { DataLoader.loadList("EnergyDrop.json", EnergyDropEntry.class) .forEach( - entry -> { - energyDropData.put(entry.getDropId(), entry.getDropList()); - }); + entry -> energyDropData.put(entry.getDropId(), entry.getDropList())); Grasscutter.getLogger().debug("Energy drop data successfully loaded."); } catch (Exception ex) { @@ -59,9 +57,7 @@ public class EnergyManager extends BasePlayerManager { try { DataLoader.loadList("SkillParticleGeneration.json", SkillParticleGenerationEntry.class) .forEach( - entry -> { - skillParticleGenerationData.put(entry.getAvatarId(), entry.getAmountList()); - }); + entry -> skillParticleGenerationData.put(entry.getAvatarId(), entry.getAmountList())); Grasscutter.getLogger().debug("Skill particle generation data successfully loaded."); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java index 7ff42db0b..6fd704e6a 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java @@ -52,9 +52,7 @@ public enum ItemUseOp { static { Stream.of(values()) .forEach( - e -> { - map.put(e.getValue(), e); - }); + e -> map.put(e.getValue(), e)); } private final int value; diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java index 99641d085..c1eda8fa3 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java @@ -16,9 +16,7 @@ public enum ItemUseTarget { static { Stream.of(values()) .forEach( - e -> { - map.put(e.getValue(), e); - }); + e -> map.put(e.getValue(), e)); } private final int value; diff --git a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java index b9a082590..7393fbf9d 100644 --- a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java +++ b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java @@ -14,9 +14,7 @@ public enum ServerBuffType { static { Stream.of(values()) .forEach( - e -> { - map.put(e.getValue(), e); - }); + e -> map.put(e.getValue(), e)); } private final int value; diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index 6ac1d1313..d4b9e4839 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -295,9 +295,7 @@ public class GameQuest { getMainQuest().getChildQuests().values().stream() .filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()) .forEach( - q -> { - q.clearProgress(notifyDelete); - }); + q -> q.clearProgress(notifyDelete)); clearProgress(notifyDelete); this.start(); return true; diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLib.java b/src/main/java/emu/grasscutter/scripts/ScriptLib.java index e5ce947df..6eaac1849 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -632,9 +632,7 @@ public class ScriptLib { worktop.removeWorktopOption(callParams.param2); var scene = getSceneScriptManager().getScene(); - Grasscutter.getGameServer().getScheduler().scheduleDelayedTask(() -> { - scene.broadcastPacket(new PacketWorktopOptionNotify(gadget)); - }, 1); + Grasscutter.getGameServer().getScheduler().scheduleDelayedTask(() -> scene.broadcastPacket(new PacketWorktopOptionNotify(gadget)), 1); return 0; } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java index 6e80b6fb2..f0b084f27 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java @@ -17,13 +17,11 @@ public class HandlerHomeKickPlayerReq extends PacketHandler { .filter(player -> player.getUid() == req.getTargetUid()) .findFirst() .ifPresent( - player -> { - success.set( - session - .getServer() - .getHomeWorldMPSystem() - .kickPlayerFromHome(session.getPlayer(), player.getUid())); - }); + player -> success.set( + session + .getServer() + .getHomeWorldMPSystem() + .kickPlayerFromHome(session.getPlayer(), player.getUid()))); session.send( new PacketHomeKickPlayerRsp( diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java index 08908c5cb..f50d1b022 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java @@ -14,16 +14,14 @@ public class PacketActivityScheduleInfoNotify extends BasePacket { var proto = ActivityScheduleInfoNotifyOuterClass.ActivityScheduleInfoNotify.newBuilder(); activityConfigItemList.forEach( - item -> { - proto.addActivityScheduleList( - ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() - .setActivityId(item.getActivityId()) - .setScheduleId(item.getScheduleId()) - .setIsOpen(true) - .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) - .setEndTime(DateHelper.getUnixTime(item.getEndTime())) - .build()); - }); + item -> proto.addActivityScheduleList( + ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() + .setActivityId(item.getActivityId()) + .setScheduleId(item.getScheduleId()) + .setIsOpen(true) + .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) + .setEndTime(DateHelper.getUnixTime(item.getEndTime())) + .build())); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java index 1d65c6bc5..74a02ea09 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java @@ -22,9 +22,7 @@ public class PacketBattlePassMissionUpdateNotify extends BasePacket { var proto = BattlePassMissionUpdateNotify.newBuilder(); missions.forEach( - mission -> { - proto.addMissionList(mission.toProto()); - }); + mission -> proto.addMissionList(mission.toProto())); this.setData(proto.build()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java index 14e2755a2..67e464d03 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java @@ -93,11 +93,9 @@ public class PacketCodexDataFullNotify extends BasePacket { .getCodex() .getUnlockedReliquarySuitCodex() .forEach( - reliquarySuit -> { - reliquaryData - .addCodexIdList(reliquarySuit) - .addAllHaveViewedList(Collections.singleton(true)); - }); + reliquarySuit -> reliquaryData + .addCodexIdList(reliquarySuit) + .addAllHaveViewedList(Collections.singleton(true))); CodexDataFullNotify.Builder proto = CodexDataFullNotify.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java index 6d9537e19..3f7a8a088 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java @@ -34,16 +34,14 @@ public class PacketCreateVehicleRsp extends BasePacket { vehicleMembers.stream() .forEach( - vehicleMember -> { - player - .getScene() - .broadcastPacket( - new PacketVehicleInteractRsp( - ((EntityVehicle) entity), - vehicleMember, - VehicleInteractTypeOuterClass.VehicleInteractType - .VEHICLE_INTERACT_TYPE_OUT)); - }); + vehicleMember -> player + .getScene() + .broadcastPacket( + new PacketVehicleInteractRsp( + ((EntityVehicle) entity), + vehicleMember, + VehicleInteractTypeOuterClass.VehicleInteractType + .VEHICLE_INTERACT_TYPE_OUT))); player.getScene().killEntity(entity, 0); }); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java index dca56bf9b..6d25619cd 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java @@ -20,10 +20,8 @@ public class PacketPlayerDataNotify extends BasePacket { player .getProperties() .forEach( - (key, value) -> { - p.putPropMap( - key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build()); - }); + (key, value) -> p.putPropMap( + key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build())); this.setData(p.build()); } diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index ab382e59a..35b9a4e54 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -189,12 +189,10 @@ public final class Tools { achievementDataMap.values().stream() .filter(AchievementData::isUsed) .forEach( - data -> { - h.newTranslatedLine( - padAchievementId.formatted(data.getId()) + "{0} - {1}", - data.getTitleTextMapHash(), - data.getDescTextMapHash()); - }); + data -> h.newTranslatedLine( + padAchievementId.formatted(data.getId()) + "{0} - {1}", + data.getTitleTextMapHash(), + data.getDescTextMapHash())); // Write txt files for (int i = 0; i < TextStrings.NUM_LANGUAGES; i++) { @@ -352,14 +350,12 @@ public final class Tools { try { Files.newDirectoryStream(getResourcePath("TextMap"), "TextMap*.json") .forEach( - path -> { - availableLangList.add( - path.getFileName() - .toString() - .replace("TextMap", "") - .replace(".json", "") - .toLowerCase()); - }); + path -> availableLangList.add( + path.getFileName() + .toString() + .replace("TextMap", "") + .replace(".json", "") + .toLowerCase())); } catch (IOException e) { Grasscutter.getLogger().error("Failed to get available languages:", e); } From b5d0afd0febc2a099c424a08351944a651ffe355 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:17:05 -0300 Subject: [PATCH 17/59] refactor: we don't need explicit types here --- .../command/commands/SendMailCommand.java | 2 +- .../data/excels/EquipAffixData.java | 2 +- .../data/excels/avatar/AvatarTalentData.java | 2 +- .../grasscutter/game/friends/FriendsList.java | 4 +-- .../game/inventory/EquipInventoryTab.java | 2 +- .../java/emu/grasscutter/game/mail/Mail.java | 2 +- .../emu/grasscutter/game/player/Player.java | 2 +- .../game/systems/InventorySystem.java | 8 ++--- .../emu/grasscutter/game/world/Scene.java | 4 +-- .../scripts/SceneScriptManager.java | 2 +- .../packet/recv/HandlerBuyGoodsReq.java | 2 +- .../packet/send/PacketMailChangeNotify.java | 10 +++--- .../emu/grasscutter/utils/lang/Language.java | 32 +++++++++---------- .../utils/objects/WeightedList.java | 2 +- 14 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index c4c0e6a4f..4c0f60907 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -25,7 +25,7 @@ public final class SendMailCommand implements CommandHandler { // Key = User that is constructing the mail. private static final HashMap mailBeingConstructed = - new HashMap(); + new HashMap<>(); // Yes this is awful and I hate it. @Override diff --git a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java index 08adc351d..d95fb6154 100644 --- a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java +++ b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java @@ -46,7 +46,7 @@ public class EquipAffixData extends GameResource { @Override public void onLoad() { - ArrayList parsed = new ArrayList(getAddProps().length); + ArrayList parsed = new ArrayList<>(getAddProps().length); for (FightPropData prop : getAddProps()) { if (prop.getPropType() != null && prop.getValue() != 0f) { prop.onLoad(); diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java index be08ede9f..5f91ca3c3 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java @@ -56,7 +56,7 @@ public class AvatarTalentData extends GameResource { @Override public void onLoad() { - ArrayList parsed = new ArrayList(getAddProps().length); + ArrayList parsed = new ArrayList<>(getAddProps().length); for (FightPropData prop : getAddProps()) { if (prop.getPropType() != null || prop.getValue() == 0f) { prop.onLoad(); diff --git a/src/main/java/emu/grasscutter/game/friends/FriendsList.java b/src/main/java/emu/grasscutter/game/friends/FriendsList.java index f7b1cd0f8..a6d723a9e 100644 --- a/src/main/java/emu/grasscutter/game/friends/FriendsList.java +++ b/src/main/java/emu/grasscutter/game/friends/FriendsList.java @@ -15,8 +15,8 @@ public class FriendsList extends BasePlayerManager { public FriendsList(Player player) { super(player); - this.friends = new Int2ObjectOpenHashMap(); - this.pendingFriends = new Int2ObjectOpenHashMap(); + this.friends = new Int2ObjectOpenHashMap<>(); + this.pendingFriends = new Int2ObjectOpenHashMap<>(); } public boolean hasLoaded() { diff --git a/src/main/java/emu/grasscutter/game/inventory/EquipInventoryTab.java b/src/main/java/emu/grasscutter/game/inventory/EquipInventoryTab.java index 5da1ae1ca..22b79f13b 100644 --- a/src/main/java/emu/grasscutter/game/inventory/EquipInventoryTab.java +++ b/src/main/java/emu/grasscutter/game/inventory/EquipInventoryTab.java @@ -7,7 +7,7 @@ public class EquipInventoryTab implements InventoryTab { private final int maxCapacity; public EquipInventoryTab(int maxCapacity) { - this.items = new HashSet(); + this.items = new HashSet<>(); this.maxCapacity = maxCapacity; } diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index 9f9404091..7acfd5a22 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -30,7 +30,7 @@ public final class Mail { public Mail() { this( new MailContent(), - new ArrayList(), + new ArrayList<>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command } diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index c8c65aded..e951dd307 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -1204,7 +1204,7 @@ public class Player implements PlayerHook, FieldFetch { public Map getMapMarks() { if (this.mapMarks == null) { - this.mapMarks = new HashMap(); + this.mapMarks = new HashMap<>(); } return mapMarks; } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index f84ae7078..624a97fca 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -122,7 +122,7 @@ public class InventorySystem extends BaseGameSystem { int moraCost = 0; int expGain = 0; - List foodRelics = new ArrayList(); + List foodRelics = new ArrayList<>(); for (long guid : foodRelicList) { // Add to delete queue GameItem food = player.getInventory().getItemByGuid(guid); @@ -139,7 +139,7 @@ public class InventorySystem extends BaseGameSystem { } foodRelics.add(food); } - List payList = new ArrayList(); + List payList = new ArrayList<>(); for (ItemParam itemParam : list) { int amount = itemParam @@ -347,7 +347,7 @@ public class InventorySystem extends BaseGameSystem { // Get exp gain int expGain = 0, expGainFree = 0; - List foodWeapons = new ArrayList(); + List foodWeapons = new ArrayList<>(); for (long guid : foodWeaponGuidList) { GameItem food = player.getInventory().getItemByGuid(guid); if (food == null || !food.isDestroyable()) { @@ -359,7 +359,7 @@ public class InventorySystem extends BaseGameSystem { } foodWeapons.add(food); } - List payList = new ArrayList(); + List payList = new ArrayList<>(); for (ItemParam param : itemParamList) { int amount = param.getCount(); // Previously this capped to inventory amount, but rejecting the payment diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 125188838..993b2d42a 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -396,10 +396,10 @@ public class Scene { } private static List> chopped(List list, final int L) { - List> parts = new ArrayList>(); + List> parts = new ArrayList<>(); final int N = list.size(); for (int i = 0; i < N; i += L) { - parts.add(new ArrayList(list.subList(i, Math.min(N, i + L)))); + parts.add(new ArrayList<>(list.subList(i, Math.min(N, i + L)))); } return parts; } diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index ca5113167..106c79483 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -270,7 +270,7 @@ public class SceneScriptManager { // If that trigger has been refreshed, ensure it does not get // deregistered anyway when the trigger completes its invocation. for (var triggerSet : currentTriggers.values()) { - var toSave = new HashSet(triggerSet); + var toSave = new HashSet<>(triggerSet); toSave.retainAll(ongoingTriggers); toSave.forEach(t -> t.setPreserved(true)); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java index 05b0c1941..3e2947662 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java @@ -49,7 +49,7 @@ public class HandlerBuyGoodsReq extends PacketHandler { } List costs = - new ArrayList(sg.getCostItemList()); // Can this even be null? + new ArrayList<>(sg.getCostItemList()); // Can this even be null? costs.add(new ItemParamData(202, sg.getScoin())); costs.add(new ItemParamData(201, sg.getHcoin())); costs.add(new ItemParamData(203, sg.getMcoin())); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java index 105e1c7dd..402e13aed 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java @@ -15,11 +15,11 @@ public class PacketMailChangeNotify extends BasePacket { public PacketMailChangeNotify(Player player, Mail message) { this( player, - new ArrayList() { - { - add(message); - } - }); + new ArrayList<>() { + { + add(message); + } + }); } public PacketMailChangeNotify(Player player, List mailList) { diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index df141b7b8..8e64dc98a 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -261,22 +261,22 @@ public final class Language { .collect(Collectors.toList()); Map canonicalTextStrings = new HashMap<>(); - return new Int2ObjectOpenHashMap( - nameHashes - .intStream() - .boxed() - .collect( - Collectors.toMap( - key -> key, - key -> { - TextStrings t = - new TextStrings( - IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(i -> languageMaps.get(i).get((int) key)) - .collect(Collectors.toList()), - key); - return canonicalTextStrings.computeIfAbsent(t, x -> t); - }))); + return new Int2ObjectOpenHashMap<>( + nameHashes + .intStream() + .boxed() + .collect( + Collectors.toMap( + key -> key, + key -> { + TextStrings t = + new TextStrings( + IntStream.range(0, TextStrings.NUM_LANGUAGES) + .mapToObj(i -> languageMaps.get(i).get((int) key)) + .collect(Collectors.toList()), + key); + return canonicalTextStrings.computeIfAbsent(t, x -> t); + }))); } @SuppressWarnings("unchecked") diff --git a/src/main/java/emu/grasscutter/utils/objects/WeightedList.java b/src/main/java/emu/grasscutter/utils/objects/WeightedList.java index bc9ac658e..9d822378f 100644 --- a/src/main/java/emu/grasscutter/utils/objects/WeightedList.java +++ b/src/main/java/emu/grasscutter/utils/objects/WeightedList.java @@ -4,7 +4,7 @@ import java.util.*; import java.util.concurrent.ThreadLocalRandom; public class WeightedList { - private final NavigableMap map = new TreeMap(); + private final NavigableMap map = new TreeMap<>(); private double total = 0; public WeightedList() {} From bb82e21c82021c4f1b5534505b01546f2269c45b Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:18:48 -0300 Subject: [PATCH 18/59] refactor: replace for loop with enhanced loop --- src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java index 1127ef9a4..5bb4b35fc 100644 --- a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java +++ b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java @@ -23,10 +23,10 @@ public class KahnsSort { mainList = new HashMap<>(); this.nodeList = nodeList; - for (int i = 0; i < nodeList.size(); i++) mainList.put(nodeList.get(i), new ArrayList<>()); + for (Integer value : nodeList) mainList.put(value, new ArrayList<>()); degreeList = new HashMap<>(); - for (int i = 0; i < nodeList.size(); i++) degreeList.put(nodeList.get(i), 0); + for (Integer integer : nodeList) degreeList.put(integer, 0); for (Node node : nodes) { mainList.get(node.source).add(node.dest); From 6d669bd47a2e54f92c6828237aa0a137bc0db5f3 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:19:41 -0300 Subject: [PATCH 19/59] refactor: Integer.ParseInt is more appropriate here --- .../emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java index c4e986476..ef11c0e93 100644 --- a/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecDecQuestGlobalVar.java @@ -12,7 +12,7 @@ public class ExecDecQuestGlobalVar extends QuestExecHandler { quest .getOwner() .getQuestManager() - .decQuestGlobalVarValue(Integer.valueOf(paramStr[0]), Integer.valueOf(paramStr[1])); + .decQuestGlobalVarValue(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); return true; } } From 7db8b6f0c71c557621e0943819cd50ec2c2983ee Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:20:19 -0300 Subject: [PATCH 20/59] refactor: Integer.ParseInt is more appropriate here --- .../emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java | 2 +- .../emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java index 0d1af5717..8b0a92d58 100644 --- a/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecIncQuestGlobalVar.java @@ -12,7 +12,7 @@ public class ExecIncQuestGlobalVar extends QuestExecHandler { quest .getOwner() .getQuestManager() - .incQuestGlobalVarValue(Integer.valueOf(paramStr[0]), Integer.valueOf(paramStr[1])); + .incQuestGlobalVarValue(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); return true; } } diff --git a/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java index fe1630ff9..eeb09d9db 100644 --- a/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java +++ b/src/main/java/emu/grasscutter/game/quest/exec/ExecSetQuestGlobalVar.java @@ -12,7 +12,7 @@ public class ExecSetQuestGlobalVar extends QuestExecHandler { quest .getOwner() .getQuestManager() - .setQuestGlobalVarValue(Integer.valueOf(paramStr[0]), Integer.valueOf(paramStr[1])); + .setQuestGlobalVarValue(Integer.parseInt(paramStr[0]), Integer.parseInt(paramStr[1])); return true; } } From c9b42a6dfbd6501475aff582b7ab911a319c1ca6 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:25:14 -0300 Subject: [PATCH 21/59] refactor: replace switch with enhanced switch --- .../grasscutter/game/inventory/Inventory.java | 38 +++++++++---------- .../recv/HandlerSetPlayerBirthdayReq.java | 24 +++--------- 2 files changed, 25 insertions(+), 37 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 67dcd32ba..b0e8f72d9 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -431,26 +431,26 @@ public class Inventory extends BasePlayerManager implements Iterable { } private int getVirtualItemCount(int itemId) { - switch (itemId) { - case 201: // Primogem - return this.player.getPrimogems(); - case 202: // Mora - return this.player.getMora(); - case 203: // Genesis Crystals - return this.player.getCrystals(); - case 106: // Resin - return this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); - case 107: // Legendary Key - return this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); - case 204: // Home Coin - return this.player.getHomeCoin(); - default: + return switch (itemId) { + case 201 -> // Primogem + this.player.getPrimogems(); + case 202 -> // Mora + this.player.getMora(); + case 203 -> // Genesis Crystals + this.player.getCrystals(); + case 106 -> // Resin + this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); + case 107 -> // Legendary Key + this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); + case 204 -> // Home Coin + this.player.getHomeCoin(); + default -> { GameItem item = - getInventoryTab(ItemType.ITEM_MATERIAL) - .getItemById( - itemId); // What if we ever want to operate on weapons/relics/furniture? :S - return (item == null) ? 0 : item.getCount(); - } + getInventoryTab(ItemType.ITEM_MATERIAL) + .getItemById( + itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S + } + }; } public synchronized boolean payItem(int id, int count) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java index 4103ca8d4..b4752b421 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java @@ -40,24 +40,12 @@ public class HandlerSetPlayerBirthdayReq extends PacketHandler { private boolean isValidBirthday(int month, int day) { - switch (month) { - case 1: - case 3: - case 5: - case 7: - case 8: - case 10: - case 12: - return day > 0 & day <= 31; - case 4: - case 6: - case 9: - case 11: - return day > 0 && day <= 30; - case 2: - return day > 0 & day <= 29; - } + return switch (month) { + case 1, 3, 5, 7, 8, 10, 12 -> day > 0 & day <= 31; + case 4, 6, 9, 11 -> day > 0 && day <= 30; + case 2 -> day > 0 & day <= 29; + default -> false; + }; - return false; } } From 77e246213fd6e684ad7f2f6b1f7b8b1df5d1ab92 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:33:59 -0300 Subject: [PATCH 22/59] refactor: fix javadoc issues --- .../java/emu/grasscutter/data/DataLoader.java | 60 +++++++++---------- .../java/emu/grasscutter/data/GameData.java | 4 +- .../ActivityConditionBaseHandler.java | 2 +- .../grasscutter/game/entity/EntityRegion.java | 2 +- .../stamina/BeforeUpdateStaminaListener.java | 4 +- .../game/player/PlayerProgressManager.java | 6 +- .../scripts/SceneScriptManager.java | 12 ++-- .../emu/grasscutter/server/http/Router.java | 4 +- .../packet/recv/HandlerQueryPathReq.java | 2 +- .../PacketPlayerWorldSceneInfoListNotify.java | 2 +- 10 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/DataLoader.java b/src/main/java/emu/grasscutter/data/DataLoader.java index e6ea19068..0b205181f 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -1,12 +1,20 @@ package emu.grasscutter.data; import emu.grasscutter.Grasscutter; -import emu.grasscutter.utils.*; -import java.io.*; -import java.nio.file.*; -import java.util.*; +import emu.grasscutter.utils.FileUtils; +import emu.grasscutter.utils.JsonUtils; +import emu.grasscutter.utils.TsvUtils; import lombok.val; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Map; + public class DataLoader { /** @@ -15,7 +23,7 @@ public class DataLoader { * * @param resourcePath The path to the data file to be loaded. * @return InputStream of the data file. - * @throws FileNotFoundException + * @throws FileNotFoundException If the file is not found. * @see #load(String, boolean) */ public static InputStream load(String resourcePath) throws FileNotFoundException { @@ -24,44 +32,37 @@ public class DataLoader { /** * Creates an input stream reader for a data file. If the file isn't found within the /data - * directory then it will fallback to the default within the jar resources + * directory then it will fall back to the default within the jar resources * * @param resourcePath The path to the data file to be loaded. * @return InputStreamReader of the data file. - * @throws IOException - * @throws FileNotFoundException + * @throws IOException If the file is not found. + * @throws FileNotFoundException If the file is not found. * @see #load(String, boolean) */ - public static InputStreamReader loadReader(String resourcePath) - throws IOException, FileNotFoundException { - try { - InputStream is = load(resourcePath, true); - return new InputStreamReader(is); - } catch (FileNotFoundException exception) { - throw exception; - } + public static InputStreamReader loadReader(String resourcePath) throws IOException { + InputStream is = load(resourcePath, true); + if (is == null) throw new FileNotFoundException("File not found: " + resourcePath); + return new InputStreamReader(is); } /** * Load a data file by its name. * * @param resourcePath The path to the data file to be loaded. - * @param useFallback If the file does not exist in the /data directory, should it use the default - * file in the jar? + * @param useFallback If the file does not exist in the /data directory, should it use the default + * file in the jar? * @return InputStream of the data file. - * @throws FileNotFoundException + * @throws FileNotFoundException If the file is not found. */ - public static InputStream load(String resourcePath, boolean useFallback) - throws FileNotFoundException { - Path path = - useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); + public static InputStream load(String resourcePath, boolean useFallback) throws FileNotFoundException { + Path path = useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); if (Files.exists(path)) { // Data is in the resource directory try { return Files.newInputStream(path); } catch (IOException e) { - throw new FileNotFoundException( - e.getMessage()); // This is evil but so is changing the function signature at this point + throw new FileNotFoundException(e.getMessage()); // This is evil but so is changing the function signature at this point } } return null; @@ -79,15 +80,13 @@ public class DataLoader { } } - public static Map loadMap( - String resourcePath, Class keyType, Class valueType) throws IOException { + public static Map loadMap(String resourcePath, Class keyType, Class valueType) throws IOException { try (InputStreamReader reader = loadReader(resourcePath)) { return JsonUtils.loadToMap(reader, keyType, valueType); } } - public static List loadTableToList(String resourcePath, Class classType) - throws IOException { + public static List loadTableToList(String resourcePath, Class classType) throws IOException { val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); Grasscutter.getLogger().trace("Loading data table from: " + path); return switch (FileUtils.getFileExtension(path)) { @@ -120,8 +119,7 @@ public class DataLoader { if (!Files.exists(filePath)) { var root = filePath.getParent(); - if (root.toFile().mkdirs()) - Grasscutter.getLogger().info("Created data folder '" + root + "'"); + if (root.toFile().mkdirs()) Grasscutter.getLogger().info("Created data folder '" + root + "'"); Grasscutter.getLogger().debug("Creating default '" + name + "' data"); FileUtils.copyResource("/defaults/data/" + name, filePath.toString()); diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index f6d9a48d7..c2ba581f9 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -713,8 +713,8 @@ public final class GameData { /** * Fetches the trial data * - * @param trialAvatarIndexId - * @return + * @param trialAvatarIndexId The ID of the trial avatar + * @return The trial data for the trial avatar */ @Nullable public static TrialAvatarActivityDataData getTrialAvatarActivityDataByAvatarIndex( int trialAvatarIndexId) { diff --git a/src/main/java/emu/grasscutter/game/activity/condition/ActivityConditionBaseHandler.java b/src/main/java/emu/grasscutter/game/activity/condition/ActivityConditionBaseHandler.java index abf45b02d..2bc47d43f 100644 --- a/src/main/java/emu/grasscutter/game/activity/condition/ActivityConditionBaseHandler.java +++ b/src/main/java/emu/grasscutter/game/activity/condition/ActivityConditionBaseHandler.java @@ -13,7 +13,7 @@ public abstract class ActivityConditionBaseHandler { * Execute activity condition handler and return result of it's calculation * * @param activityData {@link PlayerActivityData} object containing info about activity - * @param activityConfig + * @param activityConfig {@link ActivityConfigItem} object containing info about activity * @param params params for handler * @return result of condition calculation */ diff --git a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java index 37be6f3b9..33bfb7050 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java @@ -82,7 +82,7 @@ public class EntityRegion extends GameEntity { @Override public SceneEntityInfoOuterClass.SceneEntityInfo toProto() { - /** The Region Entity would not be sent to client. */ + /* The Region Entity would not be sent to client. */ return null; } diff --git a/src/main/java/emu/grasscutter/game/managers/stamina/BeforeUpdateStaminaListener.java b/src/main/java/emu/grasscutter/game/managers/stamina/BeforeUpdateStaminaListener.java index 725ec1880..967d20e01 100644 --- a/src/main/java/emu/grasscutter/game/managers/stamina/BeforeUpdateStaminaListener.java +++ b/src/main/java/emu/grasscutter/game/managers/stamina/BeforeUpdateStaminaListener.java @@ -7,7 +7,7 @@ public interface BeforeUpdateStaminaListener { * * @param reason Why updating stamina. * @param newStamina New ABSOLUTE stamina value. - * @return true if you want to cancel this update, otherwise false. + * @return current stamina value. If you want to cancel this update, return the newStamina value. */ int onBeforeUpdateStamina(String reason, int newStamina, boolean isCharacterStamina); @@ -17,7 +17,7 @@ public interface BeforeUpdateStaminaListener { * * @param reason Why updating stamina. * @param consumption ConsumptionType and RELATIVE stamina change amount. - * @return true if you want to cancel this update, otherwise false. + * @return current stamina value. If you want to cancel this update, return the newStamina value. */ Consumption onBeforeUpdateStamina( String reason, Consumption consumption, boolean isCharacterStamina); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java index 7dfa50d48..b93968f94 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java @@ -19,7 +19,7 @@ import java.util.stream.Collectors; // @Entity public final class PlayerProgressManager extends BasePlayerDataManager { /****************************************************************************************************************** - ****************************************************************************************************************** + *

* OPEN STATES ****************************************************************************************************************** *****************************************************************************************************************/ @@ -215,7 +215,7 @@ public final class PlayerProgressManager extends BasePlayerDataManager { } /****************************************************************************************************************** - ****************************************************************************************************************** + *

* MAP AREAS AND POINTS ****************************************************************************************************************** *****************************************************************************************************************/ @@ -313,7 +313,7 @@ public final class PlayerProgressManager extends BasePlayerDataManager { } /****************************************************************************************************************** - ****************************************************************************************************************** + *

* SCENETAGS ****************************************************************************************************************** *****************************************************************************************************************/ diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 106c79483..343783450 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -847,12 +847,12 @@ public class SceneScriptManager { } public Future callEvent(@Nonnull ScriptArgs params) { - /** - * We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for - * every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib - * func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could - * not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> - * (remove) So we use thread pool to clean the stack to avoid this new issue. + /* + We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for + every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib + func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could + not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> + (remove) So we use thread pool to clean the stack to avoid this new issue. */ return eventExecutor.submit(() -> this.realCallEvent(params)); } diff --git a/src/main/java/emu/grasscutter/server/http/Router.java b/src/main/java/emu/grasscutter/server/http/Router.java index 5c7aa9a68..d083bba2c 100644 --- a/src/main/java/emu/grasscutter/server/http/Router.java +++ b/src/main/java/emu/grasscutter/server/http/Router.java @@ -17,8 +17,8 @@ public interface Router { * Applies this handler to all endpoint types * * @param javalin A Javalin instance. - * @param path - * @param ctx + * @param path The path to apply the handler to. + * @param ctx The handler to apply. * @return The Javalin instance. */ default Javalin allRoutes(Javalin javalin, String path, Handler ctx) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java index 6b4efa4be..b5fd35a16 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java @@ -12,7 +12,7 @@ public class HandlerQueryPathReq extends PacketHandler { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { var req = QueryPathReq.parseFrom(payload); - /** It is not the actual work */ + /* It is not the actual work */ if (!req.getDestinationPosList().isEmpty()) { session.send(new PacketQueryPathRsp(req)); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java index 600bd1e2f..dd7d0be1e 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java @@ -24,7 +24,7 @@ public class PacketPlayerWorldSceneInfoListNotify extends BasePacket { for (int scene : GameData.getSceneDataMap().keySet()) { var worldInfoBuilder = PlayerWorldSceneInfo.newBuilder().setSceneId(scene).setIsLocked(false); - /** Add scene-specific data */ + /* Add scene-specific data */ // Scenetags if (sceneTags.keySet().contains(scene)) { From 6e7418a89dbc3a1d26641923aef2a35feee5ee25 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:35:38 -0300 Subject: [PATCH 23/59] refactor: replace concatenation log with parameterized --- .../java/emu/grasscutter/Grasscutter.java | 2 +- .../emu/grasscutter/command/CommandMap.java | 20 ++--- .../java/emu/grasscutter/data/DataLoader.java | 6 +- .../java/emu/grasscutter/data/GameData.java | 2 +- .../emu/grasscutter/data/ResourceLoader.java | 27 +++---- .../grasscutter/database/DatabaseHelper.java | 2 +- .../game/ability/AbilityManager.java | 12 +-- .../grasscutter/game/gacha/GachaBanner.java | 7 +- .../grasscutter/game/inventory/Inventory.java | 5 +- .../grasscutter/game/mail/MailHandler.java | 7 +- .../game/managers/SotSManager.java | 15 ++-- .../game/managers/blossom/BlossomManager.java | 4 +- .../game/managers/stamina/StaminaManager.java | 23 ++---- .../emu/grasscutter/game/shop/ShopSystem.java | 2 +- .../game/systems/InventorySystem.java | 7 +- .../java/emu/grasscutter/plugin/Plugin.java | 4 +- .../scripts/SceneScriptManager.java | 4 +- .../grasscutter/scripts/data/SceneBlock.java | 4 +- .../grasscutter/scripts/data/SceneGroup.java | 3 +- .../grasscutter/scripts/data/SceneMeta.java | 2 +- .../server/game/GameServerPacketHandler.java | 8 +- .../grasscutter/server/game/GameSession.java | 2 +- .../grasscutter/server/http/HttpServer.java | 3 +- .../documentation/RootRequestHandler.java | 2 +- .../http/handlers/AnnouncementsHandler.java | 6 +- .../server/http/objects/HttpJsonResponse.java | 12 ++- .../objects/WebStaticVersionResponse.java | 2 +- .../recv/HandlerCombatInvocationsNotify.java | 23 +----- .../java/emu/grasscutter/task/TaskMap.java | 5 +- .../java/emu/grasscutter/tools/Tools.java | 6 +- .../java/emu/grasscutter/utils/FileUtils.java | 18 ++--- .../java/emu/grasscutter/utils/TsvUtils.java | 76 +++++++------------ .../java/emu/grasscutter/utils/Utils.java | 6 +- .../emu/grasscutter/utils/lang/Language.java | 14 ++-- 34 files changed, 120 insertions(+), 221 deletions(-) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index 8c3248dd7..7717871b1 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -312,7 +312,7 @@ public final class Grasscutter { public static void updateDayOfWeek() { Calendar calendar = Calendar.getInstance(); Grasscutter.currentDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); - logger.debug("Set day of week to " + currentDayOfWeek); + logger.debug("Set day of week to {}", currentDayOfWeek); } public static void startConsole() { diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index d452cc6ba..1947cab8e 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -53,7 +53,7 @@ public final class CommandMap { * @return Instance chaining. */ public CommandMap registerCommand(String label, CommandHandler command) { - Grasscutter.getLogger().trace("Registered command: " + label); + Grasscutter.getLogger().trace("Registered command: {}", label); label = label.toLowerCase(); // Get command data. @@ -76,7 +76,7 @@ public final class CommandMap { * @return Instance chaining. */ public CommandMap unregisterCommand(String label) { - Grasscutter.getLogger().trace("Un-registered command: " + label); + Grasscutter.getLogger().trace("Un-registered command: {}", label); CommandHandler handler = this.commands.get(label); if (handler == null) return this; @@ -230,15 +230,9 @@ public final class CommandMap { if (SERVER.logCommands) { if (player != null) { Grasscutter.getLogger() - .info( - "Command used by [" - + player.getAccount().getUsername() - + " (Player UID: " - + player.getUid() - + ")]: " - + rawMessage); + .info("Command used by [{} (Player UID: {})]: {}", player.getAccount().getUsername(), player.getUid(), rawMessage); } else { - Grasscutter.getLogger().info("Command used by server console: " + rawMessage); + Grasscutter.getLogger().info("Command used by server console: {}", rawMessage); } } @@ -350,12 +344,10 @@ public final class CommandMap { this.registerCommand(cmdData.label(), (CommandHandler) object); else Grasscutter.getLogger() - .error("Class " + annotated.getName() + " is not a CommandHandler!"); + .error("Class {} is not a CommandHandler!", annotated.getName()); } catch (Exception exception) { Grasscutter.getLogger() - .error( - "Failed to register command handler for " + annotated.getSimpleName(), - exception); + .error("Failed to register command handler for {}", annotated.getSimpleName(), exception); } }); } diff --git a/src/main/java/emu/grasscutter/data/DataLoader.java b/src/main/java/emu/grasscutter/data/DataLoader.java index 0b205181f..0d19c11f0 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -88,7 +88,7 @@ public class DataLoader { public static List loadTableToList(String resourcePath, Class classType) throws IOException { val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); - Grasscutter.getLogger().trace("Loading data table from: " + path); + Grasscutter.getLogger().trace("Loading data table from: {}", path); return switch (FileUtils.getFileExtension(path)) { case "json" -> JsonUtils.loadToList(path, classType); case "tsj" -> TsvUtils.loadTsjToListSetField(path, classType); @@ -119,9 +119,9 @@ public class DataLoader { if (!Files.exists(filePath)) { var root = filePath.getParent(); - if (root.toFile().mkdirs()) Grasscutter.getLogger().info("Created data folder '" + root + "'"); + if (root.toFile().mkdirs()) Grasscutter.getLogger().info("Created data folder '{}'", root); - Grasscutter.getLogger().debug("Creating default '" + name + "' data"); + Grasscutter.getLogger().debug("Creating default '{}' data", name); FileUtils.copyResource("/defaults/data/" + name, filePath.toString()); } } diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index c2ba581f9..be1d2a25e 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -655,7 +655,7 @@ public final class GameData { field.setAccessible(false); } catch (Exception e) { Grasscutter.getLogger() - .error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e); + .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); } return map; diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 13be4c4a2..d7e7df051 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -63,7 +63,7 @@ public final class ResourceLoader { private static List>> getResourceDefClassesPrioritySets() { val classes = Grasscutter.reflector.getSubTypesOf(GameResource.class); val priorities = ResourceType.LoadPriority.getInOrder(); - Grasscutter.getLogger().debug("Priorities are " + priorities); + Grasscutter.getLogger().debug("Priorities are {}", priorities); val map = new LinkedHashMap>>(priorities.size()); priorities.forEach(p -> map.put(p, new HashSet<>())); @@ -159,11 +159,11 @@ public final class ResourceLoader { })); errors.forEach( pair -> - Grasscutter.getLogger() - .error("Error loading resource file: " + pair.left(), pair.right())); + Grasscutter.getLogger() + .error("Error loading resource file: {}", pair.left(), pair.right())); long endTime = System.nanoTime(); long ns = (endTime - startTime); // divide by 1000000 to get milliseconds. - Grasscutter.getLogger().debug("Loading resources took " + ns + "ns == " + ns / 1000000 + "ms"); + Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000); } @SuppressWarnings("rawtypes") @@ -281,7 +281,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneRouteDatas."); + .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneRouteData folder."); } @@ -402,7 +402,7 @@ public final class ResourceLoader { .forEach(data -> loadAbilityData(data.Default)); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path " + path.toString() + ": ", e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -464,7 +464,7 @@ public final class ResourceLoader { path, String.class, new TypeToken>() {}.getType())); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path " + path.toString() + ": ", e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -531,7 +531,7 @@ public final class ResourceLoader { }); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading open config: no files found in " + folderName); + .error("Error loading open config: no files found in {}", folderName); return; } } @@ -587,7 +587,7 @@ public final class ResourceLoader { } Grasscutter.getLogger() - .debug("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas."); + .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); } public static void loadScriptSceneData() { @@ -605,7 +605,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded " + GameData.getScriptSceneDataMap().size() + " ScriptSceneDatas."); + .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); } catch (IOException e) { Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty."); } @@ -629,10 +629,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug( - "Loaded " - + GameData.getHomeworldDefaultSaveData().size() - + " HomeworldDefaultSaveDatas."); + .debug("Loaded {} HomeworldDefaultSaveDatas.", GameData.getHomeworldDefaultSaveData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder."); } @@ -657,7 +654,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded " + GameData.getSceneNpcBornData().size() + " SceneNpcBornDatas."); + .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder."); } diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index fffc6ab73..d1b149adc 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -550,7 +550,7 @@ public final class DatabaseHelper { .first(); } catch (IllegalArgumentException e) { Grasscutter.getLogger() - .debug("Error occurred while getting uid " + uid + "'s achievement data", e); + .debug("Error occurred while getting uid {}'s achievement data", uid, e); DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid)); return null; } diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 3bf06e5ad..1711c3b06 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -177,15 +177,7 @@ public final class AbilityManager extends BasePlayerManager { public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { Grasscutter.getLogger() - .trace( - "Ability invoke: " - + invoke - + " " - + invoke.getArgumentType() - + " (" - + invoke.getArgumentTypeValue() - + "): " - + this.player.getScene().getEntityById(invoke.getEntityId())); + .trace("Ability invoke: {} {} ({}): {}", invoke, invoke.getArgumentType(), invoke.getArgumentTypeValue(), this.player.getScene().getEntityById(invoke.getEntityId())); var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if (entity != null) { Grasscutter.getLogger() @@ -212,7 +204,7 @@ public final class AbilityManager extends BasePlayerManager { if (invoke.getHead().getTargetId() != 0) { Grasscutter.getLogger() - .trace("Target: " + this.player.getScene().getEntityById(invoke.getHead().getTargetId())); + .trace("Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); } if (invoke.getHead().getLocalId() != 0) { this.handleServerInvoke(invoke); diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index 7d3405fab..3d0c2db44 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -96,12 +96,7 @@ public class GachaBanner { private void warnDeprecated(String name, String replacement) { Grasscutter.getLogger() - .error( - "Deprecated field found in Banners config: " - + name - + " was replaced back in early May 2022, use " - + replacement - + " instead. You MUST remove this field from your config."); + .error("Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", name, replacement); this.deprecated = true; } diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index b0e8f72d9..841921ac2 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -322,10 +322,7 @@ public class Inventory extends BasePlayerManager implements Iterable { case MATERIAL_COSTUME: case MATERIAL_NAMECARD: Grasscutter.getLogger() - .warn( - "Attempted to add a " - + item.getItemData().getMaterialType().name() - + " to inventory, but item definition lacks isUseOnGain. This indicates a Resources error."); + .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); return null; default: if (tab == null) { diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index ab68b6bc6..45b3373f6 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -35,12 +35,7 @@ public class MailHandler extends BasePlayerManager { this.mail.add(message); Grasscutter.getLogger() - .debug( - "Mail sent to user [" - + this.getPlayer().getUid() - + ":" - + this.getPlayer().getNickname() - + "]!"); + .debug("Mail sent to user [{}:{}]!", this.getPlayer().getUid(), this.getPlayer().getNickname()); if (this.getPlayer().isOnline()) { this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message)); diff --git a/src/main/java/emu/grasscutter/game/managers/SotSManager.java b/src/main/java/emu/grasscutter/game/managers/SotSManager.java index eeafe1a09..2864e223e 100644 --- a/src/main/java/emu/grasscutter/game/managers/SotSManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SotSManager.java @@ -104,7 +104,7 @@ public class SotSManager extends BasePlayerManager { if (isAlive) { return; } - logger.trace("Reviving avatar " + entity.getAvatar().getAvatarData().getName()); + logger.trace("Reviving avatar {}", entity.getAvatar().getAvatarData().getName()); player.getTeamManager().reviveAvatar(entity.getAvatar()); player.getTeamManager().healAvatar(entity.getAvatar(), 30, 0); }); @@ -130,8 +130,7 @@ public class SotSManager extends BasePlayerManager { setCurrentVolume(0); } if (needHP > 0) { - logger.trace( - "Healing avatar " + entity.getAvatar().getAvatarData().getName() + " +" + needHP); + logger.trace("Healing avatar {} +{}", entity.getAvatar().getAvatarData().getName(), needHP); player.getTeamManager().healAvatar(entity.getAvatar(), 0, needHP); player .getSession() @@ -168,9 +167,9 @@ public class SotSManager extends BasePlayerManager { int secondsSinceLastUsed = (int) (now - getLastUsed()); // 15s = 1% max volume int volumeRefilled = secondsSinceLastUsed * maxVolume / 15 / 100; - logger.trace("Statue has refilled HP volume: " + volumeRefilled); + logger.trace("Statue has refilled HP volume: {}", volumeRefilled); currentVolume = Math.min(currentVolume + volumeRefilled, maxVolume); - logger.trace("Statue remaining HP volume: " + currentVolume); + logger.trace("Statue remaining HP volume: {}", currentVolume); setCurrentVolume(currentVolume); } } @@ -181,11 +180,7 @@ public class SotSManager extends BasePlayerManager { public void run() { refillSpringVolume(); - logger.trace( - "isAutoRecoveryEnabled: " - + getIsAutoRecoveryEnabled() - + "\tautoRecoverPercentage: " - + getAutoRecoveryPercentage()); + logger.trace("isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", getIsAutoRecoveryEnabled(), getAutoRecoveryPercentage()); if (getIsAutoRecoveryEnabled()) { List activeTeam = player.getTeamManager().getActiveTeam(); diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java index 5322c22c9..8dfcaea69 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java @@ -101,7 +101,7 @@ public class BlossomManager { } } - Grasscutter.getLogger().info("Blossom Monsters:" + monsters); + Grasscutter.getLogger().info("Blossom Monsters:{}", monsters); activity = new BlossomActivity(entityGadget, monsters, -1, worldLevel); blossomActivities.add(activity); @@ -203,7 +203,7 @@ public class BlossomManager { RewardPreviewData blossomRewards = getRewardList(type, worldLevel); if (blossomRewards == null) { Grasscutter.getLogger() - .error("Blossom could not support world level : " + worldLevel); + .error("Blossom could not support world level : {}", worldLevel); return null; } var rewards = blossomRewards.getPreviewItems(); diff --git a/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java b/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java index 8a0a86b10..79366e79f 100644 --- a/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java +++ b/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java @@ -229,8 +229,7 @@ public class StaminaManager extends BasePlayerManager { float diffX = currentCoordinates.getX() - previousCoordinates.getX(); float diffY = currentCoordinates.getY() - previousCoordinates.getY(); float diffZ = currentCoordinates.getZ() - previousCoordinates.getZ(); - logger.trace("isPlayerMoving: " + previousCoordinates + ", " + currentCoordinates + - ", " + diffX + ", " + diffY + ", " + diffZ); + logger.trace("isPlayerMoving: {}, {}, {}, {}, {}", previousCoordinates, currentCoordinates, diffX, diffY, diffZ); return Math.abs(diffX) > 0.3 || Math.abs(diffY) > 0.2 || Math.abs(diffZ) > 0.3; } @@ -244,17 +243,13 @@ public class StaminaManager extends BasePlayerManager { for (Map.Entry listener : beforeUpdateStaminaListeners.entrySet()) { Consumption overriddenConsumption = listener.getValue().onBeforeUpdateStamina(consumption.type.toString(), consumption, isCharacterStamina); if ((overriddenConsumption.type != consumption.type) && (overriddenConsumption.amount != consumption.amount)) { - logger.debug("Stamina update relative(" + - consumption.type.toString() + ", " + consumption.amount + ") overridden to relative(" + - consumption.type.toString() + ", " + consumption.amount + ") by: " + listener.getKey()); + logger.debug("Stamina update relative({}, {}) overridden to relative({}, {}) by: {}", consumption.type.toString(), consumption.amount, consumption.type.toString(), consumption.amount, listener.getKey()); return currentStamina; } } int maxStamina = isCharacterStamina ? getMaxCharacterStamina() : getMaxVehicleStamina(); - logger.trace((isCharacterStamina ? "C " : "V ") + currentStamina + "/" + maxStamina + "\t" + currentState + "\t" + - (isPlayerMoving() ? "moving" : " ") + "\t(" + consumption.type + "," + - consumption.amount + ")"); + logger.trace("{}{}/{}\t{}\t{}\t({},{})", isCharacterStamina ? "C " : "V ", currentStamina, maxStamina, currentState, isPlayerMoving() ? "moving" : " ", consumption.type, consumption.amount); int newStamina = currentStamina + consumption.amount; if (newStamina < 0) { @@ -272,9 +267,7 @@ public class StaminaManager extends BasePlayerManager { for (Map.Entry listener : beforeUpdateStaminaListeners.entrySet()) { int overriddenNewStamina = listener.getValue().onBeforeUpdateStamina(reason, newStamina, isCharacterStamina); if (overriddenNewStamina != newStamina) { - logger.debug("Stamina update absolute(" + - reason + ", " + newStamina + ") overridden to absolute(" + - reason + ", " + newStamina + ") by: " + listener.getKey()); + logger.debug("Stamina update absolute({}, {}) overridden to absolute({}, {}) by: {}", reason, newStamina, reason, newStamina, listener.getKey()); return currentStamina; } } @@ -450,8 +443,7 @@ public class StaminaManager extends BasePlayerManager { int currentVehicleStamina = getCurrentVehicleStamina(); int maxVehicleStamina = getMaxVehicleStamina(); if (moving || (currentCharacterStamina < maxCharacterStamina) || (currentVehicleStamina < maxVehicleStamina)) { - logger.trace("Player moving: " + moving + ", stamina full: " + - (currentCharacterStamina >= maxCharacterStamina) + ", recalculate stamina"); + logger.trace("Player moving: {}, stamina full: {}, recalculate stamina", moving, currentCharacterStamina >= maxCharacterStamina); boolean isCharacterStamina = true; Consumption consumption; @@ -499,7 +491,7 @@ public class StaminaManager extends BasePlayerManager { // For others recover after 1 seconds (5 ticks) - as official server does. staminaRecoverDelay++; consumption.amount = 0; - logger.trace("Delaying recovery: " + staminaRecoverDelay); + logger.trace("Delaying recovery: {}", staminaRecoverDelay); } } updateStaminaRelative(cachedSession, consumption, isCharacterStamina); @@ -514,8 +506,7 @@ public class StaminaManager extends BasePlayerManager { // TODO: fix drowning waverider entity int stamina = getCurrentCharacterStamina(); if (stamina < 10) { - logger.trace(getCurrentCharacterStamina() + "/" + - getMaxCharacterStamina() + "\t" + currentState); + logger.trace("{}/{}\t{}", getCurrentCharacterStamina(), getMaxCharacterStamina(), currentState); if (currentState != MotionState.MOTION_STATE_SWIM_IDLE) { killAvatar(cachedSession, cachedEntity, PlayerDieType.PLAYER_DIE_TYPE_DRAWN); } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index 613834f45..b1e47d9f4 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -93,7 +93,7 @@ public class ShopSystem extends BaseGameSystem { } this.shopChestData.put((int) chestId, list); }); - Grasscutter.getLogger().debug("Loaded " + chestMap.size() + " ShopChest entries."); + Grasscutter.getLogger().debug("Loaded {} ShopChest entries.", chestMap.size()); } catch (Exception e) { Grasscutter.getLogger().error("Unable to load ShopChest data.", e); } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 624a97fca..cd86e429f 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -82,12 +82,7 @@ public class InventorySystem extends BaseGameSystem { val avatarData = avatar.getSkillDepot(); if (avatarData == null) { Grasscutter.getLogger() - .error( - "Attempted to check constellation level for UID" - + player.getUid() - + "'s avatar " - + avatarId - + " but avatar has no skillDepot!"); + .error("Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", player.getUid(), avatarId); return 0; } int constItemId = avatarData.getTalentCostItemId(); diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index 03f14a824..1c6cbdc5b 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -30,7 +30,7 @@ public abstract class Plugin { @SuppressWarnings("unused") private void initializePlugin(PluginIdentifier identifier, URLClassLoader classLoader) { if (this.identifier != null) { - Grasscutter.getLogger().warn(this.identifier.name + " had a reinitialization attempt."); + Grasscutter.getLogger().warn("{} had a reinitialization attempt.", this.identifier.name); return; } @@ -45,7 +45,7 @@ public abstract class Plugin { if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) { Grasscutter.getLogger() - .warn("Failed to create plugin data folder for " + this.identifier.name); + .warn("Failed to create plugin data folder for {}", this.identifier.name); } } diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 343783450..f37f57ebe 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -887,7 +887,7 @@ public class SceneScriptManager { } } catch (Throwable throwable) { Grasscutter.getLogger() - .error("Condition Trigger " + params.type + " triggered exception", throwable); + .error("Condition Trigger {} triggered exception", params.type, throwable); } finally { // make sure it is removed ScriptLoader.getScriptLib().removeSceneScriptManager(); @@ -913,7 +913,7 @@ public class SceneScriptManager { return false; } catch (Throwable ex) { Grasscutter.getLogger() - .error("Condition Trigger " + trigger.getName() + " triggered exception", ex); + .error("Condition Trigger {} triggered exception", trigger.getName(), ex); return false; } finally { ScriptLoader.getScriptLib().removeCurrentGroup(); diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index 68e1467d0..16bc5ac14 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -73,9 +73,7 @@ public class SceneBlock { SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint()); } catch (ScriptException exception) { Grasscutter.getLogger() - .error( - "An error occurred while loading block " + this.id + " in scene " + sceneId, - exception); + .error("An error occurred while loading block {} in scene {}", this.id, sceneId, exception); } Grasscutter.getLogger().trace("Successfully loaded block {} in scene {}.", this.id, sceneId); return this; diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index 5c9a93dba..0c2c253d8 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -168,8 +168,7 @@ public final class SceneGroup { this.suites.forEach(i -> i.init(this)); } catch (ScriptException e) { Grasscutter.getLogger() - .error( - "An error occurred while loading group " + this.id + " in scene " + sceneId + ".", e); + .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e); } catch (LuaError luaError) { Grasscutter.getLogger() .error( diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java b/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java index 93038eec2..abe23d78f 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneMeta.java @@ -29,7 +29,7 @@ public class SceneMeta { CompiledScript cs = ScriptLoader.getScript("Scene/" + sceneId + "/scene" + sceneId + ".lua"); if (cs == null) { - Grasscutter.getLogger().warn("No script found for scene " + sceneId); + Grasscutter.getLogger().warn("No script found for scene {}", sceneId); return null; } diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index 6d747797b..0cdeb63cd 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -41,7 +41,7 @@ public final class GameServerPacketHandler { // Debug Grasscutter.getLogger() - .debug("Registered " + this.handlers.size() + " " + handlerClass.getSimpleName() + "s"); + .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName()); } public void handle(GameSession session, int opcode, byte[] header, byte[] payload) { @@ -91,11 +91,7 @@ public final class GameServerPacketHandler { if (GAME_INFO.logPackets == ServerDebugMode.MISSING || GAME_INFO.logPackets == ServerDebugMode.ALL) { Grasscutter.getLogger() - .info( - "Unhandled packet (" - + opcode - + "): " - + emu.grasscutter.net.packet.PacketOpcodesUtils.getOpcodeName(opcode)); + .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); } } } diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index fa0d1a357..160644407 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -99,7 +99,7 @@ public class GameSession implements GameSessionManager.KcpChannel { public void logPacket(String sendOrRecv, int opcode, byte[] payload) { Grasscutter.getLogger() - .info(sendOrRecv + ": " + PacketOpcodesUtils.getOpcodeName(opcode) + " (" + opcode + ")"); + .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode); if (GAME_INFO.isShowPacketPayload) System.out.println(Utils.bytesToHex(payload)); } diff --git a/src/main/java/emu/grasscutter/server/http/HttpServer.java b/src/main/java/emu/grasscutter/server/http/HttpServer.java index e52e389d4..721c811bf 100644 --- a/src/main/java/emu/grasscutter/server/http/HttpServer.java +++ b/src/main/java/emu/grasscutter/server/http/HttpServer.java @@ -66,8 +66,7 @@ public final class HttpServer { this.javalin.exception(Exception.class, (exception, ctx) -> { ctx.status(500).result("Internal server error. %s" .formatted(exception.getMessage())); - Grasscutter.getLogger().debug("Exception thrown: " + - exception.getMessage(), exception); + Grasscutter.getLogger().debug("Exception thrown: {}", exception.getMessage(), exception); }); } diff --git a/src/main/java/emu/grasscutter/server/http/documentation/RootRequestHandler.java b/src/main/java/emu/grasscutter/server/http/documentation/RootRequestHandler.java index 65b00364d..fee90c4bd 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/RootRequestHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/RootRequestHandler.java @@ -18,7 +18,7 @@ final class RootRequestHandler implements DocumentationHandler { try { t = Files.readString(templatePath); } catch (IOException ignored) { - Grasscutter.getLogger().warn("File does not exist: " + templatePath); + Grasscutter.getLogger().warn("File does not exist: {}", templatePath); } this.template = t; } diff --git a/src/main/java/emu/grasscutter/server/http/handlers/AnnouncementsHandler.java b/src/main/java/emu/grasscutter/server/http/handlers/AnnouncementsHandler.java index edee6909a..c35703bb1 100644 --- a/src/main/java/emu/grasscutter/server/http/handlers/AnnouncementsHandler.java +++ b/src/main/java/emu/grasscutter/server/http/handlers/AnnouncementsHandler.java @@ -22,7 +22,7 @@ public final class AnnouncementsHandler implements Router { data = FileUtils.readToString(DataLoader.load("GameAnnouncement.json")); } catch (Exception e) { if (e.getClass() == IOException.class) { - Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n" + e); + Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n{}", e); } } } else if (Objects.equals( @@ -31,7 +31,7 @@ public final class AnnouncementsHandler implements Router { data = FileUtils.readToString(DataLoader.load("GameAnnouncementList.json")); } catch (Exception e) { if (e.getClass() == IOException.class) { - Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n" + e); + Grasscutter.getLogger().info("Unable to read file 'GameAnnouncementList.json'. \n{}", e); } } } else { @@ -77,7 +77,7 @@ public final class AnnouncementsHandler implements Router { ctx.contentType(fromExtension != null ? fromExtension : ContentType.APPLICATION_OCTET_STREAM); ctx.result(filestream.readAllBytes()); } catch (Exception e) { - Grasscutter.getLogger().warn("File does not exist: " + ctx.path()); + Grasscutter.getLogger().warn("File does not exist: {}", ctx.path()); ctx.status(404); } } diff --git a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java index 2edc529e1..70e3f053a 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java +++ b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java @@ -38,13 +38,11 @@ public final class HttpJsonResponse implements Handler { && Arrays.stream(missingRoutes) .anyMatch(x -> Objects.equals(x, ctx.endpointHandlerPath()))) { Grasscutter.getLogger() - .info( - translate( - "messages.dispatch.request", - Utils.address(ctx), - ctx.method(), - ctx.endpointHandlerPath()) - + (DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : "")); + .info("{}{}", translate( + "messages.dispatch.request", + Utils.address(ctx), + ctx.method(), + ctx.endpointHandlerPath()), DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""); } ctx.result(response); } diff --git a/src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java b/src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java index 7e65e0b48..5061c001b 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java +++ b/src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java @@ -17,7 +17,7 @@ public class WebStaticVersionResponse implements Handler { ctx.result(filestream.readAllBytes()); } catch (Exception e) { if (DISPATCH_INFO.logRequests == Grasscutter.ServerDebugMode.MISSING) { - Grasscutter.getLogger().warn("Webstatic File Missing: " + path); + Grasscutter.getLogger().warn("Webstatic File Missing: {}", path); } ctx.status(404); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java index 6489b140a..ffd1724f7 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -129,13 +129,7 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { int maxDelay = 200; long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond; Grasscutter.getLogger() - .trace( - "MOTION_FALL_ON_GROUND received after " - + actualDelay - + "/" - + maxDelay - + "ms." - + (actualDelay > maxDelay ? " Discard" : "")); + .trace("MOTION_FALL_ON_GROUND received after {}/{}ms.{}", actualDelay, maxDelay, actualDelay > maxDelay ? " Discard" : ""); if (actualDelay > maxDelay) { return; } @@ -161,20 +155,9 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { } if (damageFactor > 0) { Grasscutter.getLogger() - .debug( - currentHP - + "/" - + maxHP - + "\tLandingSpeed: " - + cachedLandingSpeed - + "\tDamageFactor: " - + damageFactor - + "\tDamage: " - + damage - + "\tNewHP: " - + newHP); + .debug("{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", currentHP, maxHP, cachedLandingSpeed, damageFactor, damage, newHP); } else { - Grasscutter.getLogger().trace(currentHP + "/" + maxHP + "\tLandingSpeed: 0\tNo damage"); + Grasscutter.getLogger().trace("{}/{}\tLandingSpeed: 0\tNo damage", currentHP, maxHP); } entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, newHP); entity diff --git a/src/main/java/emu/grasscutter/task/TaskMap.java b/src/main/java/emu/grasscutter/task/TaskMap.java index f9da26241..af98a46ea 100644 --- a/src/main/java/emu/grasscutter/task/TaskMap.java +++ b/src/main/java/emu/grasscutter/task/TaskMap.java @@ -155,12 +155,11 @@ public final class TaskMap { } } else { Grasscutter.getLogger() - .error("Class " + annotated.getName() + " is not a TaskHandler!"); + .error("Class {} is not a TaskHandler!", annotated.getName()); } } catch (Exception exception) { Grasscutter.getLogger() - .error( - "Failed to register task handler for " + annotated.getSimpleName(), exception); + .error("Failed to register task handler for {}", annotated.getSimpleName(), exception); } }); try { diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index 35b9a4e54..5c89cd733 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -314,10 +314,10 @@ public final class Tools { var path = GachaHandler.getGachaMappingsPath(); if (!Files.exists(path)) { try { - Grasscutter.getLogger().debug("Creating default '" + path + "' data"); + Grasscutter.getLogger().debug("Creating default '{}' data", path); Tools.createGachaMappings(path); } catch (Exception exception) { - Grasscutter.getLogger().warn("Failed to create gacha mappings. \n" + exception); + Grasscutter.getLogger().warn("Failed to create gacha mappings. \n{}", exception); } } } @@ -342,7 +342,7 @@ public final class Tools { Files.createDirectories(location.getParent()); Files.writeString(location, sb); - Grasscutter.getLogger().debug("Mappings generated to " + location); + Grasscutter.getLogger().debug("Mappings generated to {}", location); } public static List getAvailableLanguage() { diff --git a/src/main/java/emu/grasscutter/utils/FileUtils.java b/src/main/java/emu/grasscutter/utils/FileUtils.java index 0b1ab4fd1..21566bd75 100644 --- a/src/main/java/emu/grasscutter/utils/FileUtils.java +++ b/src/main/java/emu/grasscutter/utils/FileUtils.java @@ -41,7 +41,7 @@ public final class FileUtils { break; default: Grasscutter.getLogger() - .error("Invalid URI scheme for class resources: " + uri.getScheme()); + .error("Invalid URI scheme for class resources: {}", uri.getScheme()); break; } } catch (URISyntaxException | IOException e) { @@ -49,7 +49,7 @@ public final class FileUtils { Grasscutter.getLogger().error("Failed to load jar?!"); } finally { DATA_DEFAULT_PATH = path; - Grasscutter.getLogger().debug("Setting path for default data: " + path.toAbsolutePath()); + Grasscutter.getLogger().debug("Setting path for default data: {}", path.toAbsolutePath()); } // Setup Resources path @@ -82,10 +82,10 @@ public final class FileUtils { path = excelBinOutput.get().getParent(); if (path == null) path = root; Grasscutter.getLogger() - .debug("Resources will be loaded from \"" + resources + "/" + path + "\""); + .debug("Resources will be loaded from \"" + resources + "/{}\"", path); } else { Grasscutter.getLogger() - .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); + .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); } } catch (IOException e) { Grasscutter.getLogger().error("Failed to scan resources zip \"" + resources + "\""); @@ -176,7 +176,7 @@ public final class FileUtils { try { Files.write(path, bytes); } catch (IOException e) { - Grasscutter.getLogger().warn("Failed to write file: " + dest); + Grasscutter.getLogger().warn("Failed to write file: {}", dest); } } @@ -188,7 +188,7 @@ public final class FileUtils { try { return Files.readAllBytes(path); } catch (IOException e) { - Grasscutter.getLogger().warn("Failed to read file: " + path); + Grasscutter.getLogger().warn("Failed to read file: {}", path); } return new byte[0]; @@ -202,8 +202,8 @@ public final class FileUtils { try (InputStream is = Grasscutter.class.getResourceAsStream(resourcePath)) { return is.readAllBytes(); } catch (Exception exception) { - Grasscutter.getLogger().warn("Failed to read resource: " + resourcePath); - Grasscutter.getLogger().debug("Failed to load resource: " + resourcePath, exception); + Grasscutter.getLogger().warn("Failed to read resource: {}", resourcePath); + Grasscutter.getLogger().debug("Failed to load resource: {}", resourcePath, exception); } return new byte[0]; @@ -218,7 +218,7 @@ public final class FileUtils { byte[] resource = FileUtils.readResource(resourcePath); FileUtils.write(destination, resource); } catch (Exception exception) { - Grasscutter.getLogger().warn("Failed to copy resource: " + resourcePath + "\n" + exception); + Grasscutter.getLogger().warn("Failed to copy resource: {}\n{}", resourcePath, exception); } } diff --git a/src/main/java/emu/grasscutter/utils/TsvUtils.java b/src/main/java/emu/grasscutter/utils/TsvUtils.java index a61d75548..16fc75941 100644 --- a/src/main/java/emu/grasscutter/utils/TsvUtils.java +++ b/src/main/java/emu/grasscutter/utils/TsvUtils.java @@ -228,12 +228,10 @@ public final class TsvUtils { return tree.toClass(classType, null); } catch (Exception e) { Grasscutter.getLogger() - .warn( - "Error deserializing an instance of class " - + classType.getCanonicalName()); - Grasscutter.getLogger().warn("At token #" + t + " of #" + m); - Grasscutter.getLogger().warn("Header names are: " + headerNames); - Grasscutter.getLogger().warn("Tokens are: " + tokens); + .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + Grasscutter.getLogger().warn("At token #{} of #{}", t, m); + Grasscutter.getLogger().warn("Header names are: {}", headerNames); + Grasscutter.getLogger().warn("Tokens are: {}", tokens); Grasscutter.getLogger().warn("Stacktrace is: ", e); // System.out.println("Error deserializing an instance of class // "+classType.getCanonicalName()); @@ -247,7 +245,7 @@ public final class TsvUtils { }) .toList(); } catch (Exception e) { - Grasscutter.getLogger().error("Error loading file '" + filename + "' - Stacktrace is: ", e); + Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } } @@ -285,12 +283,10 @@ public final class TsvUtils { return obj; } catch (Exception e) { Grasscutter.getLogger() - .warn( - "Error deserializing an instance of class " - + classType.getCanonicalName()); - Grasscutter.getLogger().warn("At token #" + t + " of #" + m); - Grasscutter.getLogger().warn("Header names are: " + headerNames); - Grasscutter.getLogger().warn("Tokens are: " + tokens); + .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + Grasscutter.getLogger().warn("At token #{} of #{}", t, m); + Grasscutter.getLogger().warn("Header names are: {}", headerNames); + Grasscutter.getLogger().warn("Tokens are: {}", tokens); Grasscutter.getLogger().warn("Stacktrace is: ", e); return null; } @@ -298,17 +294,14 @@ public final class TsvUtils { .toList(); } catch (NoSuchFileException e) { Grasscutter.getLogger() - .error( - "Error loading file '" - + filename - + "' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable."); + .error("Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", filename); return null; } catch (IOException e) { - Grasscutter.getLogger().error("Error loading file '" + filename + "' - Stacktrace is: ", e); + Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } catch (NoSuchMethodException e) { Grasscutter.getLogger() - .error("Error loading file '" + filename + "' - Class is missing NoArgsConstructor"); + .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename); return null; } } @@ -336,7 +329,7 @@ public final class TsvUtils { throws Exception { val pair = getAllArgsConstructor(classType); if (pair == null) { - Grasscutter.getLogger().error("No AllArgsContructor found for class: " + classType); + Grasscutter.getLogger().error("No AllArgsContructor found for class: {}", classType); return null; } val constructor = pair.left(); @@ -405,27 +398,21 @@ public final class TsvUtils { return constructor.newInstance(args); } catch (Exception e) { Grasscutter.getLogger() - .warn( - "Error deserializing an instance of class " - + classType.getCanonicalName() - + " : " - + constructor.getName()); - Grasscutter.getLogger().warn("At token #" + t + " of #" + m); + .warn("Error deserializing an instance of class {} : {}", classType.getCanonicalName(), constructor.getName()); + Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger() - .warn("Arg names are: " + Arrays.toString(conArgNames)); + .warn("Arg names are: {}", Arrays.toString(conArgNames)); Grasscutter.getLogger() - .warn("Arg types are: " + Arrays.toString(argTypes)); + .warn("Arg types are: {}", Arrays.toString(argTypes)); Grasscutter.getLogger() - .warn("Default Args are: " + Arrays.toString(defaultArgs)); - Grasscutter.getLogger().warn("Args are: " + Arrays.toString(args)); - Grasscutter.getLogger().warn("Header names are: " + headerNames); + .warn("Default Args are: {}", Arrays.toString(defaultArgs)); + Grasscutter.getLogger().warn("Args are: {}", Arrays.toString(args)); + Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger() - .warn( - "Header types are: " - + IntStream.of(argPositions) - .mapToObj(i -> (i >= 0) ? argTypes[i] : null) - .toList()); - Grasscutter.getLogger().warn("Tokens are: " + tokens); + .warn("Header types are: {}", IntStream.of(argPositions) + .mapToObj(i -> (i >= 0) ? argTypes[i] : null) + .toList()); + Grasscutter.getLogger().warn("Tokens are: {}", tokens); Grasscutter.getLogger().warn("Stacktrace is: ", e); return null; } @@ -433,7 +420,7 @@ public final class TsvUtils { .toList(); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading file '" + filename + "' - Stacktrace is: ", e); + .error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } }) @@ -582,23 +569,14 @@ public final class TsvUtils { // System.out.println("Exception while setting field "+name+" for class "+objClass+" // - "+e); Grasscutter.getLogger() - .error( - "Exception while setting field " - + name - + " (" - + field.classType - + ")" - + " for class " - + objClass - + " - ", - e); + .error("Exception while setting field {} ({}) for class {} - ", name, field.classType, objClass, e); } }); return obj; } catch (Exception e) { // System.out.println("Exception while creating object of class "+objClass+" - "+e); Grasscutter.getLogger() - .error("Exception while creating object of class " + objClass + " - ", e); + .error("Exception while creating object of class {} - ", objClass, e); return null; } } diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index 435d6d0f1..e4fc8c0e7 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -69,7 +69,7 @@ public final class Utils { public static void logByteArray(byte[] array) { ByteBuf b = Unpooled.wrappedBuffer(array); - Grasscutter.getLogger().info("\n" + ByteBufUtil.prettyHexDump(b)); + Grasscutter.getLogger().info("\n{}", ByteBufUtil.prettyHexDump(b)); b.release(); } @@ -143,7 +143,7 @@ public final class Utils { public static boolean copyFromResources(String resource, String destination) { try (InputStream stream = Grasscutter.class.getResourceAsStream(resource)) { if (stream == null) { - Grasscutter.getLogger().warn("Could not find resource: " + resource); + Grasscutter.getLogger().warn("Could not find resource: {}", resource); return false; } @@ -151,7 +151,7 @@ public final class Utils { return true; } catch (Exception exception) { Grasscutter.getLogger() - .warn("Unable to copy resource " + resource + " to " + destination, exception); + .warn("Unable to copy resource {} to {}", resource, destination, exception); return false; } } diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 8e64dc98a..e079dfa60 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -44,7 +44,7 @@ public final class Language { .forEach(entry -> putFlattenedKey(translations, entry.getKey(), entry.getValue())); } catch (Exception exception) { Grasscutter.getLogger() - .warn("Failed to load language file: " + description.getLanguageCode(), exception); + .warn("Failed to load language file: {}", description.getLanguageCode(), exception); } } @@ -99,7 +99,7 @@ public final class Language { try { return translated.formatted(args); } catch (Exception exception) { - Grasscutter.getLogger().error("Failed to format string: " + key, exception); + Grasscutter.getLogger().error("Failed to format string: {}", key, exception); return translated; } } @@ -134,7 +134,7 @@ public final class Language { try { return translated.formatted(args); } catch (Exception exception) { - Grasscutter.getLogger().error("Failed to format string: " + key, exception); + Grasscutter.getLogger().error("Failed to format string: {}", key, exception); return translated; } } @@ -194,7 +194,7 @@ public final class Language { if (file == null) { // Provided fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: " + fileName + ", falling back to: " + fallback); + .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback); actualLanguageCode = fallbackLanguageCode; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -205,7 +205,7 @@ public final class Language { if (file == null) { // Fallback the fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: " + fallback + ", falling back to: en-US.json"); + .warn("Failed to load language file: {}, falling back to: en-US.json", fallback); actualLanguageCode = "en-US"; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -241,7 +241,7 @@ public final class Language { m -> (int) Long.parseLong(m.group(1)), m -> m.group(2).replace("\\\"", "\"")))); } catch (Exception e) { - Grasscutter.getLogger().error("Error loading textmap: " + language); + Grasscutter.getLogger().error("Error loading textmap: {}", language); Grasscutter.getLogger().error(e.toString()); } return output; @@ -361,7 +361,7 @@ public final class Language { } catch (NoSuchFileException ignored) { // Cache doesn't exist, generate it. } catch (Exception exception) { - Grasscutter.getLogger().error("Error loading textmaps cache: " + exception); + Grasscutter.getLogger().error("Error loading textmaps cache: {}", exception); } // Regenerate cache From d5ad077ce1e09404ed3a55be07404bc9e76923fc Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:37:06 -0300 Subject: [PATCH 24/59] fix: integer division in floating point --- .../java/emu/grasscutter/game/managers/SatiationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/managers/SatiationManager.java b/src/main/java/emu/grasscutter/game/managers/SatiationManager.java index 29e992863..71d1fea21 100644 --- a/src/main/java/emu/grasscutter/game/managers/SatiationManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SatiationManager.java @@ -98,7 +98,7 @@ public class SatiationManager extends BasePlayerManager { * Player Updates ********************/ public synchronized void updateSingleAvatar(Avatar avatar, float givenTime) { - float time = (player.getClientTime() / 1000) + givenTime; + float time = ((float) player.getClientTime() / 1000) + givenTime; player.getSession().send(new PacketAvatarPropNotify(avatar)); player.getSession().send(new PacketAvatarSatiationDataNotify(time, avatar)); } From 6e3b3b20a0f75c0bc12e882ebb630e75748c8f90 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:38:33 -0300 Subject: [PATCH 25/59] refactor: implicit cast from double to float may be lossy --- .../game/managers/stamina/StaminaManager.java | 16 ++++++++-------- .../emu/grasscutter/game/world/Position.java | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java b/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java index 79366e79f..037aab174 100644 --- a/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java +++ b/src/main/java/emu/grasscutter/game/managers/stamina/StaminaManager.java @@ -475,7 +475,7 @@ public class StaminaManager extends BasePlayerManager { if (consumption.amount < 0 && isCharacterStamina) { // Do not apply reduction factor when recovering stamina if (player.getTeamManager().getTeamResonances().contains(10301)) { - consumption.amount *= 0.85f; + consumption.amount *= (int) 0.85f; } } // Delay 1 seconds before starts recovering stamina @@ -543,8 +543,8 @@ public class StaminaManager extends BasePlayerManager { consumption.amount = ConsumptionType.CLIMBING.amount; } // Climbing specific reductions - consumption.amount *= getFoodCostReductionFactor(ClimbFoodReductionMap); - consumption.amount *= getTalentCostReductionFactor(ClimbTalentReductionMap); + consumption.amount *= (int) getFoodCostReductionFactor(ClimbFoodReductionMap); + consumption.amount *= (int) getTalentCostReductionFactor(ClimbTalentReductionMap); return consumption; } @@ -560,8 +560,8 @@ public class StaminaManager extends BasePlayerManager { consumption.amount = ConsumptionType.SWIM_DASH.amount; } // Swimming specific reductions - consumption.amount *= getFoodCostReductionFactor(SwimFoodReductionMap); - consumption.amount *= getTalentCostReductionFactor(SwimTalentReductionMap); + consumption.amount *= (int) getFoodCostReductionFactor(SwimFoodReductionMap); + consumption.amount *= (int) getTalentCostReductionFactor(SwimTalentReductionMap); return consumption; } @@ -571,7 +571,7 @@ public class StaminaManager extends BasePlayerManager { consumption.type = ConsumptionType.DASH; consumption.amount = ConsumptionType.DASH.amount; // Dashing specific reductions - consumption.amount *= getFoodCostReductionFactor(DashFoodReductionMap); + consumption.amount *= (int) getFoodCostReductionFactor(DashFoodReductionMap); } return consumption; } @@ -583,8 +583,8 @@ public class StaminaManager extends BasePlayerManager { } Consumption consumption = new Consumption(ConsumptionType.FLY); // Flying specific reductions - consumption.amount *= getFoodCostReductionFactor(FlyFoodReductionMap); - consumption.amount *= getTalentCostReductionFactor(FlyTalentReductionMap); + consumption.amount *= (int) getFoodCostReductionFactor(FlyFoodReductionMap); + consumption.amount *= (int) getTalentCostReductionFactor(FlyTalentReductionMap); return consumption; } diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 780a6c213..249f6733e 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -143,8 +143,8 @@ public class Position implements Serializable { /** In radians */ public Position translate(float dist, float angle) { - this.x += dist * Math.sin(angle); - this.y += dist * Math.cos(angle); + this.x += (float) (dist * Math.sin(angle)); + this.y += (float) (dist * Math.cos(angle)); return this; } @@ -173,8 +173,8 @@ public class Position implements Serializable { public Position translateWithDegrees(float dist, float angle) { angle = (float) Math.toRadians(angle); - this.x += dist * Math.sin(angle); - this.y += -dist * Math.cos(angle); + this.x += (float) (dist * Math.sin(angle)); + this.y += (float) (-dist * Math.cos(angle)); return this; } From 4f1ad7b57634ebbde1bc87dd2769c0a36d93b8d2 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:39:21 -0300 Subject: [PATCH 26/59] perf: Call to 'asList()' with only one argument --- src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java | 2 +- src/main/java/emu/grasscutter/game/world/Scene.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java index 649478655..6b4eb450f 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java @@ -27,7 +27,7 @@ public class AbilityMixinData implements Serializable { List list = (new Gson()).fromJson(modifierName, listType); return list; } else { - return Arrays.asList(modifierName.getAsString()); + return Collections.singletonList(modifierName.getAsString()); } } } diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 993b2d42a..53f028746 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -392,7 +392,7 @@ public class Scene { } public void updateEntity(GameEntity entity, VisionType type) { - this.broadcastPacket(new PacketSceneEntityUpdateNotify(Arrays.asList(entity), type)); + this.broadcastPacket(new PacketSceneEntityUpdateNotify(Collections.singletonList(entity), type)); } private static List> chopped(List list, final int L) { From e4123f47d60e2e85bdc35aa550615a43a268c3a6 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:39:46 -0300 Subject: [PATCH 27/59] perf: class initializer may be static --- src/main/java/emu/grasscutter/game/systems/InventorySystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index cd86e429f..cdbfc22cd 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -25,7 +25,7 @@ import lombok.val; public class InventorySystem extends BaseGameSystem { private static final Int2IntMap weaponRefundMaterials = new Int2IntArrayMap(); - { + static { // Use a sorted map, use exp as key to sort by exp // We want to have weaponRefundMaterials as (id, exp) in descending exp order var temp = new Int2IntRBTreeMap(Collections.reverseOrder()); From b7735295f1e8720d73d6a08d6cd24e7eabba7a9e Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:42:06 -0300 Subject: [PATCH 28/59] perf: `count > 0` can be anyMatch --- src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java index 5bb4b35fc..6a0f4e1dd 100644 --- a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java +++ b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java @@ -57,7 +57,7 @@ public class KahnsSort { } } - if (degreeList.values().stream().filter(value -> value != 0).count() != 0) + if (degreeList.values().stream().anyMatch(value -> value != 0)) return null; // Loop found return orderedList; From 33d5c5238a11e33bf7957647733e8c51e5a73498 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:42:43 -0300 Subject: [PATCH 29/59] perf: `findAny().isPresent()` is cleaner here --- src/main/java/emu/grasscutter/game/player/TeamManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index d808fbf44..f79cb422d 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -83,7 +83,7 @@ public final class TeamManager extends BasePlayerDataManager { int embryoId = 0; // add from default - if (Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).count() > 0) { + if (Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).findAny().isPresent()) { List teamAbilties = Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).toList(); for (String skill : teamAbilties) { From 1424405c64ccf85c97269e29e799b7e9dceae8d7 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:43:31 -0300 Subject: [PATCH 30/59] perf: fix redundant addAll --- .../factory/KillMonsterTimeChallengeFactoryHandler.java | 3 +-- src/main/java/emu/grasscutter/game/mail/MailHandler.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java index f2d4c63ae..8b17ac2b2 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java @@ -29,8 +29,7 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH Scene scene, SceneGroup group) { val realGroup = scene.getScriptManager().getGroupById(groupId); - val challengeTriggers = new ArrayList(); - challengeTriggers.addAll(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); + val challengeTriggers = new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId); val challengeType = challengeData.getChallengeType(); diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index 45b3373f6..2862f6ebe 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -58,8 +58,7 @@ public class MailHandler extends BasePlayerManager { } public void deleteMail(List mailList) { - List sortedMailList = new ArrayList<>(); - sortedMailList.addAll(mailList); + List sortedMailList = new ArrayList<>(mailList); sortedMailList.sort(Collections.reverseOrder()); List deleted = new ArrayList<>(); From 1e2ccc9fc63f63fecb04385bde3bb98f6f163237 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:44:23 -0300 Subject: [PATCH 31/59] perf: we can chain append here --- src/main/java/emu/grasscutter/tools/Tools.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index 5c89cd733..a8e62ab54 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -73,7 +73,7 @@ public final class Tools { var h = new Object() { void newLine(String line) { - handbookBuilders.forEach(b -> b.append(line + "\n")); + handbookBuilders.forEach(b -> b.append(line).append("\n")); } void newSection(String title) { @@ -91,7 +91,7 @@ public final class Tools { j--; // Retry the action. Language.loadTextMaps(true); } - handbookBuilders.get(i).append(s + "\n"); + handbookBuilders.get(i).append(s).append("\n"); } } @@ -127,7 +127,7 @@ public final class Tools { for (int i = 0; i < TextStrings.NUM_LANGUAGES; i++) { String desc = languages.get(i).get(descKey).replace("\n", "\n\t\t\t\t").replace("\t", " "); - handbookBuilders.get(i).append(label + desc + "\n"); + handbookBuilders.get(i).append(label).append(desc).append("\n"); } } // Avatars @@ -334,7 +334,7 @@ public final class Tools { locale)) { // Some locales fallback to en-us, we don't want to redefine en-us with // vietnamese strings sb.append("\t\"%s\": ".formatted(locale)); - sb.append(jsons.get(i).replace("\n", "\n\t") + ",\n"); + sb.append(jsons.get(i).replace("\n", "\n\t")).append(",\n"); } } sb.setLength(sb.length() - 2); // Delete trailing ",\n" From aeadf6bba71f3e70d36fea3b349235504bea4a2f Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:45:05 -0300 Subject: [PATCH 32/59] perf: equals "" can be isEmpty here --- src/main/java/emu/grasscutter/scripts/data/SceneGroup.java | 2 +- src/main/java/emu/grasscutter/server/game/GameServer.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index 0c2c253d8..de1a0ef8c 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -89,7 +89,7 @@ public final class SceneGroup { this.bindings = ScriptLoader.getEngine().createBindings(); CompiledScript cs; - if (overrideScriptPath != null && !overrideScriptPath.equals("")) { + if (overrideScriptPath != null && !overrideScriptPath.isEmpty()) { cs = ScriptLoader.getScript(overrideScriptPath, true); } else { cs = diff --git a/src/main/java/emu/grasscutter/server/game/GameServer.java b/src/main/java/emu/grasscutter/server/game/GameServer.java index ecd6b1425..7c09a3037 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServer.java +++ b/src/main/java/emu/grasscutter/server/game/GameServer.java @@ -184,7 +184,7 @@ public final class GameServer extends KcpServer implements Iterable { private static InetSocketAddress getAdapterInetSocketAddress() { InetSocketAddress inetSocketAddress; - if (GAME_INFO.bindAddress.equals("")) { + if (GAME_INFO.bindAddress.isEmpty()) { inetSocketAddress = new InetSocketAddress(GAME_INFO.bindPort); } else { inetSocketAddress = new InetSocketAddress(GAME_INFO.bindAddress, GAME_INFO.bindPort); From 7ee644c794c219bdc9bddcfb5d19a8fd39c02b5f Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:46:29 -0300 Subject: [PATCH 33/59] perf: add Serial annotation here --- .../java/emu/grasscutter/data/binout/AbilityMixinData.java | 3 +++ src/main/java/emu/grasscutter/data/binout/AbilityModifier.java | 3 +++ src/main/java/emu/grasscutter/game/world/GridPosition.java | 1 + src/main/java/emu/grasscutter/game/world/Position.java | 3 +++ 4 files changed, 10 insertions(+) diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java index 6b4eb450f..9fa16b9ca 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java @@ -3,10 +3,13 @@ package emu.grasscutter.data.binout; import com.google.gson.*; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; + +import java.io.Serial; import java.io.Serializable; import java.util.*; public class AbilityMixinData implements Serializable { + @Serial private static final long serialVersionUID = -2001232313615923575L; public enum Type { diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index fe08cccf5..099bb49ce 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -3,10 +3,13 @@ package emu.grasscutter.data.binout; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.game.props.ElementType; + +import java.io.Serial; import java.io.Serializable; import lombok.ToString; public class AbilityModifier implements Serializable { + @Serial private static final long serialVersionUID = -2001232313615923575L; public State state; diff --git a/src/main/java/emu/grasscutter/game/world/GridPosition.java b/src/main/java/emu/grasscutter/game/world/GridPosition.java index b4a47b43c..bd0e2e2ed 100644 --- a/src/main/java/emu/grasscutter/game/world/GridPosition.java +++ b/src/main/java/emu/grasscutter/game/world/GridPosition.java @@ -8,6 +8,7 @@ import lombok.*; @Entity public final class GridPosition implements Serializable { + @Serial private static final long serialVersionUID = -2001232300615923575L; @Getter @Setter private int x; diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 249f6733e..0c8483a13 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -5,6 +5,8 @@ import com.google.gson.annotations.SerializedName; import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.VectorOuterClass.Vector; import emu.grasscutter.utils.Utils; + +import java.io.Serial; import java.io.Serializable; import java.util.List; import lombok.*; @@ -13,6 +15,7 @@ import lombok.experimental.Accessors; @Entity @Accessors(chain = true) public class Position implements Serializable { + @Serial private static final long serialVersionUID = -2001232313615923575L; public static final Position ZERO = new Position(0, 0, 0); From 8f4120fcd3a4ac1bc10c37c4f1cec13b8a86492f Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:52:49 -0300 Subject: [PATCH 34/59] refactor(lombok): add Getter where possible --- .../data/binout/AbilityEmbryoEntry.java | 10 +-- .../data/binout/AbilityModifierEntry.java | 16 ++--- .../data/binout/MainQuestData.java | 41 +++--------- .../data/binout/OpenConfigEntry.java | 27 ++------ .../data/binout/ScenePointEntry.java | 5 +- .../data/binout/config/ConfigLevelEntity.java | 13 ++-- .../data/binout/routes/RotAngleType.java | 3 +- .../data/binout/routes/RouteType.java | 3 +- .../grasscutter/data/common/CurveInfo.java | 14 +--- .../data/common/FightPropData.java | 14 +--- .../data/common/ItemParamData.java | 10 +-- .../data/common/ItemParamStringData.java | 11 +--- .../grasscutter/data/common/ItemUseData.java | 5 +- .../grasscutter/data/common/OpenCondData.java | 11 +--- .../data/common/PropGrowCurve.java | 10 +-- .../grasscutter/data/excels/CombineData.java | 51 ++++---------- .../data/excels/CookBonusData.java | 18 +---- .../excels/EnvAnimalGatherConfigData.java | 12 ++-- .../data/excels/EquipAffixData.java | 27 ++------ .../data/excels/FetterCharacterCardData.java | 6 +- .../grasscutter/data/excels/FetterData.java | 7 +- .../grasscutter/data/excels/GatherData.java | 16 ++--- .../data/excels/OpenStateData.java | 4 +- .../excels/RefreshPolicyExcelConfigData.java | 7 +- .../grasscutter/data/excels/RewardData.java | 7 +- .../data/excels/ShopGoodsData.java | 66 +++++-------------- .../data/excels/StatuePromoteData.java | 11 ++-- .../activity/ActivityCondExcelConfigData.java | 5 +- .../excels/activity/ActivityShopData.java | 7 +- .../data/excels/avatar/AvatarCostumeData.java | 16 ++--- .../data/excels/avatar/AvatarCurveData.java | 7 +- .../excels/avatar/AvatarFlycloakData.java | 6 +- .../data/excels/avatar/AvatarLevelData.java | 9 +-- .../data/excels/avatar/AvatarPromoteData.java | 32 +++------ .../data/excels/avatar/AvatarTalentData.java | 37 +++-------- .../data/excels/codex/CodexMaterialData.java | 14 +--- .../data/excels/codex/CodexQuestData.java | 21 ++---- .../data/excels/codex/CodexWeaponData.java | 16 ++--- .../dungeon/DungeonChallengeConfigData.java | 7 +- .../excels/dungeon/DungeonPassConfigData.java | 12 ++-- .../data/excels/quest/QuestData.java | 37 ++++++----- .../excels/reliquary/ReliquarySetData.java | 11 +--- .../data/excels/tower/TowerScheduleData.java | 23 ++----- .../data/excels/weapon/WeaponLevelData.java | 9 +-- .../data/excels/weapon/WeaponPromoteData.java | 31 +-------- .../data/excels/world/WeatherData.java | 23 +++---- .../data/excels/world/WorldLevelData.java | 6 +- .../emu/grasscutter/data/server/Grid.java | 15 +++-- .../grasscutter/database/DatabaseManager.java | 6 +- .../java/emu/grasscutter/game/Account.java | 57 +++++----------- .../emu/grasscutter/game/CoopRequest.java | 14 +--- .../ability/AbilityModifierController.java | 7 +- .../AchievementControlReturns.java | 3 +- .../TrialAvatarActivityHandler.java | 3 +- .../game/avatar/AvatarStorage.java | 7 +- .../game/battlepass/BattlePassMission.java | 11 +--- .../game/battlepass/BattlePassReward.java | 16 ++--- .../emu/grasscutter/game/chat/ChatSystem.java | 7 +- .../grasscutter/game/city/CityInfoData.java | 7 +- .../game/combine/CombineResult.java | 19 +----- .../game/combine/ReliquaryDecomposeEntry.java | 11 +--- .../emu/grasscutter/game/drop/DropData.java | 31 +-------- .../emu/grasscutter/game/drop/DropInfo.java | 10 +-- .../game/drop/DropSystemLegacy.java | 7 +- .../game/dungeons/DungeonDrop.java | 11 +--- .../game/dungeons/DungeonDropEntry.java | 23 +------ .../game/dungeons/DungeonEndStats.java | 9 +-- .../dungeons/challenge/DungeonChallenge.java | 6 +- .../dungeon_results/BaseDungeonResult.java | 5 +- .../enums/DungeonPassConditionType.java | 3 +- .../game/dungeons/enums/DungeonType.java | 3 +- .../game/dungeons/enums/SettleShowType.java | 3 +- .../grasscutter/game/entity/EntityAvatar.java | 7 +- .../grasscutter/game/entity/EntityItem.java | 7 +- .../EntitySolarIsotomaClientGadget.java | 3 +- .../grasscutter/game/entity/EntityWorld.java | 3 +- .../game/entity/gadget/GadgetContent.java | 6 +- .../entity/gadget/GadgetGatherObject.java | 6 +- .../entity/gadget/platform/BaseRoute.java | 11 ++-- .../entity/gadget/platform/ConfigRoute.java | 7 +- .../gadget/platform/PointArrayRoute.java | 5 +- .../game/expedition/ExpeditionRewardData.java | 7 +- .../expedition/ExpeditionRewardDataList.java | 5 +- .../game/expedition/ExpeditionRewardInfo.java | 5 +- .../grasscutter/game/friends/Friendship.java | 21 ++---- .../grasscutter/game/gacha/GachaRecord.java | 23 +------ .../grasscutter/game/gacha/GachaSystem.java | 7 +- .../grasscutter/game/inventory/BagTab.java | 3 +- .../grasscutter/game/inventory/EquipType.java | 3 +- .../grasscutter/game/inventory/GameItem.java | 5 +- .../grasscutter/game/inventory/Inventory.java | 7 +- .../grasscutter/game/inventory/ItemDef.java | 11 +--- .../game/inventory/ItemQuality.java | 3 +- .../grasscutter/game/inventory/ItemType.java | 3 +- .../game/inventory/MaterialType.java | 3 +- .../java/emu/grasscutter/game/mail/Mail.java | 12 ++-- .../grasscutter/game/mail/MailHandler.java | 7 +- .../managers/blossom/BlossomActivity.java | 12 ++-- .../game/managers/blossom/BlossomConfig.java | 5 +- .../game/managers/blossom/BlossomType.java | 7 +- .../managers/deforestation/HitTreeRecord.java | 12 ++-- .../game/managers/energy/EnergyDropEntry.java | 10 +-- .../game/managers/energy/EnergyDropInfo.java | 10 +-- .../energy/SkillParticleGenerationEntry.java | 10 +-- .../energy/SkillParticleGenerationInfo.java | 10 +-- .../managers/forging/ActiveForgeData.java | 31 ++------- .../game/managers/mapmark/MapMark.java | 29 +------- .../game/player/BasePlayerDataManager.java | 6 +- .../game/player/BasePlayerManager.java | 6 +- .../emu/grasscutter/game/player/Player.java | 2 +- .../game/player/PlayerBirthday.java | 10 +-- .../game/player/PlayerCollectionRecords.java | 10 +-- .../game/player/PlayerProgress.java | 5 +- .../emu/grasscutter/game/player/TeamInfo.java | 11 +--- .../grasscutter/game/props/ActionReason.java | 6 +- .../props/BattlePassMissionRefreshType.java | 6 +- .../game/props/BattlePassMissionStatus.java | 9 +-- .../game/props/CampTargetType.java | 7 +- .../grasscutter/game/props/ClimateType.java | 7 +- .../grasscutter/game/props/ElementType.java | 13 ++-- .../grasscutter/game/props/EnterReason.java | 6 +- .../grasscutter/game/props/EntityIdType.java | 6 +- .../grasscutter/game/props/EntityType.java | 6 +- .../grasscutter/game/props/FetterState.java | 6 +- .../grasscutter/game/props/FightProperty.java | 5 +- .../emu/grasscutter/game/props/GrowCurve.java | 6 +- .../game/props/ItemUseAction/ItemUseInt.java | 3 +- .../emu/grasscutter/game/props/ItemUseOp.java | 6 +- .../grasscutter/game/props/ItemUseTarget.java | 6 +- .../emu/grasscutter/game/props/LifeState.java | 6 +- .../grasscutter/game/props/MonsterType.java | 6 +- .../game/props/PlayerProperty.java | 5 +- .../grasscutter/game/props/RefreshType.java | 7 +- .../emu/grasscutter/game/props/SceneType.java | 6 +- .../game/props/ServerBuffType.java | 6 +- .../game/props/WatcherTriggerType.java | 6 +- .../grasscutter/game/props/WeaponType.java | 14 +--- .../grasscutter/game/quest/RewindData.java | 3 +- .../game/quest/enums/LogicType.java | 6 +- .../game/quest/enums/ParentQuestState.java | 6 +- .../game/quest/enums/QuestCond.java | 7 +- .../game/quest/enums/QuestContent.java | 7 +- .../game/quest/enums/QuestExec.java | 7 +- .../game/quest/enums/QuestGuideType.java | 6 +- .../game/quest/enums/QuestShowType.java | 6 +- .../game/quest/enums/QuestState.java | 5 +- .../game/quest/enums/QuestType.java | 6 +- .../game/quest/enums/ShowQuestGuideType.java | 6 +- .../emu/grasscutter/game/shop/ShopLimit.java | 18 +---- .../emu/grasscutter/game/shop/ShopSystem.java | 7 +- .../emu/grasscutter/game/shop/ShopTable.java | 11 +--- .../emu/grasscutter/game/talk/TalkExec.java | 3 +- .../game/tower/TowerLevelRecord.java | 15 +---- .../game/tower/TowerScheduleConfig.java | 15 +---- .../grasscutter/game/tower/TowerSystem.java | 7 +- .../grasscutter/game/world/GridPosition.java | 7 +- .../emu/grasscutter/game/world/Location.java | 4 +- .../emu/grasscutter/game/world/Position.java | 4 +- .../game/world/SpawnDataEntry.java | 39 ++++++----- .../emu/grasscutter/game/world/World.java | 5 +- .../game/world/WorldDataSystem.java | 7 +- .../grasscutter/net/packet/BasePacket.java | 17 ++--- .../grasscutter/plugin/api/ServerHelper.java | 18 ++--- .../scripts/SceneScriptManager.java | 21 ++---- .../grasscutter/scripts/data/SceneBlock.java | 5 +- .../grasscutter/scripts/data/SceneGroup.java | 15 +---- .../grasscutter/scripts/data/ScriptArgs.java | 16 ++--- .../server/dispatch/DispatchClient.java | 7 +- .../server/dispatch/DispatchServer.java | 7 +- .../server/event/EventHandler.java | 17 +++-- .../event/dispatch/QueryAllRegionsEvent.java | 6 +- .../dispatch/QueryCurrentRegionEvent.java | 6 +- .../event/entity/EntityCreationEvent.java | 7 +- .../event/entity/EntityDamageEvent.java | 7 +- .../server/event/entity/EntityDeathEvent.java | 5 +- .../server/event/entity/EntityMoveEvent.java | 13 +--- .../event/game/PlayerCreationEvent.java | 10 +-- .../game/ReceiveCommandFeedbackEvent.java | 7 +- .../server/event/game/ReceivePacketEvent.java | 14 +--- .../server/event/game/SendPacketEvent.java | 10 +-- .../server/event/internal/ServerLogEvent.java | 9 +-- .../event/internal/ServerStartEvent.java | 6 +- .../event/internal/ServerStopEvent.java | 6 +- .../player/PlayerCompleteQuestEvent.java | 3 +- .../event/player/PlayerEnterAreaEvent.java | 3 +- .../event/player/PlayerEnterDungeonEvent.java | 3 +- .../event/player/PlayerForgeItemEvent.java | 3 +- .../event/player/PlayerOpenChestEvent.java | 9 +-- .../event/player/PlayerReceiveMailEvent.java | 6 +- .../event/player/PlayerTeamDeathEvent.java | 3 +- .../event/player/PlayerUseFoodEvent.java | 5 +- .../server/event/types/EntityEvent.java | 5 +- .../server/event/types/PlayerEvent.java | 5 +- .../server/game/BaseGameSystem.java | 6 +- .../grasscutter/server/game/GameSession.java | 5 +- .../server/game/GameSessionManager.java | 5 +- .../server/http/dispatch/RegionHandler.java | 10 +-- .../server/scheduler/AsyncServerTask.java | 16 ++--- .../emu/grasscutter/utils/lang/Language.java | 11 ++-- .../utils/objects/ServerLogEventAppender.java | 7 +- 200 files changed, 708 insertions(+), 1401 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java index 43d5471c5..a7b1ee98a 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java @@ -1,5 +1,8 @@ package emu.grasscutter.data.binout; +import lombok.Getter; + +@Getter public class AbilityEmbryoEntry { private String name; private String[] abilities; @@ -11,11 +14,4 @@ public class AbilityEmbryoEntry { this.abilities = array; } - public String getName() { - return name; - } - - public String[] getAbilities() { - return abilities; - } } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java index 9087b94cc..8787b5304 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java @@ -1,12 +1,17 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; +import lombok.Getter; + import java.util.*; public class AbilityModifierEntry { public final List onModifierAdded; + @Getter public final List onThinkInterval; + @Getter public final List onRemoved; + @Getter private final String name; // Custom value public AbilityModifierEntry(String name) { @@ -16,19 +21,8 @@ public class AbilityModifierEntry { this.onRemoved = new ArrayList<>(); } - public String getName() { - return name; - } - public List getOnAdded() { return onModifierAdded; } - public List getOnThinkInterval() { - return onThinkInterval; - } - - public List getOnRemoved() { - return onRemoved; - } } diff --git a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java index da7b589c7..72e427294 100644 --- a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java +++ b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java @@ -5,53 +5,30 @@ import emu.grasscutter.data.GameData; import emu.grasscutter.game.quest.enums.QuestType; import java.util.*; import lombok.Data; +import lombok.Getter; public class MainQuestData { + @Getter private int id; private int ICLLDPJFIMA; + @Getter private int series; + @Getter private QuestType type; + @Getter private long titleTextMapHash; + @Getter private int[] suggestTrackMainQuestList; + @Getter private int[] rewardIdList; + @Getter private SubQuestData[] subQuests; + @Getter private List talks; private long[] preloadLuaList; - public int getId() { - return id; - } - - public int getSeries() { - return series; - } - - public QuestType getType() { - return type; - } - - public long getTitleTextMapHash() { - return titleTextMapHash; - } - - public int[] getSuggestTrackMainQuestList() { - return suggestTrackMainQuestList; - } - - public int[] getRewardIdList() { - return rewardIdList; - } - - public SubQuestData[] getSubQuests() { - return subQuests; - } - - public List getTalks() { - return talks; - } - public void onLoad() { if (this.talks == null) this.talks = new ArrayList<>(); if (this.subQuests == null) this.subQuests = new SubQuestData[0]; diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index c5f9c1a40..21a301207 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -1,8 +1,11 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.ResourceLoader.OpenConfigData; +import lombok.Getter; + import java.util.*; +@Getter public class OpenConfigEntry { private final String name; private String[] addAbilities; @@ -34,22 +37,7 @@ public class OpenConfigEntry { } } - public String getName() { - return name; - } - - public String[] getAddAbilities() { - return addAbilities; - } - - public int getExtraTalentIndex() { - return extraTalentIndex; - } - - public SkillPointModifier[] getSkillPointModifiers() { - return skillPointModifiers; - } - + @Getter public static class SkillPointModifier { private final int skillId; private final int delta; @@ -59,12 +47,5 @@ public class OpenConfigEntry { this.delta = delta; } - public int getSkillId() { - return skillId; - } - - public int getDelta() { - return delta; - } } } diff --git a/src/main/java/emu/grasscutter/data/binout/ScenePointEntry.java b/src/main/java/emu/grasscutter/data/binout/ScenePointEntry.java index 3ca40f32e..4b9d805b0 100644 --- a/src/main/java/emu/grasscutter/data/binout/ScenePointEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/ScenePointEntry.java @@ -3,9 +3,10 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.common.PointData; import lombok.Getter; +@Getter public class ScenePointEntry { - @Getter private final int sceneId; - @Getter private final PointData pointData; + private final int sceneId; + private final PointData pointData; @Deprecated(forRemoval = true) public ScenePointEntry(String name, PointData pointData) { diff --git a/src/main/java/emu/grasscutter/data/binout/config/ConfigLevelEntity.java b/src/main/java/emu/grasscutter/data/binout/config/ConfigLevelEntity.java index 9afe5a5d1..fc63f002b 100644 --- a/src/main/java/emu/grasscutter/data/binout/config/ConfigLevelEntity.java +++ b/src/main/java/emu/grasscutter/data/binout/config/ConfigLevelEntity.java @@ -4,13 +4,14 @@ import emu.grasscutter.data.binout.config.fields.ConfigAbilityData; import java.util.List; import lombok.Getter; +@Getter public class ConfigLevelEntity { - @Getter private List abilities; - @Getter private List monsterAbilities; - @Getter private List avatarAbilities; - @Getter private List teamAbilities; - @Getter private List preloadMonsterEntityIDs; + private List abilities; + private List monsterAbilities; + private List avatarAbilities; + private List teamAbilities; + private List preloadMonsterEntityIDs; - @Getter private String dropElemControlType; + private String dropElemControlType; } diff --git a/src/main/java/emu/grasscutter/data/binout/routes/RotAngleType.java b/src/main/java/emu/grasscutter/data/binout/routes/RotAngleType.java index cd8287a72..4116be5c8 100644 --- a/src/main/java/emu/grasscutter/data/binout/routes/RotAngleType.java +++ b/src/main/java/emu/grasscutter/data/binout/routes/RotAngleType.java @@ -3,13 +3,14 @@ package emu.grasscutter.data.binout.routes; // import emu.grasscutter.scripts.constants.IntValueEnum; import lombok.Getter; +@Getter public enum RotAngleType /*implements IntValueEnum */ { ROT_NONE(-1), ROT_ANGLE_X(0), ROT_ANGLE_Y(1), ROT_ANGLE_Z(2); - @Getter private final int id; + private final int id; RotAngleType(int id) { this.id = id; diff --git a/src/main/java/emu/grasscutter/data/binout/routes/RouteType.java b/src/main/java/emu/grasscutter/data/binout/routes/RouteType.java index 55b4cd04b..558b23e0d 100644 --- a/src/main/java/emu/grasscutter/data/binout/routes/RouteType.java +++ b/src/main/java/emu/grasscutter/data/binout/routes/RouteType.java @@ -3,13 +3,14 @@ package emu.grasscutter.data.binout.routes; // import emu.grasscutter.scripts.constants.IntValueEnum; import lombok.Getter; +@Getter public enum RouteType /*implements IntValueEnum*/ { Unknown(-1), OneWay(0), Reciprocate(1), Loop(2); - @Getter private final int id; + private final int id; RouteType(int id) { this.id = id; diff --git a/src/main/java/emu/grasscutter/data/common/CurveInfo.java b/src/main/java/emu/grasscutter/data/common/CurveInfo.java index d9f814723..ffb6ae2be 100644 --- a/src/main/java/emu/grasscutter/data/common/CurveInfo.java +++ b/src/main/java/emu/grasscutter/data/common/CurveInfo.java @@ -1,19 +1,11 @@ package emu.grasscutter.data.common; +import lombok.Getter; + +@Getter public class CurveInfo { private String type; private String arith; private float value; - public String getType() { - return type; - } - - public String getArith() { - return arith; - } - - public float getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/data/common/FightPropData.java b/src/main/java/emu/grasscutter/data/common/FightPropData.java index cdc634a39..9bc31f781 100644 --- a/src/main/java/emu/grasscutter/data/common/FightPropData.java +++ b/src/main/java/emu/grasscutter/data/common/FightPropData.java @@ -1,24 +1,14 @@ package emu.grasscutter.data.common; import emu.grasscutter.game.props.FightProperty; +import lombok.Getter; +@Getter public class FightPropData { private String propType; private FightProperty prop; private float value; - public String getPropType() { - return propType; - } - - public float getValue() { - return value; - } - - public FightProperty getProp() { - return prop; - } - public void onLoad() { this.prop = FightProperty.getPropByName(propType); } diff --git a/src/main/java/emu/grasscutter/data/common/ItemParamData.java b/src/main/java/emu/grasscutter/data/common/ItemParamData.java index c77235976..e1d768ae3 100644 --- a/src/main/java/emu/grasscutter/data/common/ItemParamData.java +++ b/src/main/java/emu/grasscutter/data/common/ItemParamData.java @@ -1,8 +1,10 @@ package emu.grasscutter.data.common; import com.google.gson.annotations.SerializedName; +import lombok.Getter; // Used in excels +@Getter public class ItemParamData { @SerializedName( value = "id", @@ -21,18 +23,10 @@ public class ItemParamData { this.count = count; } - public int getId() { - return id; - } - public int getItemId() { return id; } - public int getCount() { - return count; - } - public int getItemCount() { return count; } diff --git a/src/main/java/emu/grasscutter/data/common/ItemParamStringData.java b/src/main/java/emu/grasscutter/data/common/ItemParamStringData.java index 7f864fc9e..dbb3cc2da 100644 --- a/src/main/java/emu/grasscutter/data/common/ItemParamStringData.java +++ b/src/main/java/emu/grasscutter/data/common/ItemParamStringData.java @@ -1,19 +1,14 @@ package emu.grasscutter.data.common; +import lombok.Getter; + +@Getter public class ItemParamStringData { private int id; private String count; public ItemParamStringData() {} - public int getId() { - return id; - } - - public String getCount() { - return count; - } - public ItemParamData toItemParamData() { if (count.contains(";")) { String[] split = count.split(";"); diff --git a/src/main/java/emu/grasscutter/data/common/ItemUseData.java b/src/main/java/emu/grasscutter/data/common/ItemUseData.java index e1af1a0b2..bd09ca4d8 100644 --- a/src/main/java/emu/grasscutter/data/common/ItemUseData.java +++ b/src/main/java/emu/grasscutter/data/common/ItemUseData.java @@ -1,9 +1,11 @@ package emu.grasscutter.data.common; import emu.grasscutter.game.props.ItemUseOp; +import lombok.Getter; public class ItemUseData { private ItemUseOp useOp; + @Getter private String[] useParam; public ItemUseOp getUseOp() { @@ -13,7 +15,4 @@ public class ItemUseData { return useOp; } - public String[] getUseParam() { - return useParam; - } } diff --git a/src/main/java/emu/grasscutter/data/common/OpenCondData.java b/src/main/java/emu/grasscutter/data/common/OpenCondData.java index b379106a8..8627c681f 100644 --- a/src/main/java/emu/grasscutter/data/common/OpenCondData.java +++ b/src/main/java/emu/grasscutter/data/common/OpenCondData.java @@ -1,23 +1,18 @@ package emu.grasscutter.data.common; +import lombok.Getter; + import java.util.List; +@Getter public class OpenCondData { private String condType; private List paramList; - public String getCondType() { - return condType; - } - public void setCondType(String cType) { condType = cType; } - public List getParamList() { - return paramList; - } - public void setParamList(List pList) { paramList = pList; } diff --git a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java index d7951917d..8c60834b2 100644 --- a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java +++ b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java @@ -1,14 +1,10 @@ package emu.grasscutter.data.common; +import lombok.Getter; + +@Getter public class PropGrowCurve { private String type; private String growCurve; - public String getType() { - return this.type; - } - - public String getGrowCurve() { - return this.growCurve; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/CombineData.java b/src/main/java/emu/grasscutter/data/excels/CombineData.java index b44305589..d15de8ff2 100644 --- a/src/main/java/emu/grasscutter/data/excels/CombineData.java +++ b/src/main/java/emu/grasscutter/data/excels/CombineData.java @@ -2,22 +2,34 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; +import lombok.Getter; + import java.util.List; import java.util.stream.Collectors; @ResourceType(name = "CombineExcelConfigData.json") public class CombineData extends GameResource { + @Getter private int combineId; + @Getter private int playerLevel; private boolean isDefaultShow; + @Getter private int combineType; + @Getter private int subCombineType; + @Getter private int resultItemId; + @Getter private int resultItemCount; + @Getter private int scoinCost; + @Getter private List randomItems; + @Getter private List materialItems; + @Getter private String recipeType; @Override @@ -35,47 +47,8 @@ public class CombineData extends GameResource { materialItems.stream().filter(item -> item.getId() > 0).collect(Collectors.toList()); } - public int getCombineId() { - return combineId; - } - - public int getPlayerLevel() { - return playerLevel; - } - public boolean isDefaultShow() { return isDefaultShow; } - public int getCombineType() { - return combineType; - } - - public int getSubCombineType() { - return subCombineType; - } - - public int getResultItemId() { - return resultItemId; - } - - public int getResultItemCount() { - return resultItemCount; - } - - public int getScoinCost() { - return scoinCost; - } - - public List getRandomItems() { - return randomItems; - } - - public List getMaterialItems() { - return materialItems; - } - - public String getRecipeType() { - return recipeType; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/CookBonusData.java b/src/main/java/emu/grasscutter/data/excels/CookBonusData.java index 1a2de3884..b02cb7945 100644 --- a/src/main/java/emu/grasscutter/data/excels/CookBonusData.java +++ b/src/main/java/emu/grasscutter/data/excels/CookBonusData.java @@ -2,7 +2,9 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; +import lombok.Getter; +@Getter @ResourceType( name = {"CookBonusExcelConfigData.json"}, loadPriority = LoadPriority.LOW) @@ -17,22 +19,6 @@ public class CookBonusData extends GameResource { return this.avatarId; } - public int getAvatarId() { - return avatarId; - } - - public int getRecipeId() { - return recipeId; - } - - public int[] getParamVec() { - return paramVec; - } - - public int[] getComplexParamVec() { - return complexParamVec; - } - public int getReplacementItemId() { return this.paramVec[0]; } diff --git a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java index 002c75141..9612eb3ed 100644 --- a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java @@ -2,13 +2,17 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; +import lombok.Getter; + import java.util.List; @ResourceType( name = "EnvAnimalGatherExcelConfigData.json", loadPriority = ResourceType.LoadPriority.LOW) public class EnvAnimalGatherConfigData extends GameResource { + @Getter private int animalId; + @Getter private String entityType; private List gatherItemId; private String excludeWeathers; @@ -21,14 +25,6 @@ public class EnvAnimalGatherConfigData extends GameResource { return animalId; } - public int getAnimalId() { - return animalId; - } - - public String getEntityType() { - return entityType; - } - public ItemParamData getGatherItem() { return !gatherItemId.isEmpty() ? gatherItemId.get(0) : null; } diff --git a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java index d95fb6154..194ef810f 100644 --- a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java +++ b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java @@ -2,6 +2,8 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.FightPropData; +import lombok.Getter; + import java.util.ArrayList; @ResourceType(name = "EquipAffixExcelConfigData.json") @@ -9,10 +11,15 @@ public class EquipAffixData extends GameResource { private int affixId; private int id; + @Getter private int level; + @Getter private long nameTextMapHash; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override @@ -24,26 +31,6 @@ public class EquipAffixData extends GameResource { return id; } - public int getLevel() { - return level; - } - - public long getNameTextMapHash() { - return nameTextMapHash; - } - - public String getOpenConfig() { - return openConfig; - } - - public FightPropData[] getAddProps() { - return addProps; - } - - public float[] getParamList() { - return paramList; - } - @Override public void onLoad() { ArrayList parsed = new ArrayList<>(getAddProps().length); diff --git a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java index bdd7fa441..7097e7c7c 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java @@ -2,10 +2,12 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; +import lombok.Getter; @ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class FetterCharacterCardData extends GameResource { private int avatarId; + @Getter private int rewardId; @Override @@ -13,10 +15,6 @@ public class FetterCharacterCardData extends GameResource { return avatarId; } - public int getRewardId() { - return rewardId; - } - @Override public void onLoad() {} } diff --git a/src/main/java/emu/grasscutter/data/excels/FetterData.java b/src/main/java/emu/grasscutter/data/excels/FetterData.java index 08eea561c..94c42c217 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterData.java @@ -3,6 +3,8 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.OpenCondData; +import lombok.Getter; + import java.util.List; @ResourceType( @@ -15,6 +17,7 @@ import java.util.List; }, loadPriority = LoadPriority.HIGHEST) public class FetterData extends GameResource { + @Getter private int avatarId; private int fetterId; private List openCond; @@ -24,10 +27,6 @@ public class FetterData extends GameResource { return fetterId; } - public int getAvatarId() { - return avatarId; - } - public List getOpenConds() { return openCond; } diff --git a/src/main/java/emu/grasscutter/data/excels/GatherData.java b/src/main/java/emu/grasscutter/data/excels/GatherData.java index a9129be66..716974af9 100644 --- a/src/main/java/emu/grasscutter/data/excels/GatherData.java +++ b/src/main/java/emu/grasscutter/data/excels/GatherData.java @@ -1,13 +1,17 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = "GatherExcelConfigData.json") public class GatherData extends GameResource { private int pointType; private int id; + @Getter private int gadgetId; + @Getter private int itemId; + @Getter private int cd; // Probably hours private boolean isForbidGuest; private boolean initDisableInteract; @@ -21,18 +25,6 @@ public class GatherData extends GameResource { return id; } - public int getGadgetId() { - return gadgetId; - } - - public int getItemId() { - return itemId; - } - - public int getCd() { - return cd; - } - public boolean isForbidGuest() { return isForbidGuest; } diff --git a/src/main/java/emu/grasscutter/data/excels/OpenStateData.java b/src/main/java/emu/grasscutter/data/excels/OpenStateData.java index 9d8d187c3..6c4dc0cdb 100644 --- a/src/main/java/emu/grasscutter/data/excels/OpenStateData.java +++ b/src/main/java/emu/grasscutter/data/excels/OpenStateData.java @@ -39,12 +39,10 @@ public class OpenStateData extends GameResource { OPEN_STATE_COND_PARENT_QUEST } + @Getter public static class OpenStateCond { - @Getter private OpenStateCondType condType; - @Getter private int param; - @Getter private int param2; } } diff --git a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java index 6429728f8..6c48ec1b2 100644 --- a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java @@ -6,11 +6,12 @@ import emu.grasscutter.game.world.World; import java.util.*; import lombok.Getter; +@Getter @ResourceType(name = "RefreshPolicyExcelConfigData.json") public class RefreshPolicyExcelConfigData extends GameResource { - @Getter private int id; - @Getter private RefreshType type; - @Getter private String time; + private int id; + private RefreshType type; + private String time; private static int upperBound(List list, int low, int high, int value) { while (low < high) { diff --git a/src/main/java/emu/grasscutter/data/excels/RewardData.java b/src/main/java/emu/grasscutter/data/excels/RewardData.java index 1b817aec2..ecf799e05 100644 --- a/src/main/java/emu/grasscutter/data/excels/RewardData.java +++ b/src/main/java/emu/grasscutter/data/excels/RewardData.java @@ -2,11 +2,14 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; +import lombok.Getter; + import java.util.List; @ResourceType(name = "RewardExcelConfigData.json") public class RewardData extends GameResource { public int rewardId; + @Getter public List rewardItemList; @Override @@ -14,10 +17,6 @@ public class RewardData extends GameResource { return rewardId; } - public List getRewardItemList() { - return rewardItemList; - } - @Override public void onLoad() { rewardItemList = rewardItemList.stream().filter(i -> i.getId() > 0).toList(); diff --git a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java index 5c1482f4d..697ea74a3 100644 --- a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java +++ b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java @@ -4,26 +4,40 @@ import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.game.shop.ShopInfo; +import lombok.Getter; + import java.util.List; @ResourceType(name = "ShopGoodsExcelConfigData.json") public class ShopGoodsData extends GameResource { + @Getter private int goodsId; + @Getter private int shopType; + @Getter private int itemId; + @Getter private int itemCount; + @Getter private int costScoin; + @Getter private int costHcoin; + @Getter private int costMcoin; + @Getter private List costItems; + @Getter private int minPlayerLevel; + @Getter private int maxPlayerLevel; + @Getter private int buyLimit; + @Getter @SerializedName( value = "subTabId", alternate = {"secondarySheetId"}) @@ -32,6 +46,7 @@ public class ShopGoodsData extends GameResource { private String refreshType; private transient ShopInfo.ShopRefreshType refreshTypeEnum; + @Getter private int refreshParam; @Override @@ -53,59 +68,8 @@ public class ShopGoodsData extends GameResource { return getGoodsId(); } - public int getGoodsId() { - return goodsId; - } - - public int getShopType() { - return shopType; - } - - public int getItemId() { - return itemId; - } - - public int getItemCount() { - return itemCount; - } - - public int getCostScoin() { - return costScoin; - } - - public int getCostHcoin() { - return costHcoin; - } - - public int getCostMcoin() { - return costMcoin; - } - - public List getCostItems() { - return costItems; - } - - public int getMinPlayerLevel() { - return minPlayerLevel; - } - - public int getMaxPlayerLevel() { - return maxPlayerLevel; - } - - public int getBuyLimit() { - return buyLimit; - } - - public int getSubTabId() { - return subTabId; - } - public ShopInfo.ShopRefreshType getRefreshType() { return refreshTypeEnum; } - public int getRefreshParam() { - return refreshParam; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java b/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java index fd3afc8eb..32d3f205d 100644 --- a/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java @@ -4,13 +4,14 @@ import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; import lombok.*; +@Getter @ResourceType(name = "StatuePromoteExcelConfigData.json") public class StatuePromoteData extends GameResource { - @Getter @Setter private int level; - @Getter @Setter private int cityId; - @Getter @Setter private ItemParamData[] costItems; - @Getter @Setter private int[] rewardIdList; - @Getter @Setter private int stamina; + @Setter private int level; + @Setter private int cityId; + @Setter private ItemParamData[] costItems; + @Setter private int[] rewardIdList; + @Setter private int stamina; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/activity/ActivityCondExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/activity/ActivityCondExcelConfigData.java index ebb1d3c4f..afe41f20e 100644 --- a/src/main/java/emu/grasscutter/data/excels/activity/ActivityCondExcelConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/activity/ActivityCondExcelConfigData.java @@ -15,9 +15,10 @@ public class ActivityCondExcelConfigData extends GameResource { LogicType condComb; List cond; + @Getter public static class ActivityConfigCondition { - @Getter private ActivityConditions type; - @Getter private List param; + private ActivityConditions type; + private List param; public int[] paramArray() { return param.stream().mapToInt(Integer::intValue).toArray(); diff --git a/src/main/java/emu/grasscutter/data/excels/activity/ActivityShopData.java b/src/main/java/emu/grasscutter/data/excels/activity/ActivityShopData.java index 0f8d2ceb2..56af01206 100644 --- a/src/main/java/emu/grasscutter/data/excels/activity/ActivityShopData.java +++ b/src/main/java/emu/grasscutter/data/excels/activity/ActivityShopData.java @@ -5,11 +5,12 @@ import emu.grasscutter.game.shop.ShopType; import java.util.List; import lombok.Getter; +@Getter @ResourceType(name = "ActivityShopOverallExcelConfigData.json") public class ActivityShopData extends GameResource { - @Getter private int scheduleId; - @Getter private ShopType shopType; - @Getter private List sheetList; + private int scheduleId; + private ShopType shopType; + private List sheetList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java index 9468a4c57..47b4db756 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java @@ -2,14 +2,18 @@ package emu.grasscutter.data.excels.avatar; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = "AvatarCostumeExcelConfigData.json") public class AvatarCostumeData extends GameResource { @SerializedName(value = "skinId", alternate = "costumeId") private int skinId; + @Getter private int itemId; + @Getter private int characterId; + @Getter private int quality; @Override @@ -17,18 +21,6 @@ public class AvatarCostumeData extends GameResource { return this.skinId; } - public int getItemId() { - return this.itemId; - } - - public int getCharacterId() { - return characterId; - } - - public int getQuality() { - return quality; - } - @Override public void onLoad() { GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this); diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java index 6b58a711b..5b201156f 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java @@ -2,11 +2,14 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.CurveInfo; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; @ResourceType(name = "AvatarCurveExcelConfigData.json") public class AvatarCurveData extends GameResource { + @Getter private int level; private CurveInfo[] curveInfos; @@ -17,10 +20,6 @@ public class AvatarCurveData extends GameResource { return this.level; } - public int getLevel() { - return level; - } - public Map getCurveInfos() { return curveInfoMap; } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java index dda483808..8799c1ba6 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java @@ -1,10 +1,12 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = "AvatarFlycloakExcelConfigData.json") public class AvatarFlycloakData extends GameResource { private int flycloakId; + @Getter private long nameTextMapHash; @Override @@ -12,10 +14,6 @@ public class AvatarFlycloakData extends GameResource { return this.flycloakId; } - public long getNameTextMapHash() { - return nameTextMapHash; - } - @Override public void onLoad() {} } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java index 1eae299e3..a2d30b13d 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java @@ -1,7 +1,9 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; +import lombok.Getter; +@Getter @ResourceType(name = "AvatarLevelExcelConfigData.json") public class AvatarLevelData extends GameResource { private int level; @@ -12,11 +14,4 @@ public class AvatarLevelData extends GameResource { return this.level; } - public int getLevel() { - return level; - } - - public int getExp() { - return exp; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java index 8972de6e9..b871929fc 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java @@ -2,17 +2,25 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; +import lombok.Getter; + import java.util.ArrayList; @ResourceType(name = "AvatarPromoteExcelConfigData.json") public class AvatarPromoteData extends GameResource { + @Getter private int avatarPromoteId; + @Getter private int promoteLevel; private int scoinCost; + @Getter private ItemParamData[] costItems; + @Getter private int unlockMaxLevel; + @Getter private FightPropData[] addProps; + @Getter private int requiredPlayerLevel; @Override @@ -20,34 +28,10 @@ public class AvatarPromoteData extends GameResource { return (avatarPromoteId << 8) + promoteLevel; } - public int getAvatarPromoteId() { - return avatarPromoteId; - } - - public int getPromoteLevel() { - return promoteLevel; - } - - public ItemParamData[] getCostItems() { - return costItems; - } - public int getCoinCost() { return scoinCost; } - public FightPropData[] getAddProps() { - return addProps; - } - - public int getUnlockMaxLevel() { - return unlockMaxLevel; - } - - public int getRequiredPlayerLevel() { - return requiredPlayerLevel; - } - @Override public void onLoad() { // Trim item params diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java index 5f91ca3c3..291f75877 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java @@ -3,18 +3,27 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.FightPropData; +import lombok.Getter; + import java.util.ArrayList; @ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class AvatarTalentData extends GameResource { private int talentId; private int prevTalent; + @Getter private long nameTextMapHash; + @Getter private String icon; + @Getter private int mainCostItemId; + @Getter private int mainCostItemCount; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override @@ -26,34 +35,6 @@ public class AvatarTalentData extends GameResource { return prevTalent; } - public long getNameTextMapHash() { - return nameTextMapHash; - } - - public String getIcon() { - return icon; - } - - public int getMainCostItemId() { - return mainCostItemId; - } - - public int getMainCostItemCount() { - return mainCostItemCount; - } - - public String getOpenConfig() { - return openConfig; - } - - public FightPropData[] getAddProps() { - return addProps; - } - - public float[] getParamList() { - return paramList; - } - @Override public void onLoad() { ArrayList parsed = new ArrayList<>(getAddProps().length); diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexMaterialData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexMaterialData.java index ee14db8e2..fa28411dc 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexMaterialData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexMaterialData.java @@ -1,25 +1,15 @@ package emu.grasscutter.data.excels.codex; import emu.grasscutter.data.*; +import lombok.Getter; +@Getter @ResourceType(name = {"MaterialCodexExcelConfigData.json"}) public class CodexMaterialData extends GameResource { private int Id; private int materialId; private int sortOrder; - public int getSortOrder() { - return sortOrder; - } - - public int getMaterialId() { - return materialId; - } - - public int getId() { - return Id; - } - @Override public void onLoad() { GameData.getCodexMaterialDataIdMap().put(this.getMaterialId(), this); diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java index 1b373bfbe..547d89f8b 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java @@ -1,31 +1,20 @@ package emu.grasscutter.data.excels.codex; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = {"QuestCodexExcelConfigData.json"}) public class CodexQuestData extends GameResource { + @Getter private int Id; + @Getter private int parentQuestId; + @Getter private int chapterId; + @Getter private int sortOrder; private boolean isDisuse; - public int getParentQuestId() { - return parentQuestId; - } - - public int getId() { - return Id; - } - - public int getChapterId() { - return chapterId; - } - - public int getSortOrder() { - return sortOrder; - } - public boolean getIsDisuse() { return isDisuse; } diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java index 7d585839e..a7124bda1 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java @@ -1,30 +1,22 @@ package emu.grasscutter.data.excels.codex; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = {"WeaponCodexExcelConfigData.json"}) public class CodexWeaponData extends GameResource { + @Getter private int Id; + @Getter private int weaponId; private int gadgetId; + @Getter private int sortOrder; - public int getSortOrder() { - return sortOrder; - } - - public int getWeaponId() { - return weaponId; - } - public int getGadgetId() { return weaponId; } - public int getId() { - return Id; - } - @Override public void onLoad() { GameData.getCodexWeaponDataIdMap().put(this.getWeaponId(), this); diff --git a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java index 12f81f303..fd9722f1f 100644 --- a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java @@ -9,6 +9,7 @@ import lombok.Getter; @Getter @ResourceType(name = "DungeonChallengeConfigData.json") public class DungeonChallengeConfigData extends GameResource { + @Getter private int id; private ChallengeType challengeType; private boolean noSuccessHint; @@ -42,11 +43,7 @@ public class DungeonChallengeConfigData extends GameResource { alternate = {"NJBJIKAIENN"}) private AllowAnimationType animationOnSubFail; - public int getId() { - return id; - } - - public enum InterruptButtonType { + public enum InterruptButtonType { INTERRUPT_BUTTON_TYPE_NONE, INTERRUPT_BUTTON_TYPE_HOST, INTERRUPT_BUTTON_TYPE_ALL diff --git a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonPassConfigData.java b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonPassConfigData.java index 4c92c341b..6d1c3d7f9 100644 --- a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonPassConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonPassConfigData.java @@ -6,15 +6,17 @@ import emu.grasscutter.game.quest.enums.LogicType; import java.util.List; import lombok.*; +@Getter @ResourceType(name = "DungeonPassExcelConfigData.json") public class DungeonPassConfigData extends GameResource { - @Getter private int id; - @Getter private LogicType logicType; - @Getter @Setter private List conds; + private int id; + private LogicType logicType; + @Setter private List conds; + @Getter public static class DungeonPassCondition { - @Getter private DungeonPassConditionType condType; - @Getter int[] param; + private DungeonPassConditionType condType; + int[] param; } @Override diff --git a/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java b/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java index a0463f6d1..7b0174136 100644 --- a/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java +++ b/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java @@ -11,32 +11,33 @@ import javax.annotation.*; import lombok.*; import lombok.experimental.FieldDefaults; +@Getter @ResourceType(name = "QuestExcelConfigData.json") @Getter @ToString public class QuestData extends GameResource { - @Getter private int subId; - @Getter private int mainId; - @Getter private int order; - @Getter private long descTextMapHash; + private int subId; + private int mainId; + private int order; + private long descTextMapHash; - @Getter private boolean finishParent; - @Getter private boolean isRewind; + private boolean finishParent; + private boolean isRewind; - @Getter private LogicType acceptCondComb; - @Getter private LogicType finishCondComb; - @Getter private LogicType failCondComb; + private LogicType acceptCondComb; + private LogicType finishCondComb; + private LogicType failCondComb; - @Getter private List acceptCond; - @Getter private List finishCond; - @Getter private List failCond; - @Getter private List beginExec; - @Getter private List finishExec; - @Getter private List failExec; - @Getter private Guide guide; + private List acceptCond; + private List finishCond; + private List failCond; + private List beginExec; + private List finishExec; + private List failExec; + private Guide guide; - @Getter private List trialAvatarList; - @Getter private List gainItems; + private List trialAvatarList; + private List gainItems; public static String questConditionKey( @Nonnull Enum type, int firstParam, @Nullable String paramsStr) { diff --git a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java index 022d2997e..153c0777e 100644 --- a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java +++ b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java @@ -2,12 +2,15 @@ package emu.grasscutter.data.excels.reliquary; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = "ReliquarySetExcelConfigData.json") public class ReliquarySetData extends GameResource { private int setId; + @Getter private int[] setNeedNum; + @Getter @SerializedName( value = "equipAffixId", alternate = {"EquipAffixId"}) @@ -18,14 +21,6 @@ public class ReliquarySetData extends GameResource { return setId; } - public int[] getSetNeedNum() { - return setNeedNum; - } - - public int getEquipAffixId() { - return equipAffixId; - } - @Override public void onLoad() {} } diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java index 7652e644b..321d04e62 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java @@ -1,8 +1,11 @@ package emu.grasscutter.data.excels.tower; import emu.grasscutter.data.*; +import lombok.Getter; + import java.util.List; +@Getter @ResourceType(name = "TowerScheduleExcelConfigData.json") public class TowerScheduleData extends GameResource { private int scheduleId; @@ -22,27 +25,9 @@ public class TowerScheduleData extends GameResource { this.schedules.stream().filter(item -> !item.getFloorList().isEmpty()).toList(); } - public int getScheduleId() { - return scheduleId; - } - - public List getEntranceFloorId() { - return entranceFloorId; - } - - public List getSchedules() { - return schedules; - } - - public int getMonthlyLevelConfigId() { - return monthlyLevelConfigId; - } - + @Getter public static class ScheduleDetail { private List floorList; - public List getFloorList() { - return floorList; - } } } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java index a35b9b9c2..3d326ea6b 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java @@ -1,7 +1,9 @@ package emu.grasscutter.data.excels.weapon; import emu.grasscutter.data.*; +import lombok.Getter; +@Getter @ResourceType(name = "WeaponLevelExcelConfigData.json") public class WeaponLevelData extends GameResource { private int level; @@ -12,11 +14,4 @@ public class WeaponLevelData extends GameResource { return this.level; } - public int getLevel() { - return level; - } - - public int[] getRequiredExps() { - return requiredExps; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java index 775737e11..228716f8f 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java @@ -2,8 +2,11 @@ package emu.grasscutter.data.excels.weapon; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; +import lombok.Getter; + import java.util.ArrayList; +@Getter @ResourceType(name = "WeaponPromoteExcelConfigData.json") public class WeaponPromoteData extends GameResource { @@ -20,34 +23,6 @@ public class WeaponPromoteData extends GameResource { return (weaponPromoteId << 8) + promoteLevel; } - public int getWeaponPromoteId() { - return weaponPromoteId; - } - - public int getPromoteLevel() { - return promoteLevel; - } - - public ItemParamData[] getCostItems() { - return costItems; - } - - public int getCoinCost() { - return coinCost; - } - - public FightPropData[] getAddProps() { - return addProps; - } - - public int getUnlockMaxLevel() { - return unlockMaxLevel; - } - - public int getRequiredPlayerLevel() { - return requiredPlayerLevel; - } - @Override public void onLoad() { // Trim item params diff --git a/src/main/java/emu/grasscutter/data/excels/world/WeatherData.java b/src/main/java/emu/grasscutter/data/excels/world/WeatherData.java index 631134257..9db8809e4 100644 --- a/src/main/java/emu/grasscutter/data/excels/world/WeatherData.java +++ b/src/main/java/emu/grasscutter/data/excels/world/WeatherData.java @@ -4,19 +4,20 @@ import emu.grasscutter.data.*; import emu.grasscutter.game.props.ClimateType; import lombok.Getter; +@Getter @ResourceType(name = "WeatherExcelConfigData.json") public class WeatherData extends GameResource { - @Getter private int areaID; - @Getter private int weatherAreaId; - @Getter private String maxHeightStr; - @Getter private int gadgetID; - @Getter private boolean isDefaultValid; - @Getter private String templateName; - @Getter private int priority; - @Getter private String profileName; - @Getter private ClimateType defaultClimate; - @Getter private boolean isUseDefault; - @Getter private int sceneID; + private int areaID; + private int weatherAreaId; + private String maxHeightStr; + private int gadgetID; + private boolean isDefaultValid; + private String templateName; + private int priority; + private String profileName; + private ClimateType defaultClimate; + private boolean isUseDefault; + private int sceneID; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java index 0967c9871..00cc9b87a 100644 --- a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java @@ -1,10 +1,12 @@ package emu.grasscutter.data.excels.world; import emu.grasscutter.data.*; +import lombok.Getter; @ResourceType(name = "WorldLevelExcelConfigData.json") public class WorldLevelData extends GameResource { private int level; + @Getter private int monsterLevel; @Override @@ -12,10 +14,6 @@ public class WorldLevelData extends GameResource { return this.level; } - public int getMonsterLevel() { - return monsterLevel; - } - @Override public void onLoad() {} } diff --git a/src/main/java/emu/grasscutter/data/server/Grid.java b/src/main/java/emu/grasscutter/data/server/Grid.java index 25f84559b..c42431c30 100644 --- a/src/main/java/emu/grasscutter/data/server/Grid.java +++ b/src/main/java/emu/grasscutter/data/server/Grid.java @@ -5,12 +5,20 @@ import com.github.davidmoten.rtreemulti.geometry.Geometry; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.SceneIndexManager; +import lombok.Getter; + import java.util.*; public class Grid { public transient RTree>, Geometry> gridOptimized = null; private final transient Set nearbyGroups = new HashSet<>(100); + /** + * -- GETTER -- + * + * @return The correctly loaded grid map. + */ + @Getter public Map> grid = new LinkedHashMap<>(); /** Creates an optimized cache of the grid. */ @@ -23,13 +31,6 @@ public class Grid { } } - /** - * @return The correctly loaded grid map. - */ - public Map> getGrid() { - return this.grid; - } - public Set getNearbyGroups(int vision_level, Position position) { this.optimize(); // Check to see if the grid is optimized. diff --git a/src/main/java/emu/grasscutter/database/DatabaseManager.java b/src/main/java/emu/grasscutter/database/DatabaseManager.java index 7331bccb7..52fc274f7 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -11,15 +11,13 @@ import dev.morphia.query.experimental.filters.Filters; import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.game.Account; +import lombok.Getter; public final class DatabaseManager { + @Getter private static Datastore gameDatastore; private static Datastore dispatchDatastore; - public static Datastore getGameDatastore() { - return gameDatastore; - } - public static Datastore getAccountDatastore() { if (Grasscutter.getRunMode() == ServerRunMode.HYBRID) return gameDatastore; else return dispatchDatastore; diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index e13475705..bbdab85c4 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -7,28 +7,44 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.utils.*; import java.util.*; import java.util.stream.Stream; + +import lombok.Getter; import org.bson.Document; @Entity(value = "accounts", useDiscriminator = false) public class Account { + @Getter @Id private String id; + @Getter @Indexed(options = @IndexOptions(unique = true)) @Collation(locale = "simple", caseLevel = true) private String username; + @Getter private String password; // Unused for now private int reservedPlayerId; private String email; + @Getter private String token; + @Getter private String sessionKey; // Session token for dispatch server + /** + * -- GETTER -- + * The collection of a player's permissions. + */ + @Getter private final List permissions; + @Getter private Locale locale; + @Getter private String banReason; + @Getter private int banEndTime; + @Getter private int banStartTime; private boolean isBanned; @@ -64,34 +80,18 @@ public class Account { return (wildcardParts.length == permissionParts.length); } - public String getId() { - return id; - } - public void setId(String id) { this.id = id; } - public String getUsername() { - return username; - } - public void setUsername(String username) { this.username = username; } - public String getPassword() { - return password; - } - public void setPassword(String password) { this.password = password; } - public String getToken() { - return token; - } - public void setToken(String token) { this.token = token; } @@ -117,44 +117,24 @@ public class Account { this.email = email; } - public String getSessionKey() { - return this.sessionKey; - } - public String generateSessionKey() { this.sessionKey = Utils.bytesToHex(Crypto.createSessionKey(32)); this.save(); return this.sessionKey; } - public Locale getLocale() { - return locale; - } - public void setLocale(Locale locale) { this.locale = locale; } - public String getBanReason() { - return banReason; - } - public void setBanReason(String banReason) { this.banReason = banReason; } - public int getBanEndTime() { - return banEndTime; - } - public void setBanEndTime(int banEndTime) { this.banEndTime = banEndTime; } - public int getBanStartTime() { - return banStartTime; - } - public void setBanStartTime(int banStartTime) { this.banStartTime = banStartTime; } @@ -175,11 +155,6 @@ public class Account { this.isBanned = isBanned; } - /** The collection of a player's permissions. */ - public List getPermissions() { - return this.permissions; - } - public boolean addPermission(String permission) { if (this.permissions.contains(permission)) return false; this.permissions.add(permission); diff --git a/src/main/java/emu/grasscutter/game/CoopRequest.java b/src/main/java/emu/grasscutter/game/CoopRequest.java index f1caf0f8b..ca4c0c6aa 100644 --- a/src/main/java/emu/grasscutter/game/CoopRequest.java +++ b/src/main/java/emu/grasscutter/game/CoopRequest.java @@ -1,7 +1,9 @@ package emu.grasscutter.game; import emu.grasscutter.game.player.Player; +import lombok.Getter; +@Getter public class CoopRequest { private final Player requester; private final long requestTime; @@ -13,18 +15,6 @@ public class CoopRequest { this.expireTime = this.requestTime + 10000; } - public Player getRequester() { - return requester; - } - - public long getRequestTime() { - return requestTime; - } - - public long getExpireTime() { - return expireTime; - } - public boolean isExpired() { return System.currentTimeMillis() > getExpireTime(); } diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java b/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java index a95c4fbda..d5f8d760f 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityModifierController.java @@ -3,11 +3,12 @@ package emu.grasscutter.game.ability; import emu.grasscutter.data.binout.*; import lombok.Getter; +@Getter public class AbilityModifierController { - @Getter private final Ability ability; + private final Ability ability; - @Getter private final AbilityData abilityData; - @Getter private final AbilityModifier modifierData; + private final AbilityData abilityData; + private final AbilityModifier modifierData; public AbilityModifierController( Ability ability, AbilityData abilityData, AbilityModifier modifierData) { diff --git a/src/main/java/emu/grasscutter/game/achievement/AchievementControlReturns.java b/src/main/java/emu/grasscutter/game/achievement/AchievementControlReturns.java index c177f8035..942eb52ca 100644 --- a/src/main/java/emu/grasscutter/game/achievement/AchievementControlReturns.java +++ b/src/main/java/emu/grasscutter/game/achievement/AchievementControlReturns.java @@ -32,13 +32,14 @@ public class AchievementControlReturns { return new AchievementControlReturns(Return.NOT_YET_ACHIEVED); } + @Getter public enum Return { SUCCESS("commands.achievement.success."), ACHIEVEMENT_NOT_FOUND("commands.achievement.fail.achievement_not_found"), ALREADY_ACHIEVED("commands.achievement.fail.already_achieved"), NOT_YET_ACHIEVED("commands.achievement.fail.not_yet_achieved"); - @Getter private final String key; + private final String key; Return(String key) { this.key = key; diff --git a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java index 719607721..20835fe81 100644 --- a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java +++ b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java @@ -16,9 +16,10 @@ import java.util.*; import java.util.stream.Stream; import lombok.*; +@Getter @GameActivity(ActivityType.NEW_ACTIVITY_TRIAL_AVATAR) public class TrialAvatarActivityHandler extends ActivityHandler { - @Getter @Setter private int selectedTrialAvatarIndex; + @Setter private int selectedTrialAvatarIndex; @Override public void onInitPlayerActivityData(PlayerActivityData playerActivityData) { diff --git a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java index 1d2002e7b..5d30007c6 100644 --- a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java +++ b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java @@ -15,10 +15,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import lombok.Getter; + import java.util.Iterator; import java.util.List; public class AvatarStorage extends BasePlayerManager implements Iterable { + @Getter private final Int2ObjectMap avatars; private final Long2ObjectMap avatarsGuid; @@ -28,10 +31,6 @@ public class AvatarStorage extends BasePlayerManager implements Iterable this.avatarsGuid = new Long2ObjectOpenHashMap<>(); } - public Int2ObjectMap getAvatars() { - return avatars; - } - public int getAvatarCount() { return this.avatars.size(); } diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java index afd895224..27286ad00 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java @@ -4,10 +4,13 @@ import dev.morphia.annotations.*; import emu.grasscutter.data.GameData; import emu.grasscutter.data.excels.BattlePassMissionData; import emu.grasscutter.game.props.BattlePassMissionStatus; +import lombok.Getter; @Entity public class BattlePassMission { + @Getter private int id; + @Getter private int progress; private BattlePassMissionStatus status; @@ -20,10 +23,6 @@ public class BattlePassMission { this.id = id; } - public int getId() { - return id; - } - public BattlePassMissionData getData() { if (this.data == null) { this.data = GameData.getBattlePassMissionDataMap().get(getId()); @@ -31,10 +30,6 @@ public class BattlePassMission { return this.data; } - public int getProgress() { - return progress; - } - public void setProgress(int value) { this.progress = value; } diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java index 6433563d7..d37518f45 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java @@ -4,11 +4,15 @@ import dev.morphia.annotations.*; import emu.grasscutter.data.excels.BattlePassMissionData; import emu.grasscutter.net.proto.BattlePassRewardTagOuterClass.BattlePassRewardTag; import emu.grasscutter.net.proto.BattlePassUnlockStatusOuterClass.BattlePassUnlockStatus; +import lombok.Getter; @Entity public class BattlePassReward { + @Getter private int level; + @Getter private int rewardId; + @Getter private boolean paid; @Transient private BattlePassMissionData data; @@ -22,18 +26,6 @@ public class BattlePassReward { this.paid = paid; } - public int getLevel() { - return level; - } - - public int getRewardId() { - return rewardId; - } - - public boolean isPaid() { - return paid; - } - public BattlePassRewardTag toProto() { var protoBuilder = BattlePassRewardTag.newBuilder(); diff --git a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java index 9bd64ba32..bd1797270 100644 --- a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java +++ b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java @@ -10,6 +10,8 @@ import emu.grasscutter.server.event.player.PlayerChatEvent; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; +import lombok.Getter; + import java.util.*; import java.util.regex.Pattern; @@ -22,16 +24,13 @@ public class ChatSystem implements ChatSystemHandler { // user id -> chat partner id -> [messages] private final Map>> history = new HashMap<>(); + @Getter private final GameServer server; public ChatSystem(GameServer server) { this.server = server; } - public GameServer getServer() { - return server; - } - private boolean tryInvokeCommand(Player sender, Player target, String rawMessage) { if (!RE_PREFIXES.matcher(rawMessage.substring(0, 1)).matches()) return false; for (String line : rawMessage.substring(1).split("\n[/!]")) diff --git a/src/main/java/emu/grasscutter/game/city/CityInfoData.java b/src/main/java/emu/grasscutter/game/city/CityInfoData.java index 5c8bde72f..6cff23158 100644 --- a/src/main/java/emu/grasscutter/game/city/CityInfoData.java +++ b/src/main/java/emu/grasscutter/game/city/CityInfoData.java @@ -4,14 +4,15 @@ import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.CityInfoOuterClass.CityInfo; import lombok.*; +@Getter @Entity public class CityInfoData { - @Getter @Setter private int cityId; + @Setter private int cityId; - @Getter @Setter + @Setter private int level = 1; // level of the city (include level SotS, level Frostbearing Trees, etc.) - @Getter @Setter private int numCrystal = 0; // number of crystals in the city + @Setter private int numCrystal = 0; // number of crystals in the city public CityInfoData(int cityId) { this.cityId = cityId; diff --git a/src/main/java/emu/grasscutter/game/combine/CombineResult.java b/src/main/java/emu/grasscutter/game/combine/CombineResult.java index df8ace74b..e5099e755 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineResult.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineResult.java @@ -1,42 +1,29 @@ package emu.grasscutter.game.combine; import emu.grasscutter.data.common.ItemParamData; +import lombok.Getter; + import java.util.List; +@Getter public class CombineResult { private List material; private List result; private List extra; private List back; - public List getMaterial() { - return material; - } - public void setMaterial(List material) { this.material = material; } - public List getResult() { - return result; - } - public void setResult(List result) { this.result = result; } - public List getExtra() { - return extra; - } - public void setExtra(List extra) { this.extra = extra; } - public List getBack() { - return back; - } - public void setBack(List back) { this.back = back; } diff --git a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java index 856278535..ae2697af5 100644 --- a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java +++ b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java @@ -1,23 +1,18 @@ package emu.grasscutter.game.combine; +import lombok.Getter; + import java.util.List; +@Getter public class ReliquaryDecomposeEntry { private int configId; private List items; - public int getConfigId() { - return configId; - } - public void setConfigId(int configId) { this.configId = configId; } - public List getItems() { - return items; - } - public void setItems(List items) { this.items = items; } diff --git a/src/main/java/emu/grasscutter/game/drop/DropData.java b/src/main/java/emu/grasscutter/game/drop/DropData.java index e82681f59..9cc033b02 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropData.java +++ b/src/main/java/emu/grasscutter/game/drop/DropData.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.drop; +import lombok.Getter; + +@Getter @Deprecated public class DropData { private int minWeight; @@ -10,42 +13,14 @@ public class DropData { private boolean share = false; private boolean give = false; - public boolean isGive() { - return give; - } - public void setGive(boolean give) { this.give = give; } - public int getItemId() { - return itemId; - } - public void setItemId(int itemId) { this.itemId = itemId; } - public int getMinCount() { - return minCount; - } - - public int getMaxCount() { - return maxCount; - } - - public int getMinWeight() { - return minWeight; - } - - public int getMaxWeight() { - return maxWeight; - } - - public boolean isShare() { - return share; - } - public void setIsShare(boolean share) { this.share = share; } diff --git a/src/main/java/emu/grasscutter/game/drop/DropInfo.java b/src/main/java/emu/grasscutter/game/drop/DropInfo.java index 0484d777a..f46e4986d 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropInfo.java +++ b/src/main/java/emu/grasscutter/game/drop/DropInfo.java @@ -1,17 +1,13 @@ package emu.grasscutter.game.drop; +import lombok.Getter; + import java.util.List; +@Getter @SuppressWarnings("deprecation") public class DropInfo { private int monsterId; private List dropDataList; - public int getMonsterId() { - return monsterId; - } - - public List getDropDataList() { - return dropDataList; - } } diff --git a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java index 00bdfcb45..2a3bea754 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java +++ b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java @@ -11,8 +11,11 @@ import emu.grasscutter.game.world.*; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.List; +@Getter @SuppressWarnings("deprecation") public class DropSystemLegacy extends BaseGameSystem { private final Int2ObjectMap> dropData; @@ -23,10 +26,6 @@ public class DropSystemLegacy extends BaseGameSystem { this.load(); } - public Int2ObjectMap> getDropData() { - return dropData; - } - public synchronized void load() { getDropData().clear(); try { diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java index f329eab9c..23807a498 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java @@ -1,23 +1,18 @@ package emu.grasscutter.game.dungeons; +import lombok.Getter; + import java.util.List; +@Getter public class DungeonDrop { private int dungeonId; private List drops; - public int getDungeonId() { - return dungeonId; - } - public void setDungeonId(int dungeonId) { this.dungeonId = dungeonId; } - public List getDrops() { - return drops; - } - public void setDrops(List drops) { this.drops = drops; } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java index 80e7b80af..a44592b54 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java @@ -1,7 +1,10 @@ package emu.grasscutter.game.dungeons; +import lombok.Getter; + import java.util.List; +@Getter public class DungeonDropEntry { private List counts; private List items; @@ -9,42 +12,22 @@ public class DungeonDropEntry { private List itemProbabilities; private boolean mpDouble; - public List getCounts() { - return counts; - } - public void setCounts(List counts) { this.counts = counts; } - public List getItems() { - return items; - } - public void setItems(List items) { this.items = items; } - public List getProbabilities() { - return probabilities; - } - public void setProbabilities(List probabilities) { this.probabilities = probabilities; } - public List getItemProbabilities() { - return itemProbabilities; - } - public void setItemProbabilities(List itemProbabilities) { this.itemProbabilities = itemProbabilities; } - public boolean isMpDouble() { - return mpDouble; - } - public void setMpDouble(boolean mpDouble) { this.mpDouble = mpDouble; } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java index f204860a7..8c6d1a288 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonEndStats.java @@ -3,11 +3,12 @@ package emu.grasscutter.game.dungeons; import emu.grasscutter.game.dungeons.dungeon_results.BaseDungeonResult; import lombok.Getter; +@Getter public class DungeonEndStats { - @Getter private final int killedMonsters; - @Getter private final int timeTaken; - @Getter private final int openChestCount; - @Getter private final BaseDungeonResult.DungeonEndReason dungeonResult; + private final int killedMonsters; + private final int timeTaken; + private final int openChestCount; + private final BaseDungeonResult.DungeonEndReason dungeonResult; public DungeonEndStats( int killedMonsters, diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java index 86a27021b..ab218b57f 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java @@ -4,9 +4,11 @@ import emu.grasscutter.game.dungeons.challenge.trigger.ChallengeTrigger; import emu.grasscutter.game.dungeons.enums.DungeonPassConditionType; import emu.grasscutter.game.world.Scene; import emu.grasscutter.scripts.data.SceneGroup; +import lombok.Getter; import java.util.List; +@Getter public final class DungeonChallenge extends WorldChallenge { /** @@ -22,10 +24,6 @@ public final class DungeonChallenge extends WorldChallenge { super(scene, group, challengeId, challengeIndex, paramList, timeLimit, goal, challengeTriggers); } - public boolean isStage() { - return stage; - } - public void setStage(boolean stage) { this.stage = stage; } diff --git a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/BaseDungeonResult.java b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/BaseDungeonResult.java index 367c6baa1..08c271ff6 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/BaseDungeonResult.java +++ b/src/main/java/emu/grasscutter/game/dungeons/dungeon_results/BaseDungeonResult.java @@ -7,9 +7,10 @@ import emu.grasscutter.net.proto.ParamListOuterClass; import emu.grasscutter.utils.Utils; import lombok.Getter; +@Getter public class BaseDungeonResult { - @Getter DungeonData dungeonData; - @Getter DungeonEndStats dungeonStats; + DungeonData dungeonData; + DungeonEndStats dungeonStats; public BaseDungeonResult(DungeonData dungeonData, DungeonEndStats dungeonStats) { this.dungeonData = dungeonData; diff --git a/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonPassConditionType.java b/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonPassConditionType.java index cfd1a47ee..a28e445e6 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonPassConditionType.java +++ b/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonPassConditionType.java @@ -3,6 +3,7 @@ package emu.grasscutter.game.dungeons.enums; import emu.grasscutter.scripts.constants.IntValueEnum; import lombok.Getter; +@Getter public enum DungeonPassConditionType implements IntValueEnum { DUNGEON_COND_NONE(0), DUNGEON_COND_KILL_MONSTER(3), @@ -15,7 +16,7 @@ public enum DungeonPassConditionType implements IntValueEnum { DUNGEON_COND_END_MULTISTAGE_PLAY(15) // Missing ; - @Getter private final int id; + private final int id; DungeonPassConditionType(int id) { this.id = id; diff --git a/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonType.java b/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonType.java index a5b5993fa..78c5de72f 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonType.java +++ b/src/main/java/emu/grasscutter/game/dungeons/enums/DungeonType.java @@ -2,6 +2,7 @@ package emu.grasscutter.game.dungeons.enums; import lombok.Getter; +@Getter public enum DungeonType { DUNGEON_NONE(false), DUNGEON_PLOT(true), @@ -41,7 +42,7 @@ public enum DungeonType { DUNGEON_EFFIGY_CHALLENGE_V2(false), DUNGEON_CHAR_AMUSEMENT(false); - @Getter private final boolean countsToBattlepass; + private final boolean countsToBattlepass; DungeonType(boolean countsToBattlepass) { this.countsToBattlepass = countsToBattlepass; diff --git a/src/main/java/emu/grasscutter/game/dungeons/enums/SettleShowType.java b/src/main/java/emu/grasscutter/game/dungeons/enums/SettleShowType.java index 1a591408c..6bf6d1b4f 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/enums/SettleShowType.java +++ b/src/main/java/emu/grasscutter/game/dungeons/enums/SettleShowType.java @@ -2,6 +2,7 @@ package emu.grasscutter.game.dungeons.enums; import lombok.Getter; +@Getter public enum SettleShowType { SETTLE_SHOW_NONE(0), SETTLE_SHOW_TIME_COST(1), @@ -9,7 +10,7 @@ public enum SettleShowType { SETTLE_SHOW_KILL_MONSTER_COUNT(3), SETTLE_SHOW_BLACKSCREEN(4); - @Getter private final int id; + private final int id; SettleShowType(int id) { this.id = id; diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index 8a4303430..764f7e426 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -33,11 +33,12 @@ import emu.grasscutter.utils.helpers.ProtoHelper; import it.unimi.dsi.fastutil.ints.Int2FloatMap; import lombok.*; +@Getter public class EntityAvatar extends GameEntity { - @Getter private final Avatar avatar; + private final Avatar avatar; - @Getter private PlayerDieType killedType; - @Getter private int killedBy; + private PlayerDieType killedType; + private int killedBy; public EntityAvatar(Avatar avatar) { this(null, avatar); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityItem.java b/src/main/java/emu/grasscutter/game/entity/EntityItem.java index 3946ab3f3..5da370503 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityItem.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityItem.java @@ -26,10 +26,11 @@ import emu.grasscutter.utils.helpers.ProtoHelper; import it.unimi.dsi.fastutil.ints.Int2FloatMap; import lombok.Getter; +@Getter public class EntityItem extends EntityBaseGadget { - @Getter private final GameItem item; - @Getter private final long guid; - @Getter private final boolean share; + private final GameItem item; + private final long guid; + private final boolean share; public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, int count) { this(scene, player, itemData, pos, count, true); diff --git a/src/main/java/emu/grasscutter/game/entity/EntitySolarIsotomaClientGadget.java b/src/main/java/emu/grasscutter/game/entity/EntitySolarIsotomaClientGadget.java index 9d3e13cdb..981bd1fa6 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntitySolarIsotomaClientGadget.java +++ b/src/main/java/emu/grasscutter/game/entity/EntitySolarIsotomaClientGadget.java @@ -6,10 +6,11 @@ import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.proto.EvtCreateGadgetNotifyOuterClass; import lombok.Getter; +@Getter public class EntitySolarIsotomaClientGadget extends EntityClientGadget { public static final int GADGET_ID = 41038001; public static final int ELEVATOR_GADGET_ID = 41038002; - @Getter private EntityGadget platformGadget; + private EntityGadget platformGadget; public EntitySolarIsotomaClientGadget( Scene scene, Player player, EvtCreateGadgetNotifyOuterClass.EvtCreateGadgetNotify notify) { diff --git a/src/main/java/emu/grasscutter/game/entity/EntityWorld.java b/src/main/java/emu/grasscutter/game/entity/EntityWorld.java index da6fbd7ae..586e6b386 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityWorld.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityWorld.java @@ -7,8 +7,9 @@ import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo; import it.unimi.dsi.fastutil.ints.*; import lombok.Getter; +@Getter public class EntityWorld extends GameEntity { - @Getter private final World world; + private final World world; public EntityWorld(World world) { super(null); diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetContent.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetContent.java index 091957832..01208e301 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetContent.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetContent.java @@ -4,7 +4,9 @@ import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.player.Player; import emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq; import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo; +import lombok.Getter; +@Getter public abstract class GadgetContent { private final EntityGadget gadget; @@ -12,10 +14,6 @@ public abstract class GadgetContent { this.gadget = gadget; } - public EntityGadget getGadget() { - return gadget; - } - public abstract boolean onInteract(Player player, GadgetInteractReq req); public abstract void onBuildProto(SceneGadgetInfo.Builder gadgetInfo); diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java index 03aab7d27..cbeecaf76 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java @@ -16,8 +16,10 @@ import emu.grasscutter.scripts.constants.EventType; import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp; import emu.grasscutter.utils.Utils; +import lombok.Getter; public final class GadgetGatherObject extends GadgetContent { + @Getter private int itemId; private boolean isForbidGuest; @@ -39,10 +41,6 @@ public final class GadgetGatherObject extends GadgetContent { } } - public int getItemId() { - return this.itemId; - } - public boolean isForbidGuest() { return isForbidGuest; } 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 0575e2ad9..221cfbd90 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 @@ -6,12 +6,13 @@ import emu.grasscutter.net.proto.PlatformInfoOuterClass.PlatformInfo; import emu.grasscutter.scripts.data.SceneGadget; import lombok.*; +@Getter public abstract class BaseRoute { - @Getter @Setter private boolean isStarted; - @Getter @Setter private boolean isActive; - @Getter @Setter private Position startRot; - @Getter @Setter private int startSceneTime; - @Getter @Setter private int stopSceneTime; + @Setter private boolean isStarted; + @Setter private boolean isActive; + @Setter private Position startRot; + @Setter private int startSceneTime; + @Setter private int stopSceneTime; BaseRoute(Position startRot, boolean isStarted, boolean isActive) { this.startRot = startRot; diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java b/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java index a70a8e769..26ff78b29 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java @@ -6,11 +6,12 @@ import emu.grasscutter.scripts.data.SceneGadget; import java.util.*; import lombok.*; +@Getter public class ConfigRoute extends BaseRoute { - @Getter @Setter private int routeId; - @Getter @Setter private int startIndex; - @Getter @Setter private List scheduledIndexes; + @Setter private int routeId; + @Setter private int startIndex; + @Setter private List scheduledIndexes; public ConfigRoute(SceneGadget gadget) { super(gadget); diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java b/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java index cd0c67efe..3174ba9e7 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java @@ -6,10 +6,11 @@ import emu.grasscutter.scripts.data.SceneGadget; import lombok.*; /** TODO implement point array routes, read from missing resources */ +@Getter public class PointArrayRoute extends BaseRoute { - @Getter @Setter int currentPoint; - @Getter @Setter int pointArrayId; + @Setter int currentPoint; + @Setter int pointArrayId; public PointArrayRoute(SceneGadget gadget) { super(gadget); diff --git a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardData.java b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardData.java index 8d322794d..37299e27c 100644 --- a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardData.java +++ b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardData.java @@ -4,10 +4,11 @@ import emu.grasscutter.game.inventory.GameItem; import emu.grasscutter.utils.Utils; import lombok.Getter; +@Getter public class ExpeditionRewardData { - @Getter private int itemId; - @Getter private int minCount; - @Getter private int maxCount; + private int itemId; + private int minCount; + private int maxCount; public GameItem getReward() { return new GameItem(itemId, Utils.randomRange(minCount, maxCount)); diff --git a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardDataList.java b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardDataList.java index 2712bfd27..0851abfc8 100644 --- a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardDataList.java +++ b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardDataList.java @@ -4,9 +4,10 @@ import emu.grasscutter.game.inventory.GameItem; import java.util.*; import lombok.Getter; +@Getter public class ExpeditionRewardDataList { - @Getter private int hourTime; - @Getter private List expeditionRewardData; + private int hourTime; + private List expeditionRewardData; public List getRewards() { List rewards = new ArrayList<>(); diff --git a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardInfo.java b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardInfo.java index b39475b83..8685ceddc 100644 --- a/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardInfo.java +++ b/src/main/java/emu/grasscutter/game/expedition/ExpeditionRewardInfo.java @@ -3,7 +3,8 @@ package emu.grasscutter.game.expedition; import java.util.List; import lombok.Getter; +@Getter public class ExpeditionRewardInfo { - @Getter private int expId; - @Getter private List expeditionRewardDataList; + private int expId; + private List expeditionRewardDataList; } diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index 21d483a29..41d80133a 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -7,17 +7,22 @@ import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief; import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.PlatformTypeOuterClass; import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture; +import lombok.Getter; import org.bson.types.ObjectId; @Entity(value = "friendships", useDiscriminator = false) public class Friendship { @Id private ObjectId id; + @Getter @Transient private Player owner; + @Getter @Indexed private int ownerId; + @Getter @Indexed private int friendId; private boolean isFriend; + @Getter private int askerId; private PlayerProfile profile; @@ -33,10 +38,6 @@ public class Friendship { this.askerId = asker.getUid(); } - public Player getOwner() { - return owner; - } - public void setOwner(Player owner) { this.owner = owner; } @@ -49,18 +50,6 @@ public class Friendship { this.isFriend = b; } - public int getOwnerId() { - return ownerId; - } - - public int getFriendId() { - return friendId; - } - - public int getAskerId() { - return askerId; - } - public void setAskerId(int askerId) { this.askerId = askerId; } diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java index b1bbc7172..3122e81b2 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java @@ -2,8 +2,11 @@ package emu.grasscutter.game.gacha; import dev.morphia.annotations.*; import java.util.Date; + +import lombok.Getter; import org.bson.types.ObjectId; +@Getter @Entity(value = "gachas", useDiscriminator = false) public class GachaRecord { @Id private ObjectId id; @@ -23,42 +26,22 @@ public class GachaRecord { this.gachaType = gachaType; } - public int getOwnerId() { - return ownerId; - } - public void setOwnerId(int ownerId) { this.ownerId = ownerId; } - public int getGachaType() { - return gachaType; - } - public void setGachaType(int type) { this.gachaType = type; } - public Date getTransactionDate() { - return transactionDate; - } - public void setTransactionDate(Date transactionDate) { this.transactionDate = transactionDate; } - public int getItemID() { - return itemID; - } - public void setItemID(int itemID) { this.itemID = itemID; } - public ObjectId getId() { - return id; - } - public void setId(ObjectId id) { this.id = id; } diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java index 649aa5972..3ef45bd39 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java @@ -26,11 +26,14 @@ import it.unimi.dsi.fastutil.ints.*; import java.nio.file.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; + +import lombok.Getter; import org.greenrobot.eventbus.Subscribe; public class GachaSystem extends BaseGameSystem { private static final int starglitterId = 221; private static final int stardustId = 222; + @Getter private final Int2ObjectMap gachaBanners; private WatchService watchService; @@ -41,10 +44,6 @@ public class GachaSystem extends BaseGameSystem { this.startWatcher(server); } - public Int2ObjectMap getGachaBanners() { - return gachaBanners; - } - public int randomRange(int min, int max) { // Both are inclusive return ThreadLocalRandom.current().nextInt(max - min + 1) + min; } diff --git a/src/main/java/emu/grasscutter/game/inventory/BagTab.java b/src/main/java/emu/grasscutter/game/inventory/BagTab.java index 697374b75..30fba692c 100644 --- a/src/main/java/emu/grasscutter/game/inventory/BagTab.java +++ b/src/main/java/emu/grasscutter/game/inventory/BagTab.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.*; +@Getter @RequiredArgsConstructor public enum BagTab { TAB_NONE(0), @@ -30,7 +31,7 @@ public enum BagTab { }); } - @Getter private final int value; + private final int value; /** * Fetches the bag tab by its value. diff --git a/src/main/java/emu/grasscutter/game/inventory/EquipType.java b/src/main/java/emu/grasscutter/game/inventory/EquipType.java index 00bf4e078..5efd255f1 100644 --- a/src/main/java/emu/grasscutter/game/inventory/EquipType.java +++ b/src/main/java/emu/grasscutter/game/inventory/EquipType.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum EquipType { EQUIP_NONE(0), EQUIP_BRACER(1), @@ -26,7 +27,7 @@ public enum EquipType { }); } - @Getter private final int value; + private final int value; EquipType(int value) { this.value = value; diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index 239ac8e9f..edea4ad33 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -28,6 +28,7 @@ import org.bson.types.ObjectId; @Entity(value = "items", useDiscriminator = false) public class GameItem { @Id private ObjectId id; + @Getter @Indexed private int ownerId; @Getter @Setter private int itemId; @Getter @Setter private int count; @@ -112,10 +113,6 @@ public class GameItem { } } - public int getOwnerId() { - return ownerId; - } - public void setOwner(Player player) { this.ownerId = player.getUid(); this.guid = player.getNextGameGuid(); diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 841921ac2..39a8d716c 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -21,10 +21,13 @@ import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.longs.*; import java.util.*; import javax.annotation.Nullable; + +import lombok.Getter; import lombok.val; public class Inventory extends BasePlayerManager implements Iterable { private final Long2ObjectMap store; + @Getter private final Int2ObjectMap inventoryTypes; public Inventory(Player player) { @@ -50,10 +53,6 @@ public class Inventory extends BasePlayerManager implements Iterable { return store; } - public Int2ObjectMap getInventoryTypes() { - return inventoryTypes; - } - public InventoryTab getInventoryTab(ItemType type) { return getInventoryTypes().get(type.getValue()); } diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java index 0dde8fd05..c1dd29797 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.inventory; +import lombok.Getter; + +@Getter public class ItemDef { private int itemId; private int count; @@ -9,18 +12,10 @@ public class ItemDef { this.count = count; } - public int getItemId() { - return itemId; - } - public void setItemId(int itemId) { this.itemId = itemId; } - public int getCount() { - return count; - } - public void setCount(int count) { this.count = count; } diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemQuality.java b/src/main/java/emu/grasscutter/game/inventory/ItemQuality.java index 954230d62..659527761 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemQuality.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemQuality.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum ItemQuality { QUALITY_NONE(0), QUALITY_WHITE(1), @@ -26,7 +27,7 @@ public enum ItemQuality { }); } - @Getter private final int value; + private final int value; ItemQuality(int value) { this.value = value; diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemType.java b/src/main/java/emu/grasscutter/game/inventory/ItemType.java index c6ab80e33..237d22318 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemType.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemType.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum ItemType { ITEM_NONE(0), ITEM_VIRTUAL(1), @@ -26,7 +27,7 @@ public enum ItemType { }); } - @Getter private final int value; + private final int value; ItemType(int value) { this.value = value; diff --git a/src/main/java/emu/grasscutter/game/inventory/MaterialType.java b/src/main/java/emu/grasscutter/game/inventory/MaterialType.java index e53764744..ba34eb632 100644 --- a/src/main/java/emu/grasscutter/game/inventory/MaterialType.java +++ b/src/main/java/emu/grasscutter/game/inventory/MaterialType.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum MaterialType { MATERIAL_NONE(0), MATERIAL_FOOD(1), @@ -60,7 +61,7 @@ public enum MaterialType { }); } - @Getter private final int value; + private final int value; MaterialType(int value) { this.value = value; diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index 7acfd5a22..be585a000 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -11,11 +11,15 @@ import emu.grasscutter.net.proto.MailCollectStateOuterClass.MailCollectState; import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; import java.time.Instant; import java.util.*; + +import lombok.Getter; import org.bson.types.ObjectId; @Entity(value = "mail", useDiscriminator = false) public final class Mail { + @Getter @Id private ObjectId id; + @Getter @Indexed private int ownerUid; public final MailContent mailContent; public final List itemList; @@ -59,14 +63,6 @@ public final class Mail { this.stateValue = state; // Different mailboxes, 1 = Default, 3 = Gift-box. } - public ObjectId getId() { - return id; - } - - public int getOwnerUid() { - return ownerUid; - } - public void setOwnerUid(int ownerUid) { this.ownerUid = ownerUid; } diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index 2862f6ebe..a14b0cafb 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -5,8 +5,11 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.*; import emu.grasscutter.server.event.player.PlayerReceiveMailEvent; import emu.grasscutter.server.packet.send.*; +import lombok.Getter; + import java.util.*; +@Getter public class MailHandler extends BasePlayerManager { private final List mail; @@ -16,10 +19,6 @@ public class MailHandler extends BasePlayerManager { this.mail = new ArrayList<>(); } - public List getMail() { - return mail; - } - // ---------------------MAIL------------------------ public void sendMail(Mail message) { diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java index d73778cca..b8237fcea 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java @@ -8,12 +8,16 @@ import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.data.*; import emu.grasscutter.utils.Utils; +import lombok.Getter; + import java.util.*; public final class BlossomActivity { private final SceneGroup tempSceneGroup; + @Getter private final WorldChallenge challenge; + @Getter private final EntityGadget gadget; private EntityGadget chest; private int step; @@ -49,10 +53,6 @@ public final class BlossomActivity { // this.challengeTriggers.add(new InTimeTrigger()); } - public WorldChallenge getChallenge() { - return this.challenge; - } - public void setMonsters(List monsters) { this.activeMonsters.clear(); this.activeMonsters.addAll(monsters); @@ -119,10 +119,6 @@ public final class BlossomActivity { } } - public EntityGadget getGadget() { - return gadget; - } - public EntityGadget getChest() { if (chest == null) { EntityGadget rewardGadget = diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomConfig.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomConfig.java index a8652e8fe..f151aad48 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomConfig.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomConfig.java @@ -3,9 +3,10 @@ package emu.grasscutter.game.managers.blossom; import java.util.*; import lombok.Getter; +@Getter public class BlossomConfig { - @Getter private int monsterFightingVolume; + private int monsterFightingVolume; // @Getter private Int2ObjectMap monsterIdsPerDifficulty; // Need to wrangle Gson for // this - @Getter private Map> monsterIdsPerDifficulty; + private Map> monsterIdsPerDifficulty; } diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java index 069e469c5..b87074346 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomType.java @@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.ints.*; import java.util.stream.*; import lombok.Getter; +@Getter public enum BlossomType { GOLD(70360056, 101001001, 1), BLUE(70360057, 101002003, 2); @@ -12,9 +13,9 @@ public enum BlossomType { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>( Stream.of(values()).collect(Collectors.toMap(BlossomType::getGadgetId, x -> x))); - @Getter private final int gadgetId; - @Getter private final int circleCampId; - @Getter private final int blossomChestId; + private final int gadgetId; + private final int circleCampId; + private final int blossomChestId; BlossomType(int gadgetId, int circleCampId, int blossomChestId) { this.gadgetId = gadgetId; diff --git a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java index f29467eae..45fb27507 100644 --- a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java +++ b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java @@ -1,6 +1,13 @@ package emu.grasscutter.game.managers.deforestation; +import lombok.Getter; + public class HitTreeRecord { + /** + * -- GETTER -- + * get unique id + */ + @Getter private final int unique; private short count; // hit this tree times private long time; // last available hitting time @@ -36,11 +43,6 @@ public class HitTreeRecord { } } - /** get unique id */ - public int getUnique() { - return unique; - } - @Override public String toString() { return "HitTreeRecord{" + "unique=" + unique + ", count=" + count + ", time=" + time + '}'; diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java index 6832294a0..b42c2e6ef 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java @@ -1,16 +1,12 @@ package emu.grasscutter.game.managers.energy; +import lombok.Getter; + import java.util.List; +@Getter public class EnergyDropEntry { private int dropId; private List dropList; - public int getDropId() { - return this.dropId; - } - - public List getDropList() { - return this.dropList; - } } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java index 2ba4d5842..72d3763b3 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java @@ -1,14 +1,10 @@ package emu.grasscutter.game.managers.energy; +import lombok.Getter; + +@Getter public class EnergyDropInfo { private int ballId; private int count; - public int getBallId() { - return this.ballId; - } - - public int getCount() { - return this.count; - } } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java index b7047a930..80fbcc686 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java @@ -1,16 +1,12 @@ package emu.grasscutter.game.managers.energy; +import lombok.Getter; + import java.util.List; +@Getter public class SkillParticleGenerationEntry { private int avatarId; private List amountList; - public int getAvatarId() { - return this.avatarId; - } - - public List getAmountList() { - return this.amountList; - } } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java index c9ce4067a..d46ee16ef 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java @@ -1,14 +1,10 @@ package emu.grasscutter.game.managers.energy; +import lombok.Getter; + +@Getter public class SkillParticleGenerationInfo { private int value; private int chance; - public int getValue() { - return this.value; - } - - public int getChance() { - return this.chance; - } } diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java index fd2408645..f27d5cc9a 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java @@ -1,17 +1,24 @@ package emu.grasscutter.game.managers.forging; import dev.morphia.annotations.Entity; +import lombok.Getter; @Entity public class ActiveForgeData { + @Getter private int forgeId; + @Getter private int avatarId; + @Getter private int count; + @Getter private int startTime; + @Getter private int forgeTime; private int lastUnfinishedCount; + @Getter private boolean changed; public int getFinishedCount(int currentTime) { @@ -35,50 +42,26 @@ public class ActiveForgeData { return this.startTime + this.forgeTime * this.count; } - public int getForgeId() { - return this.forgeId; - } - public void setForgeId(int value) { this.forgeId = value; } - public int getAvatarId() { - return this.avatarId; - } - public void setAvatarId(int value) { this.avatarId = value; } - public int getCount() { - return count; - } - public void setCount(int value) { this.count = value; } - public int getStartTime() { - return this.startTime; - } - public void setStartTime(int value) { this.startTime = value; } - public int getForgeTime() { - return this.forgeTime; - } - public void setForgeTime(int value) { this.forgeTime = value; } - public boolean isChanged() { - return this.changed; - } - public void setChanged(boolean value) { this.changed = value; } diff --git a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java index 6960a8595..a8f05337c 100644 --- a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java +++ b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java @@ -5,7 +5,9 @@ import emu.grasscutter.game.world.Position; import emu.grasscutter.net.proto.MapMarkFromTypeOuterClass.MapMarkFromType; import emu.grasscutter.net.proto.MapMarkPointOuterClass.MapMarkPoint; import emu.grasscutter.net.proto.MapMarkPointTypeOuterClass.MapMarkPointType; +import lombok.Getter; +@Getter @Entity public class MapMark { private int sceneId; @@ -32,31 +34,4 @@ public class MapMark { this.questId = mapMarkPoint.getQuestId(); } - public int getSceneId() { - return this.sceneId; - } - - public String getName() { - return this.name; - } - - public Position getPosition() { - return this.position; - } - - public MapMarkPointType getMapMarkPointType() { - return this.mapMarkPointType; - } - - public int getMonsterId() { - return this.monsterId; - } - - public MapMarkFromType getMapMarkFromType() { - return this.mapMarkFromType; - } - - public int getQuestId() { - return this.questId; - } } diff --git a/src/main/java/emu/grasscutter/game/player/BasePlayerDataManager.java b/src/main/java/emu/grasscutter/game/player/BasePlayerDataManager.java index a8f70bfb4..8e29adee6 100644 --- a/src/main/java/emu/grasscutter/game/player/BasePlayerDataManager.java +++ b/src/main/java/emu/grasscutter/game/player/BasePlayerDataManager.java @@ -1,7 +1,9 @@ package emu.grasscutter.game.player; +import lombok.Getter; import lombok.NonNull; +@Getter public abstract class BasePlayerDataManager { protected transient Player player; @@ -11,10 +13,6 @@ public abstract class BasePlayerDataManager { this.player = player; } - public Player getPlayer() { - return this.player; - } - public void setPlayer(Player player) { if (this.player == null) { this.player = player; diff --git a/src/main/java/emu/grasscutter/game/player/BasePlayerManager.java b/src/main/java/emu/grasscutter/game/player/BasePlayerManager.java index 1a42840b5..c2447cefb 100644 --- a/src/main/java/emu/grasscutter/game/player/BasePlayerManager.java +++ b/src/main/java/emu/grasscutter/game/player/BasePlayerManager.java @@ -2,10 +2,10 @@ package emu.grasscutter.game.player; import lombok.*; +@Getter public abstract class BasePlayerManager { protected final transient Player player; - @Getter @Setter(AccessLevel.PROTECTED) protected boolean loaded = false; @@ -13,10 +13,6 @@ public abstract class BasePlayerManager { this.player = player; } - public Player getPlayer() { - return this.player; - } - /** Saves the player to the database */ public void save() { getPlayer().save(); diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index e951dd307..684f1c1eb 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -1645,10 +1645,10 @@ public class Player implements PlayerHook, FieldFetch { .formatted(this.id, this.nickname, this.account); } + @Getter public enum SceneLoadState { NONE(0), LOADING(1), INIT(2), LOADED(3); - @Getter private final int value; SceneLoadState(int value) { diff --git a/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java b/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java index 85301daa6..7fa3f5f6e 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerBirthday.java @@ -2,7 +2,9 @@ package emu.grasscutter.game.player; import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday; +import lombok.Getter; +@Getter @Entity public class PlayerBirthday { private int day; @@ -32,19 +34,11 @@ public class PlayerBirthday { return this; } - public int getDay() { - return this.day; - } - public PlayerBirthday setDay(int value) { this.day = value; return this; } - public int getMonth() { - return this.month; - } - public PlayerBirthday setMonth(int value) { this.month = value; return this; diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java index 1d1488bd4..1f3f1e1c8 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java @@ -1,6 +1,8 @@ package emu.grasscutter.game.player; import dev.morphia.annotations.Entity; +import lombok.Getter; + import java.util.*; @Entity(useDiscriminator = false) @@ -43,6 +45,7 @@ public class PlayerCollectionRecords { } } + @Getter @Entity public static class CollectionRecord { private int configId; @@ -56,12 +59,5 @@ public class PlayerCollectionRecords { this.expiredTime = expiredTime; } - public int getConfigId() { - return configId; - } - - public long getExpiredTime() { - return expiredTime; - } } } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerProgress.java b/src/main/java/emu/grasscutter/game/player/PlayerProgress.java index 43ce48554..dffaea0e8 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerProgress.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerProgress.java @@ -83,11 +83,12 @@ public class PlayerProgress { return questProgressCountMap.merge(progressId, 0, Integer::min); } + @Getter @Entity @NoArgsConstructor public static class ItemEntry { - @Getter private int itemId; - @Getter @Setter private int obtainedCount; + private int itemId; + @Setter private int obtainedCount; ItemEntry(int itemId) { this.itemId = itemId; diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 397682cde..86c76fef5 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -5,8 +5,11 @@ 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 lombok.Getter; + import java.util.*; +@Getter @Entity public final class TeamInfo { private String name; @@ -22,18 +25,10 @@ public final class TeamInfo { this.avatars = avatars; } - public String getName() { - return name; - } - public void setName(String name) { this.name = name; } - public List getAvatars() { - return avatars; - } - public int size() { return avatars.size(); } diff --git a/src/main/java/emu/grasscutter/game/props/ActionReason.java b/src/main/java/emu/grasscutter/game/props/ActionReason.java index 57867ed35..251aa6fbc 100644 --- a/src/main/java/emu/grasscutter/game/props/ActionReason.java +++ b/src/main/java/emu/grasscutter/game/props/ActionReason.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum ActionReason { None(0), QuestItem(1), @@ -206,7 +209,4 @@ public enum ActionReason { return stringMap.getOrDefault(name, None); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java index d95a858a1..d5273f4e9 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.props; +import lombok.Getter; + +@Getter public enum BattlePassMissionRefreshType { BATTLE_PASS_MISSION_REFRESH_DAILY(0), BATTLE_PASS_MISSION_REFRESH_CYCLE_CROSS_SCHEDULE(1), // Weekly @@ -12,7 +15,4 @@ public enum BattlePassMissionRefreshType { this.value = value; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java index 385f0775f..1abc80f1d 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java @@ -1,7 +1,9 @@ package emu.grasscutter.game.props; import emu.grasscutter.net.proto.BattlePassMissionOuterClass.BattlePassMission.MissionStatus; +import lombok.Getter; +@Getter public enum BattlePassMissionStatus { MISSION_STATUS_INVALID(0, MissionStatus.MISSION_STATUS_INVALID), MISSION_STATUS_UNFINISHED(1, MissionStatus.MISSION_STATUS_UNFINISHED), @@ -16,11 +18,4 @@ public enum BattlePassMissionStatus { this.missionStatus = missionStatus; // In case proto enum values change later } - public int getValue() { - return value; - } - - public MissionStatus getMissionStatus() { - return missionStatus; - } } diff --git a/src/main/java/emu/grasscutter/game/props/CampTargetType.java b/src/main/java/emu/grasscutter/game/props/CampTargetType.java index a1076a0ae..955b642cc 100644 --- a/src/main/java/emu/grasscutter/game/props/CampTargetType.java +++ b/src/main/java/emu/grasscutter/game/props/CampTargetType.java @@ -2,9 +2,12 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum CampTargetType implements IntValueEnum { None(0), Alliance(1), @@ -32,10 +35,6 @@ public enum CampTargetType implements IntValueEnum { this.value = value; } - public int getValue() { - return value; - } - public static CampTargetType getTypeByValue(int value) { return map.getOrDefault(value, None); } diff --git a/src/main/java/emu/grasscutter/game/props/ClimateType.java b/src/main/java/emu/grasscutter/game/props/ClimateType.java index 71a7c28e4..39ed137b0 100644 --- a/src/main/java/emu/grasscutter/game/props/ClimateType.java +++ b/src/main/java/emu/grasscutter/game/props/ClimateType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum ClimateType { CLIMATE_NONE(0), CLIMATE_SUNNY(1), @@ -45,10 +48,6 @@ public enum ClimateType { return stringMap.getOrDefault(name, CLIMATE_NONE); } - public int getValue() { - return this.value; - } - public String getShortName() { return this.name().substring(8).toLowerCase(); } diff --git a/src/main/java/emu/grasscutter/game/props/ElementType.java b/src/main/java/emu/grasscutter/game/props/ElementType.java index 9ef59130c..5a8c49725 100644 --- a/src/main/java/emu/grasscutter/game/props/ElementType.java +++ b/src/main/java/emu/grasscutter/game/props/ElementType.java @@ -7,6 +7,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum ElementType implements IntValueEnum { None(0, FightProperty.FIGHT_PROP_CUR_WIND_ENERGY, FightProperty.FIGHT_PROP_MAX_WIND_ENERGY), Fire( @@ -80,12 +81,12 @@ public enum ElementType implements IntValueEnum { }); } - @Getter private final int value; - @Getter private final int teamResonanceId; - @Getter private final FightProperty curEnergyProp; - @Getter private final FightProperty maxEnergyProp; - @Getter private final int depotIndex; - @Getter private final int configHash; + private final int value; + private final int teamResonanceId; + private final FightProperty curEnergyProp; + private final FightProperty maxEnergyProp; + private final int depotIndex; + private final int configHash; ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp) { this(value, curEnergyProp, maxEnergyProp, 0, null, 0); diff --git a/src/main/java/emu/grasscutter/game/props/EnterReason.java b/src/main/java/emu/grasscutter/game/props/EnterReason.java index 7ef342e86..683c486db 100644 --- a/src/main/java/emu/grasscutter/game/props/EnterReason.java +++ b/src/main/java/emu/grasscutter/game/props/EnterReason.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum EnterReason { None(0), Login(1), @@ -64,7 +67,4 @@ public enum EnterReason { return stringMap.getOrDefault(name, None); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/EntityIdType.java b/src/main/java/emu/grasscutter/game/props/EntityIdType.java index cee0a2981..622069146 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityIdType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityIdType.java @@ -1,7 +1,10 @@ package emu.grasscutter.game.props; +import lombok.Getter; + import java.util.*; +@Getter public enum EntityIdType { AVATAR(0x01), MONSTER(0x02), @@ -35,7 +38,4 @@ public enum EntityIdType { return map.getOrDefault(entityId, EntityType.None); } - public int getId() { - return id; - } } diff --git a/src/main/java/emu/grasscutter/game/props/EntityType.java b/src/main/java/emu/grasscutter/game/props/EntityType.java index 7d074b841..883258582 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityType.java @@ -2,9 +2,12 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum EntityType implements IntValueEnum { None(0), Avatar(1), @@ -102,7 +105,4 @@ public enum EntityType implements IntValueEnum { return stringMap.getOrDefault(name, None); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/FetterState.java b/src/main/java/emu/grasscutter/game/props/FetterState.java index aac46461d..8ee65407d 100644 --- a/src/main/java/emu/grasscutter/game/props/FetterState.java +++ b/src/main/java/emu/grasscutter/game/props/FetterState.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum FetterState { NONE(0), NOT_OPEN(1), @@ -36,7 +39,4 @@ public enum FetterState { return stringMap.getOrDefault(name, NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/FightProperty.java b/src/main/java/emu/grasscutter/game/props/FightProperty.java index f94bc78a5..bd4990495 100644 --- a/src/main/java/emu/grasscutter/game/props/FightProperty.java +++ b/src/main/java/emu/grasscutter/game/props/FightProperty.java @@ -8,6 +8,7 @@ import java.util.function.Consumer; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum FightProperty { FIGHT_PROP_NONE(0), FIGHT_PROP_BASE_HP(1), @@ -240,10 +241,6 @@ public enum FightProperty { return !flatProps.contains(prop); } - public int getId() { - return id; - } - @Getter public static class CompoundProperty { private final FightProperty result; diff --git a/src/main/java/emu/grasscutter/game/props/GrowCurve.java b/src/main/java/emu/grasscutter/game/props/GrowCurve.java index 2ec0db35d..4734350f7 100644 --- a/src/main/java/emu/grasscutter/game/props/GrowCurve.java +++ b/src/main/java/emu/grasscutter/game/props/GrowCurve.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum GrowCurve { GROW_CURVE_NONE(0), GROW_CURVE_HP(1), @@ -97,7 +100,4 @@ public enum GrowCurve { return stringMap.getOrDefault(name, GROW_CURVE_NONE); } - public int getId() { - return id; - } } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseInt.java b/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseInt.java index 34ec476d8..dd0eec681 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseInt.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseAction/ItemUseInt.java @@ -2,8 +2,9 @@ package emu.grasscutter.game.props.ItemUseAction; import lombok.Getter; +@Getter public abstract class ItemUseInt extends ItemUseAction { - @Getter protected int i = 0; + protected int i = 0; public ItemUseInt(String[] useParam) { try { diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java index 6fd704e6a..66eff8ed6 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java @@ -1,8 +1,11 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.stream.Stream; +@Getter public enum ItemUseOp { ITEM_USE_NONE(0), ITEM_USE_ACCEPT_QUEST(1), @@ -65,7 +68,4 @@ public enum ItemUseOp { return map.getOrDefault(value, ITEM_USE_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java index c1eda8fa3..5ad8671c2 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java @@ -1,8 +1,11 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.stream.Stream; +@Getter public enum ItemUseTarget { ITEM_USE_TARGET_NONE(0), ITEM_USE_TARGET_CUR_AVATAR(1), @@ -29,7 +32,4 @@ public enum ItemUseTarget { return map.getOrDefault(value, ITEM_USE_TARGET_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/LifeState.java b/src/main/java/emu/grasscutter/game/props/LifeState.java index 1785b2faf..52a0622e0 100644 --- a/src/main/java/emu/grasscutter/game/props/LifeState.java +++ b/src/main/java/emu/grasscutter/game/props/LifeState.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum LifeState { LIFE_NONE(0), LIFE_ALIVE(1), @@ -36,7 +39,4 @@ public enum LifeState { return stringMap.getOrDefault(name, LIFE_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/MonsterType.java b/src/main/java/emu/grasscutter/game/props/MonsterType.java index 69558ee83..adc080d4b 100644 --- a/src/main/java/emu/grasscutter/game/props/MonsterType.java +++ b/src/main/java/emu/grasscutter/game/props/MonsterType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum MonsterType { MONSTER_NONE(0), MONSTER_ORDINARY(1), @@ -38,7 +41,4 @@ public enum MonsterType { return stringMap.getOrDefault(name, MONSTER_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/PlayerProperty.java b/src/main/java/emu/grasscutter/game/props/PlayerProperty.java index 4c5995873..9c4d40b59 100644 --- a/src/main/java/emu/grasscutter/game/props/PlayerProperty.java +++ b/src/main/java/emu/grasscutter/game/props/PlayerProperty.java @@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.ints.*; import java.util.stream.Stream; import lombok.Getter; +@Getter public enum PlayerProperty { PROP_NONE(0), PROP_EXP(1001, 0), @@ -73,8 +74,8 @@ public enum PlayerProperty { Stream.of(values()).forEach(e -> map.put(e.getId(), e)); } - @Getter private final int id, min, max; - @Getter private final boolean dynamicRange; + private final int id, min, max; + private final boolean dynamicRange; PlayerProperty(int id, int min, int max, boolean dynamicRange) { this.id = id; diff --git a/src/main/java/emu/grasscutter/game/props/RefreshType.java b/src/main/java/emu/grasscutter/game/props/RefreshType.java index 8f1baa132..5df028a79 100644 --- a/src/main/java/emu/grasscutter/game/props/RefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/RefreshType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum RefreshType { REFRESH_NONE(0), REFRESH_INTERVAL(1), @@ -28,10 +31,6 @@ public enum RefreshType { this.value = value; } - public int getValue() { - return value; - } - public static RefreshType getTypeByValue(int value) { return map.getOrDefault(value, REFRESH_NONE); } diff --git a/src/main/java/emu/grasscutter/game/props/SceneType.java b/src/main/java/emu/grasscutter/game/props/SceneType.java index 09bd084b3..48015a7e8 100644 --- a/src/main/java/emu/grasscutter/game/props/SceneType.java +++ b/src/main/java/emu/grasscutter/game/props/SceneType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum SceneType { SCENE_NONE(0), SCENE_WORLD(1), @@ -39,7 +42,4 @@ public enum SceneType { return stringMap.getOrDefault(name, SCENE_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java index 7393fbf9d..a55e13f3b 100644 --- a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java +++ b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java @@ -1,8 +1,11 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.stream.Stream; +@Getter public enum ServerBuffType { SERVER_BUFF_NONE(0), SERVER_BUFF_AVATAR(1), @@ -27,7 +30,4 @@ public enum ServerBuffType { return map.getOrDefault(value, SERVER_BUFF_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java index 98ae0a3c3..36c855635 100644 --- a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java +++ b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum WatcherTriggerType { TRIGGER_NONE(0), TRIGGER_COMBAT_CONFIG_COMMON(1), @@ -331,7 +334,4 @@ public enum WatcherTriggerType { return stringMap.getOrDefault(name, TRIGGER_NONE); } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/props/WeaponType.java b/src/main/java/emu/grasscutter/game/props/WeaponType.java index 5d1b9640d..d70af53be 100644 --- a/src/main/java/emu/grasscutter/game/props/WeaponType.java +++ b/src/main/java/emu/grasscutter/game/props/WeaponType.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum WeaponType { WEAPON_NONE(0), WEAPON_SWORD_ONE_HAND(1, 10, 5), @@ -54,15 +57,4 @@ public enum WeaponType { return stringMap.getOrDefault(name, WEAPON_NONE); } - public int getValue() { - return value; - } - - public int getEnergyGainInitialProbability() { - return energyGainInitialProbability; - } - - public int getEnergyGainIncreaseProbability() { - return energyGainIncreaseProbability; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/RewindData.java b/src/main/java/emu/grasscutter/game/quest/RewindData.java index d17ee1876..825593297 100644 --- a/src/main/java/emu/grasscutter/game/quest/RewindData.java +++ b/src/main/java/emu/grasscutter/game/quest/RewindData.java @@ -8,9 +8,10 @@ public class RewindData { AvatarData avatar; List npcs; + @Getter @Data public static class AvatarData { - @Getter private String pos; + private String pos; } @Data diff --git a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java index 17d7aac83..dd2e5cd91 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java @@ -3,8 +3,11 @@ package emu.grasscutter.game.quest.enums; import emu.grasscutter.Grasscutter; import java.util.*; import java.util.function.BooleanSupplier; + +import lombok.Getter; import org.jetbrains.annotations.NotNull; +@Getter public enum LogicType { LOGIC_NONE(0), LOGIC_AND(1), @@ -89,7 +92,4 @@ public enum LogicType { } } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java index a89b09f3a..02019c360 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.quest.enums; +import lombok.Getter; + +@Getter public enum ParentQuestState { PARENT_QUEST_STATE_NONE(0), PARENT_QUEST_STATE_FINISHED(1), @@ -12,7 +15,4 @@ public enum ParentQuestState { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java index 24d8fcf07..9cb1faa83 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum QuestCond implements QuestTrigger { QUEST_COND_NONE(0), QUEST_COND_STATE_EQUAL(1), @@ -92,10 +95,6 @@ public enum QuestCond implements QuestTrigger { this.value = id; } - public int getValue() { - return value; - } - private static final Int2ObjectMap contentMap = new Int2ObjectOpenHashMap<>(); private static final Map contentStringMap = new HashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java index a7e66b874..053b559e5 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum QuestContent implements QuestTrigger { QUEST_CONTENT_NONE(0), QUEST_CONTENT_KILL_MONSTER(1), // currently unused @@ -88,10 +91,6 @@ public enum QuestContent implements QuestTrigger { this.value = id; } - public int getValue() { - return value; - } - private static final Int2ObjectMap contentMap = new Int2ObjectOpenHashMap<>(); private static final Map contentStringMap = new HashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java index 31924ca12..2b14a98b2 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java @@ -1,9 +1,12 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; +@Getter public enum QuestExec implements QuestTrigger { QUEST_EXEC_NONE(0), QUEST_EXEC_DEL_PACK_ITEM(1), @@ -85,10 +88,6 @@ public enum QuestExec implements QuestTrigger { this.value = id; } - public int getValue() { - return value; - } - private static final Int2ObjectMap contentMap = new Int2ObjectOpenHashMap<>(); private static final Map contentStringMap = new HashMap<>(); diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java index 90cd6ea2d..d9bbac8d4 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.quest.enums; +import lombok.Getter; + +@Getter public enum QuestGuideType { QUEST_GUIDE_NONE(0), QUEST_GUIDE_LOCATION(1), @@ -11,7 +14,4 @@ public enum QuestGuideType { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java index 2ea9c61f4..db76cdf7d 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.quest.enums; +import lombok.Getter; + +@Getter public enum QuestShowType { QUEST_SHOW(0), QUEST_HIDDEN(1); @@ -10,7 +13,4 @@ public enum QuestShowType { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java index 0bccccb34..692343835 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java @@ -1,7 +1,9 @@ package emu.grasscutter.game.quest.enums; import emu.grasscutter.scripts.constants.IntValueEnum; +import lombok.Getter; +@Getter public enum QuestState implements IntValueEnum { QUEST_STATE_NONE(0), QUEST_STATE_UNSTARTED(1), @@ -22,7 +24,4 @@ public enum QuestState implements IntValueEnum { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java index be1e31fe7..8fa4d6e75 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.quest.enums; +import lombok.Getter; + +@Getter public enum QuestType { AQ(0), FQ(1), @@ -16,7 +19,4 @@ public enum QuestType { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java index d59d1737b..f5c7d14d1 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java @@ -1,5 +1,8 @@ package emu.grasscutter.game.quest.enums; +import lombok.Getter; + +@Getter public enum ShowQuestGuideType { QUEST_GUIDE_ITEM_ENABLE(0), QUEST_GUIDE_ITEM_DISABLE(1), @@ -11,7 +14,4 @@ public enum ShowQuestGuideType { this.value = id; } - public int getValue() { - return value; - } } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java index 827826803..e75e7ef24 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java @@ -1,7 +1,9 @@ package emu.grasscutter.game.shop; import dev.morphia.annotations.Entity; +import lombok.Getter; +@Getter @Entity public class ShopLimit { private int shopGoodId; @@ -9,34 +11,18 @@ public class ShopLimit { private int hasBoughtInPeriod = 0; private int nextRefreshTime = 0; - public int getShopGoodId() { - return shopGoodId; - } - public void setShopGoodId(int shopGoodId) { this.shopGoodId = shopGoodId; } - public int getHasBought() { - return hasBought; - } - public void setHasBought(int hasBought) { this.hasBought = hasBought; } - public int getNextRefreshTime() { - return nextRefreshTime; - } - public void setNextRefreshTime(int nextRefreshTime) { this.nextRefreshTime = nextRefreshTime; } - public int getHasBoughtInPeriod() { - return hasBoughtInPeriod; - } - public void setHasBoughtInPeriod(int hasBoughtInPeriod) { this.hasBoughtInPeriod = hasBoughtInPeriod; } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index b1e47d9f4..71c6122ab 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -9,11 +9,14 @@ import emu.grasscutter.data.excels.ShopGoodsData; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; +import lombok.Getter; + import java.util.*; public class ShopSystem extends BaseGameSystem { private static final int REFRESH_HOUR = 4; // In GMT+8 server private static final String TIME_ZONE = "Asia/Shanghai"; // GMT+8 Timezone + @Getter private final Int2ObjectMap> shopData; private final Int2ObjectMap> shopChestData; @@ -36,10 +39,6 @@ public class ShopSystem extends BaseGameSystem { }; } - public Int2ObjectMap> getShopData() { - return shopData; - } - public List getShopChestData(int chestId) { return this.shopChestData.get(chestId); } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopTable.java b/src/main/java/emu/grasscutter/game/shop/ShopTable.java index a2990d7ff..78a8c201e 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopTable.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopTable.java @@ -1,23 +1,18 @@ package emu.grasscutter.game.shop; +import lombok.Getter; + import java.util.*; +@Getter public class ShopTable { private int shopId; private List items = new ArrayList<>(); - public int getShopId() { - return shopId; - } - public void setShopId(int shopId) { this.shopId = shopId; } - public List getItems() { - return items; - } - public void setItems(List items) { this.items = items; } diff --git a/src/main/java/emu/grasscutter/game/talk/TalkExec.java b/src/main/java/emu/grasscutter/game/talk/TalkExec.java index f6a7aefde..0e92462cc 100644 --- a/src/main/java/emu/grasscutter/game/talk/TalkExec.java +++ b/src/main/java/emu/grasscutter/game/talk/TalkExec.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.stream.Stream; import lombok.*; +@Getter @AllArgsConstructor public enum TalkExec { TALK_EXEC_NONE(0), @@ -56,5 +57,5 @@ public enum TalkExec { return execStringMap.getOrDefault(name, TALK_EXEC_NONE); } - @Getter private final int value; + private final int value; } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java index 245ec327d..12afe9f58 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java @@ -1,8 +1,11 @@ package emu.grasscutter.game.tower; import dev.morphia.annotations.Entity; +import lombok.Getter; + import java.util.*; +@Getter @Entity public class TowerLevelRecord { /** floorId in config */ @@ -33,26 +36,14 @@ public class TowerLevelRecord { return passedLevelMap.values().stream().mapToInt(Integer::intValue).sum(); } - public int getFloorId() { - return floorId; - } - public void setFloorId(int floorId) { this.floorId = floorId; } - public Map getPassedLevelMap() { - return passedLevelMap; - } - public void setPassedLevelMap(Map passedLevelMap) { this.passedLevelMap = passedLevelMap; } - public int getFloorStarRewardProgress() { - return floorStarRewardProgress; - } - public void setFloorStarRewardProgress(int floorStarRewardProgress) { this.floorStarRewardProgress = floorStarRewardProgress; } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java index ae6f86b00..c82ca6e23 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java @@ -1,33 +1,24 @@ package emu.grasscutter.game.tower; +import lombok.Getter; + import java.util.Date; +@Getter public class TowerScheduleConfig { private int scheduleId; private Date scheduleStartTime; private Date nextScheduleChangeTime; - public int getScheduleId() { - return scheduleId; - } - public void setScheduleId(int scheduleId) { this.scheduleId = scheduleId; } - public Date getScheduleStartTime() { - return scheduleStartTime; - } - public void setScheduleStartTime(Date scheduleStartTime) { this.scheduleStartTime = scheduleStartTime; } - public Date getNextScheduleChangeTime() { - return nextScheduleChangeTime; - } - public void setNextScheduleChangeTime(Date nextScheduleChangeTime) { this.nextScheduleChangeTime = nextScheduleChangeTime; } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java index 18c1036cd..5369ecb40 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java @@ -4,8 +4,11 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.data.*; import emu.grasscutter.data.excels.tower.TowerScheduleData; import emu.grasscutter.server.game.*; +import lombok.Getter; + import java.util.*; +@Getter public class TowerSystem extends BaseGameSystem { private TowerScheduleConfig towerScheduleConfig; @@ -23,10 +26,6 @@ public class TowerSystem extends BaseGameSystem { } } - public TowerScheduleConfig getTowerScheduleConfig() { - return towerScheduleConfig; - } - public TowerScheduleData getCurrentTowerScheduleData() { var data = GameData.getTowerScheduleDataMap().get(towerScheduleConfig.getScheduleId()); if (data == null) { diff --git a/src/main/java/emu/grasscutter/game/world/GridPosition.java b/src/main/java/emu/grasscutter/game/world/GridPosition.java index bd0e2e2ed..e7e02d5ba 100644 --- a/src/main/java/emu/grasscutter/game/world/GridPosition.java +++ b/src/main/java/emu/grasscutter/game/world/GridPosition.java @@ -6,16 +6,17 @@ import java.io.*; import java.util.List; import lombok.*; +@Getter @Entity public final class GridPosition implements Serializable { @Serial private static final long serialVersionUID = -2001232300615923575L; - @Getter @Setter private int x; + @Setter private int x; - @Getter @Setter private int z; + @Setter private int z; - @Getter @Setter private int width; + @Setter private int width; public GridPosition() {} diff --git a/src/main/java/emu/grasscutter/game/world/Location.java b/src/main/java/emu/grasscutter/game/world/Location.java index e6f5ca4fb..a1c720ee5 100644 --- a/src/main/java/emu/grasscutter/game/world/Location.java +++ b/src/main/java/emu/grasscutter/game/world/Location.java @@ -3,9 +3,11 @@ package emu.grasscutter.game.world; import dev.morphia.annotations.*; import lombok.*; +@Getter @Entity public class Location extends Position { - @Transient @Getter @Setter private Scene scene; + @Transient + @Setter private Scene scene; public Location(Scene scene, Position position) { this.set(position); diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 0c8483a13..854c57aaa 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -12,6 +12,7 @@ import java.util.List; import lombok.*; import lombok.experimental.Accessors; +@Getter @Entity @Accessors(chain = true) public class Position implements Serializable { @@ -24,21 +25,18 @@ public class Position implements Serializable { @SerializedName( value = "x", alternate = {"_x", "X"}) - @Getter @Setter private float x; @SerializedName( value = "y", alternate = {"_y", "Y"}) - @Getter @Setter private float y; @SerializedName( value = "z", alternate = {"_z", "Z"}) - @Getter @Setter private float z; diff --git a/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java b/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java index 8e903c469..0c9d3e2ce 100644 --- a/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java +++ b/src/main/java/emu/grasscutter/game/world/SpawnDataEntry.java @@ -4,17 +4,18 @@ import emu.grasscutter.data.GameDepot; import java.util.*; import lombok.*; +@Getter public class SpawnDataEntry { - @Getter @Setter private transient SpawnGroupEntry group; - @Getter private int monsterId; - @Getter private int gadgetId; - @Getter private int configId; - @Getter private int level; - @Getter private int poseId; - @Getter private int gatherItemId; - @Getter private int gadgetState; - @Getter private Position pos; - @Getter private Position rot; + @Setter private transient SpawnGroupEntry group; + private int monsterId; + private int gadgetId; + private int configId; + private int level; + private int poseId; + private int gatherItemId; + private int gadgetState; + private Position pos; + private Position rot; public GridBlockId getBlockId() { int scale = GridBlockId.getScale(gadgetId); @@ -25,18 +26,20 @@ public class SpawnDataEntry { (int) (pos.getZ() / GameDepot.BLOCK_SIZE[scale])); } + @Getter public static class SpawnGroupEntry { - @Getter private int sceneId; - @Getter private int groupId; - @Getter private int blockId; - @Getter @Setter private List spawns; + private int sceneId; + private int groupId; + private int blockId; + @Setter private List spawns; } + @Getter public static class GridBlockId { - @Getter private final int sceneId; - @Getter private final int scale; - @Getter private final int x; - @Getter private final int z; + private final int sceneId; + private final int scale; + private final int x; + private final int z; public GridBlockId(int sceneId, int scale, int x, int z) { this.sceneId = sceneId; diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index 115a57c80..bc7c6b8b7 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -51,6 +51,7 @@ public class World implements Iterable { @Getter private final EntityWorld entity; private int nextEntityId = 0; private int nextPeerId = 0; + @Getter private int worldLevel; @Getter private boolean isMultiplayer = false; @@ -121,10 +122,6 @@ public class World implements Iterable { return ++this.nextPeerId; } - public int getWorldLevel() { - return worldLevel; - } - public void setWorldLevel(int worldLevel) { this.worldLevel = worldLevel; } diff --git a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java index 39bc93717..5dd2d10bf 100644 --- a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java +++ b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java @@ -11,9 +11,12 @@ import emu.grasscutter.scripts.data.*; import emu.grasscutter.server.game.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; + +import lombok.Getter; import org.luaj.vm2.LuaError; public class WorldDataSystem extends BaseGameSystem { + @Getter private final Map chestInteractHandlerMap; // chestType-Handler private final Map sceneInvestigationGroupMap; // @@ -44,10 +47,6 @@ public class WorldDataSystem extends BaseGameSystem { } } - public Map getChestInteractHandlerMap() { - return chestInteractHandlerMap; - } - public RewardPreviewData getRewardByBossId(int monsterId) { var investigationMonsterData = GameData.getInvestigationMonsterDataMap().values().parallelStream() diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index da9a9436b..e6bf489f6 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -2,15 +2,20 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; +import lombok.Getter; + import java.io.*; public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; + @Getter private int opcode; private boolean shouldBuildHeader = false; + @Getter private byte[] header; + @Getter private byte[] data; // Encryption private boolean useDispatchKey; @@ -29,10 +34,6 @@ public class BasePacket { this.shouldBuildHeader = buildHeader; } - public int getOpcode() { - return opcode; - } - public void setOpcode(int opcode) { this.opcode = opcode; } @@ -45,10 +46,6 @@ public class BasePacket { this.useDispatchKey = useDispatchKey; } - public byte[] getHeader() { - return header; - } - public void setHeader(byte[] header) { this.header = header; } @@ -57,10 +54,6 @@ public class BasePacket { return shouldBuildHeader; } - public byte[] getData() { - return data; - } - public void setData(byte[] data) { this.data = data; } diff --git a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java index 67bc2f023..852a28246 100644 --- a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java +++ b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java @@ -7,11 +7,20 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.http.*; import emu.grasscutter.server.scheduler.ServerTaskScheduler; +import lombok.Getter; + import java.util.*; import java.util.stream.Stream; /** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */ public final class ServerHelper { + /** + * -- GETTER -- + * Gets the server hook instance. + * + * @return A {@link ServerHelper} singleton. + */ + @Getter private static ServerHelper instance; private final GameServer gameServer; private final HttpServer httpServer; @@ -29,15 +38,6 @@ public final class ServerHelper { instance = this; } - /** - * Gets the server hook instance. - * - * @return A {@link ServerHelper} singleton. - */ - public static ServerHelper getInstance() { - return instance; - } - /** * @return The server's current run mode. */ diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index f37f57ebe..30bb4fe3e 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -30,11 +30,13 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import javax.annotation.*; import kotlin.Pair; +import lombok.Getter; import lombok.val; import org.luaj.vm2.*; import org.luaj.vm2.lib.jse.CoerceJavaToLua; public class SceneScriptManager { + @Getter private final Scene scene; private final Map variables; private SceneMeta meta; @@ -54,9 +56,12 @@ public class SceneScriptManager { private final Map sceneGroups; private final Map sceneGroupsInstances; private final Map cachedSceneGroupsInstances; + @Getter private ScriptMonsterTideService scriptMonsterTideService; + @Getter private final ScriptMonsterSpawnService scriptMonsterSpawnService; /** blockid - loaded groupSet */ + @Getter private final Map> loadedGroupSetPerBlock; private static final Int2ObjectMap> groupGridsCache = new Int2ObjectOpenHashMap<>(); @@ -100,10 +105,6 @@ public class SceneScriptManager { new Thread(this::init).start(); } - public Scene getScene() { - return scene; - } - public SceneConfig getConfig() { for (int i = 0; i < 10; ++i) { if (this.isInit) { @@ -385,10 +386,6 @@ public class SceneScriptManager { .ifPresent(entityRegion -> this.regions.remove(entityRegion.getId())); } - public Map> getLoadedGroupSetPerBlock() { - return loadedGroupSetPerBlock; - } - // TODO optimize public SceneGroup getGroupById(int groupId) { for (var block : getBlocks().values()) { @@ -1009,14 +1006,6 @@ public class SceneScriptManager { } } - public ScriptMonsterTideService getScriptMonsterTideService() { - return scriptMonsterTideService; - } - - public ScriptMonsterSpawnService getScriptMonsterSpawnService() { - return scriptMonsterSpawnService; - } - public EntityGadget createGadget(int groupId, int blockId, SceneGadget g) { return createGadget(groupId, blockId, g, g.state); } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index 16bc5ac14..58138fa27 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -22,12 +22,9 @@ public class SceneBlock { public Map groups; public RTree sceneGroupIndex; + @Getter private transient boolean loaded; // Not an actual variable in the scripts either - public boolean isLoaded() { - return this.loaded; - } - public void setLoaded(boolean loaded) { this.loaded = loaded; } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index de1a0ef8c..9728ca900 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -37,8 +37,11 @@ public final class SceneGroup { public SceneReplaceable is_replaceable; /* These are not script variables. */ + @Getter private transient boolean loaded; + @Getter private transient CompiledScript script; + @Getter private transient Bindings bindings; public String overrideScriptPath; @@ -48,10 +51,6 @@ public final class SceneGroup { return group; } - public boolean isLoaded() { - return this.loaded; - } - public void setLoaded(boolean loaded) { this.loaded = loaded; } @@ -64,10 +63,6 @@ public final class SceneGroup { return this.garbages == null ? null : this.garbages.gadgets; } - public CompiledScript getScript() { - return this.script; - } - public SceneSuite getSuiteByIndex(int index) { if (index < 1 || index > suites.size()) { return null; @@ -75,10 +70,6 @@ public final class SceneGroup { return this.suites.get(index - 1); } - public Bindings getBindings() { - return this.bindings; - } - public synchronized SceneGroup load(int sceneId) { if (this.loaded) { return this; diff --git a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java index 9e607861c..883c66e0b 100644 --- a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java +++ b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java @@ -1,11 +1,15 @@ package emu.grasscutter.scripts.data; +import lombok.Getter; import lombok.ToString; @ToString public class ScriptArgs { + @Getter public int param1; + @Getter public int param2; + @Getter public int param3; public int source_eid; // Source entity public int target_eid; @@ -28,28 +32,16 @@ public class ScriptArgs { this.param2 = param2; } - public int getParam1() { - return param1; - } - public ScriptArgs setParam1(int param1) { this.param1 = param1; return this; } - public int getParam2() { - return param2; - } - public ScriptArgs setParam2(int param2) { this.param2 = param2; return this; } - public int getParam3() { - return param3; - } - public ScriptArgs setParam3(int param3) { this.param3 = param3; return this; diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchClient.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchClient.java index 80d943ee8..e663d2892 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchClient.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchClient.java @@ -21,11 +21,12 @@ import org.java_websocket.client.WebSocketClient; import org.java_websocket.handshake.ServerHandshake; import org.slf4j.Logger; +@Getter public final class DispatchClient extends WebSocketClient implements IDispatcher { - @Getter private final Logger logger = Grasscutter.getLogger(); - @Getter private final Map> handlers = new HashMap<>(); + private final Logger logger = Grasscutter.getLogger(); + private final Map> handlers = new HashMap<>(); - @Getter private final Map>> callbacks = new HashMap<>(); + private final Map>> callbacks = new HashMap<>(); public DispatchClient(URI serverUri) { super(serverUri); diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 0427ede80..e58309a1d 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -19,11 +19,12 @@ import org.java_websocket.server.WebSocketServer; import org.slf4j.Logger; /* Internal communications server. */ +@Getter public final class DispatchServer extends WebSocketServer implements IDispatcher { - @Getter private final Logger logger = Grasscutter.getLogger(); - @Getter private final Map> handlers = new HashMap<>(); + private final Logger logger = Grasscutter.getLogger(); + private final Map> handlers = new HashMap<>(); - @Getter private final Map>> callbacks = new HashMap<>(); + private final Map>> callbacks = new HashMap<>(); /** * Constructs a new {@code DispatchServer} instance. diff --git a/src/main/java/emu/grasscutter/server/event/EventHandler.java b/src/main/java/emu/grasscutter/server/event/EventHandler.java index c43cfc1a3..d9b0450b3 100644 --- a/src/main/java/emu/grasscutter/server/event/EventHandler.java +++ b/src/main/java/emu/grasscutter/server/event/EventHandler.java @@ -3,6 +3,7 @@ package emu.grasscutter.server.event; import emu.grasscutter.Grasscutter; import emu.grasscutter.plugin.Plugin; import emu.grasscutter.utils.objects.EventConsumer; +import lombok.Getter; public final class EventHandler { /** @@ -57,6 +58,13 @@ public final class EventHandler { private final Class eventClass; private EventConsumer listener; + /** + * -- GETTER -- + * Returns the handler's priority. + * + * @return The priority of the handler. + */ + @Getter private HandlerPriority priority; private boolean handleCanceled; private Plugin plugin; @@ -83,15 +91,6 @@ public final class EventHandler { return this.listener; } - /** - * Returns the handler's priority. - * - * @return The priority of the handler. - */ - public HandlerPriority getPriority() { - return this.priority; - } - /** * Returns if the handler will ignore cancelled events. * diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java index 937f9f8f7..e2f4c3439 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java @@ -1,7 +1,9 @@ package emu.grasscutter.server.event.dispatch; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; +@Getter public final class QueryAllRegionsEvent extends ServerEvent { private String regionList; @@ -11,10 +13,6 @@ public final class QueryAllRegionsEvent extends ServerEvent { this.regionList = regionList; } - public String getRegionList() { - return this.regionList; - } - public void setRegionList(String regionList) { this.regionList = regionList; } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java index 6ae59362d..c0a8e4743 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java @@ -1,7 +1,9 @@ package emu.grasscutter.server.event.dispatch; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; +@Getter public final class QueryCurrentRegionEvent extends ServerEvent { private String regionInfo; @@ -11,10 +13,6 @@ public final class QueryCurrentRegionEvent extends ServerEvent { this.regionInfo = regionInfo; } - public String getRegionInfo() { - return this.regionInfo; - } - public void setRegionInfo(String regionInfo) { this.regionInfo = regionInfo; } diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java index c59408fdd..e6dc26fe9 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java @@ -6,6 +6,7 @@ import javax.annotation.Nullable; import lombok.*; /** Invoked when an entity is created. */ +@Getter @AllArgsConstructor public final class EntityCreationEvent extends Event { /** @@ -21,9 +22,9 @@ public final class EntityCreationEvent extends Event { return type.cast(event.getEntity()); } - @Getter @Setter private Class entityType; - @Getter @Setter private Class[] constructorArgTypes; - @Getter @Setter private Object[] constructorArgs; + @Setter private Class entityType; + @Setter private Class[] constructorArgTypes; + @Setter private Object[] constructorArgs; /** * Creates a new entity. Returns null if the entity could not be created. diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityDamageEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityDamageEvent.java index 34527941a..8995fe15e 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityDamageEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityDamageEvent.java @@ -7,10 +7,11 @@ import emu.grasscutter.server.event.types.EntityEvent; import javax.annotation.Nullable; import lombok.*; +@Getter public final class EntityDamageEvent extends EntityEvent implements Cancellable { - @Getter @Setter private float damage; - @Getter @Setter private ElementType attackElementType; - @Getter @Nullable private final GameEntity damager; + @Setter private float damage; + @Setter private ElementType attackElementType; + @Nullable private final GameEntity damager; public EntityDamageEvent( GameEntity entity, diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityDeathEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityDeathEvent.java index 2f6c3c1df..4a8d40215 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityDeathEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityDeathEvent.java @@ -6,9 +6,10 @@ import emu.grasscutter.server.event.types.EntityEvent; import javax.annotation.Nullable; import lombok.Getter; +@Getter public final class EntityDeathEvent extends EntityEvent { - @Getter private final Location deathLocation; - @Getter @Nullable private final GameEntity killer; + private final Location deathLocation; + @Nullable private final GameEntity killer; public EntityDeathEvent(GameEntity entity, int killerId) { super(entity); diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java index 7c0bcc54f..410458818 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java @@ -4,7 +4,9 @@ import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.world.Position; import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState; import emu.grasscutter.server.event.types.EntityEvent; +import lombok.Getter; +@Getter public final class EntityMoveEvent extends EntityEvent { private final Position position, rotation; private final MotionState motionState; @@ -18,15 +20,4 @@ public final class EntityMoveEvent extends EntityEvent { this.motionState = motionState; } - public Position getPosition() { - return this.position; - } - - public Position getRotation() { - return this.rotation; - } - - public MotionState getMotionState() { - return this.motionState; - } } diff --git a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java index 24cf09235..b234c8e1c 100644 --- a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java @@ -3,7 +3,9 @@ package emu.grasscutter.server.event.game; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.GameEvent; import emu.grasscutter.server.game.GameSession; +import lombok.Getter; +@Getter public final class PlayerCreationEvent extends GameEvent { private final GameSession session; private Class playerClass; @@ -13,14 +15,6 @@ public final class PlayerCreationEvent extends GameEvent { this.playerClass = playerClass; } - public GameSession getSession() { - return this.session; - } - - public Class getPlayerClass() { - return this.playerClass; - } - public void setPlayerClass(Class playerClass) { this.playerClass = playerClass; } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java index b0c14e2f0..5709deb30 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java @@ -3,10 +3,13 @@ package emu.grasscutter.server.event.game; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; + import javax.annotation.Nullable; public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Cancellable { @Nullable private final Player player; + @Getter private String message; public ReceiveCommandFeedbackEvent(@Nullable Player player, String message) { @@ -16,10 +19,6 @@ public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Ca this.message = message; } - public String getMessage() { - return this.message; - } - public void setMessage(String message) { this.message = message; } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java index 4f21297cf..8eab8e2c9 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java @@ -3,7 +3,9 @@ package emu.grasscutter.server.event.game; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.game.GameSession; +import lombok.Getter; +@Getter public final class ReceivePacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; private final int packetId; @@ -17,18 +19,6 @@ public final class ReceivePacketEvent extends ServerEvent implements Cancellable this.packetData = packetData; } - public GameSession getGameSession() { - return this.gameSession; - } - - public int getPacketId() { - return this.packetId; - } - - public byte[] getPacketData() { - return this.packetData; - } - public void setPacketData(byte[] packetData) { this.packetData = packetData; } diff --git a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java index 7a6125ba7..b37722bd4 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java @@ -4,7 +4,9 @@ import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.game.GameSession; +import lombok.Getter; +@Getter public final class SendPacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; private BasePacket packet; @@ -16,14 +18,6 @@ public final class SendPacketEvent extends ServerEvent implements Cancellable { this.packet = packet; } - public GameSession getGameSession() { - return this.gameSession; - } - - public BasePacket getPacket() { - return this.packet; - } - public void setPacket(BasePacket packet) { this.packet = packet; } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java index 911e6d0fc..121271b9f 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java @@ -2,7 +2,9 @@ package emu.grasscutter.server.event.internal; import ch.qos.logback.classic.spi.ILoggingEvent; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; +@Getter public final class ServerLogEvent extends ServerEvent { private final ILoggingEvent loggingEvent; private final String consoleMessage; @@ -14,11 +16,4 @@ public final class ServerLogEvent extends ServerEvent { this.consoleMessage = consoleMessage; } - public ILoggingEvent getLoggingEvent() { - return this.loggingEvent; - } - - public String getConsoleMessage() { - return this.consoleMessage; - } } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java index a5e60d7e4..e9951098b 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java @@ -1,8 +1,11 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; + import java.time.OffsetDateTime; +@Getter public final class ServerStartEvent extends ServerEvent { private final OffsetDateTime startTime; @@ -12,7 +15,4 @@ public final class ServerStartEvent extends ServerEvent { this.startTime = startTime; } - public OffsetDateTime getStartTime() { - return this.startTime; - } } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java index 2fc6bc6a4..eff1b97c7 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java @@ -1,8 +1,11 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; +import lombok.Getter; + import java.time.OffsetDateTime; +@Getter public final class ServerStopEvent extends ServerEvent { private final OffsetDateTime stopTime; @@ -12,7 +15,4 @@ public final class ServerStopEvent extends ServerEvent { this.stopTime = stopTime; } - public OffsetDateTime getStopTime() { - return this.stopTime; - } } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerCompleteQuestEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerCompleteQuestEvent.java index 255d1b281..54beed142 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerCompleteQuestEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerCompleteQuestEvent.java @@ -6,8 +6,9 @@ import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.Getter; +@Getter public final class PlayerCompleteQuestEvent extends PlayerEvent implements Cancellable { - @Getter private final GameQuest quest; + private final GameQuest quest; public PlayerCompleteQuestEvent(Player player, GameQuest quest) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerEnterAreaEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerEnterAreaEvent.java index 88c48c25e..ef040cdaf 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerEnterAreaEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerEnterAreaEvent.java @@ -4,8 +4,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.Getter; +@Getter public final class PlayerEnterAreaEvent extends PlayerEvent { - @Getter private final int areaId, areaType; + private final int areaId, areaType; public PlayerEnterAreaEvent(Player player) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerEnterDungeonEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerEnterDungeonEvent.java index b976e99b1..4e49272d7 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerEnterDungeonEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerEnterDungeonEvent.java @@ -5,8 +5,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.Getter; +@Getter public final class PlayerEnterDungeonEvent extends PlayerEvent { - @Getter private final DungeonData dungeon; + private final DungeonData dungeon; public PlayerEnterDungeonEvent(Player player, DungeonData dungeon) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java index d669762a4..42681438f 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java @@ -5,8 +5,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.*; +@Getter public final class PlayerForgeItemEvent extends PlayerEvent { - @Getter @Setter private GameItem itemForged; + @Setter private GameItem itemForged; public PlayerForgeItemEvent(Player player, GameItem itemForged) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java index e397ff33b..9d6059226 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java @@ -5,7 +5,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.game.world.ChestReward; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.PlayerEvent; +import lombok.Getter; +@Getter public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellable { private final GadgetChest chest; private ChestReward reward; @@ -17,15 +19,8 @@ public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellab this.reward = reward; } - public GadgetChest getChest() { - return this.chest; - } - public void setReward(ChestReward reward) { this.reward = reward; } - public ChestReward getReward() { - return this.reward; - } } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java index c008a9783..c71ef50f8 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java @@ -4,7 +4,9 @@ import emu.grasscutter.game.mail.Mail; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.PlayerEvent; +import lombok.Getter; +@Getter public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancellable { private Mail message; @@ -14,10 +16,6 @@ public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancell this.message = message; } - public Mail getMessage() { - return this.message; - } - public void setMessage(Mail message) { this.message = message; } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerTeamDeathEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerTeamDeathEvent.java index 524d27078..84f7771d2 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerTeamDeathEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerTeamDeathEvent.java @@ -9,8 +9,9 @@ import lombok.Getter; * This event is invoked when the ENTIRE TEAM dies. To listen for one player death, use {@link * emu.grasscutter.server.event.entity.EntityDeathEvent}. */ +@Getter public final class PlayerTeamDeathEvent extends PlayerEvent { - @Getter private final EntityAvatar selectedAvatar; + private final EntityAvatar selectedAvatar; public PlayerTeamDeathEvent(Player player, EntityAvatar selectedAvatar) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerUseFoodEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerUseFoodEvent.java index d5482e93f..e04a14766 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerUseFoodEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerUseFoodEvent.java @@ -8,9 +8,10 @@ import emu.grasscutter.server.event.types.PlayerEvent; import lombok.*; /** This event is invoked when the player uses food on an avatar. */ +@Getter public final class PlayerUseFoodEvent extends PlayerEvent implements Cancellable { - @Getter private final EntityAvatar selectedAvatar; - @Getter @Setter private ItemData foodUsed; + private final EntityAvatar selectedAvatar; + @Setter private ItemData foodUsed; public PlayerUseFoodEvent(Player player, ItemData foodUsed, EntityAvatar selectedAvatar) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java index e009612ad..12948bdbf 100644 --- a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java @@ -2,8 +2,10 @@ package emu.grasscutter.server.event.types; import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.server.event.Event; +import lombok.Getter; /** An event that is related to entity interactions. */ +@Getter public abstract class EntityEvent extends Event { protected final GameEntity entity; @@ -11,7 +13,4 @@ public abstract class EntityEvent extends Event { this.entity = entity; } - public GameEntity getEntity() { - return this.entity; - } } diff --git a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java index 2d1a77492..b506f95e5 100644 --- a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java @@ -2,8 +2,10 @@ package emu.grasscutter.server.event.types; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Event; +import lombok.Getter; /** An event that is related to player interactions. */ +@Getter public abstract class PlayerEvent extends Event { protected final Player player; @@ -11,7 +13,4 @@ public abstract class PlayerEvent extends Event { this.player = player; } - public Player getPlayer() { - return this.player; - } } diff --git a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java index 3fd3db05c..883cd2b7f 100644 --- a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java +++ b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java @@ -1,5 +1,8 @@ package emu.grasscutter.server.game; +import lombok.Getter; + +@Getter public abstract class BaseGameSystem { protected final GameServer server; @@ -7,7 +10,4 @@ public abstract class BaseGameSystem { this.server = server; } - public GameServer getServer() { - return this.server; - } } diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 160644407..092bf72d3 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -17,6 +17,7 @@ import java.nio.file.Path; import lombok.*; public class GameSession implements GameSessionManager.KcpChannel { + @Getter private final GameServer server; private GameSessionManager.KcpTunnel tunnel; @@ -44,10 +45,6 @@ public class GameSession implements GameSessionManager.KcpChannel { } } - public GameServer getServer() { - return server; - } - public InetSocketAddress getAddress() { try { return tunnel.getAddress(); diff --git a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java index 5c6ef7770..ed1b292ff 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java +++ b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java @@ -12,6 +12,7 @@ import lombok.Getter; public class GameSessionManager { @Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop(); private static final ConcurrentHashMap sessions = new ConcurrentHashMap<>(); + @Getter private static final KcpListener listener = new KcpListener() { @Override @@ -90,10 +91,6 @@ public class GameSessionManager { } }; - public static KcpListener getListener() { - return listener; - } - public interface KcpTunnel { InetSocketAddress getAddress(); diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index 94d1ba60e..cc29fbe28 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -22,6 +22,8 @@ import java.time.Instant; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; + +import lombok.Getter; import org.slf4j.Logger; /** Handles requests related to region queries. */ @@ -321,6 +323,7 @@ public final class RegionHandler implements Router { } /** Region data container. */ + @Getter public static class RegionData { private final QueryCurrRegionHttpRsp regionQuery; private final String base64; @@ -330,13 +333,6 @@ public final class RegionHandler implements Router { this.base64 = b64; } - public QueryCurrRegionHttpRsp getRegionQuery() { - return this.regionQuery; - } - - public String getBase64() { - return this.base64; - } } /** diff --git a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java index 38e4c2a02..b152bdeb6 100644 --- a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java +++ b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java @@ -14,7 +14,14 @@ public final class AsyncServerTask implements Runnable { /* Has the task already been started? */ private boolean started = false; + /** + * -- GETTER -- + * Returns the state of the task. + * + * @return True if the task has finished execution, false otherwise. + */ /* Has the task finished execution? */ + @Getter private boolean finished = false; /* The result produced in the async task. */ @Nullable private Object result = null; @@ -49,15 +56,6 @@ public final class AsyncServerTask implements Runnable { return this.started; } - /** - * Returns the state of the task. - * - * @return True if the task has finished execution, false otherwise. - */ - public boolean isFinished() { - return this.finished; - } - /** Runs the task. */ @Override public void run() { diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index e079dfa60..fe172270e 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.regex.*; import java.util.stream.*; import lombok.EqualsAndHashCode; +import lombok.Getter; public final class Language { private static final Map cachedLanguages = new ConcurrentHashMap<>(); @@ -28,6 +29,11 @@ public final class Language { private static boolean scannedTextmaps = false; // Ensure that we don't infinitely rescan on cache misses that don't exist private static Int2ObjectMap textMapStrings; + /** + * -- GETTER -- + * get language code + */ + @Getter private final String languageCode; private final Map translations = new ConcurrentHashMap<>(); @@ -406,11 +412,6 @@ public final class Language { } } - /** get language code */ - public String getLanguageCode() { - return languageCode; - } - /** * Returns the value (as a string) from a nested key. * diff --git a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java index efb5775e7..5bcfbda13 100644 --- a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java +++ b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java @@ -4,8 +4,11 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.encoder.Encoder; import emu.grasscutter.server.event.internal.ServerLogEvent; +import lombok.Getter; + import java.nio.charset.StandardCharsets; +@Getter public final class ServerLogEventAppender extends AppenderBase { private Encoder encoder; @@ -17,10 +20,6 @@ public final class ServerLogEventAppender extends AppenderBase { sle.call(); } - public Encoder getEncoder() { - return this.encoder; - } - public void setEncoder(Encoder encoder) { this.encoder = encoder; } From dd9f59fbfc40c46d201741a8f7d4022ead134106 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:55:51 -0300 Subject: [PATCH 35/59] refactor(lombok): add Setter where possible --- .../command/commands/ClearCommand.java | 7 +-- .../data/excels/StatuePromoteData.java | 11 +++-- .../java/emu/grasscutter/game/Account.java | 46 ++++--------------- .../TrialAvatarActivityHandler.java | 3 +- .../game/battlepass/BattlePassMission.java | 11 ++--- .../grasscutter/game/city/CityInfoData.java | 6 +-- .../game/combine/CombineResult.java | 17 +------ .../game/combine/ReliquaryDecomposeEntry.java | 9 +--- .../emu/grasscutter/game/drop/DropData.java | 11 ++--- .../game/dungeons/DungeonDrop.java | 9 +--- .../game/dungeons/DungeonDropEntry.java | 21 +-------- .../dungeons/challenge/DungeonChallenge.java | 6 +-- .../entity/gadget/platform/BaseRoute.java | 11 +++-- .../entity/gadget/platform/ConfigRoute.java | 7 +-- .../gadget/platform/PointArrayRoute.java | 5 +- .../grasscutter/game/friends/Friendship.java | 16 ++----- .../grasscutter/game/gacha/GachaRecord.java | 22 +-------- .../grasscutter/game/inventory/ItemDef.java | 9 +--- .../java/emu/grasscutter/game/mail/Mail.java | 6 +-- .../managers/forging/ActiveForgeData.java | 31 +++---------- .../emu/grasscutter/game/player/TeamInfo.java | 6 +-- .../emu/grasscutter/game/shop/ShopLimit.java | 17 +------ .../emu/grasscutter/game/shop/ShopTable.java | 9 +--- .../game/tower/TowerLevelRecord.java | 13 +----- .../game/tower/TowerScheduleConfig.java | 13 +----- .../grasscutter/game/world/GridPosition.java | 7 +-- .../emu/grasscutter/game/world/Location.java | 3 +- .../emu/grasscutter/game/world/Position.java | 4 +- .../emu/grasscutter/game/world/World.java | 6 +-- .../grasscutter/net/packet/BasePacket.java | 21 ++------- .../grasscutter/scripts/data/SceneBlock.java | 5 +- .../grasscutter/scripts/data/SceneGadget.java | 4 +- .../grasscutter/scripts/data/SceneGroup.java | 5 +- .../event/dispatch/QueryAllRegionsEvent.java | 5 +- .../dispatch/QueryCurrentRegionEvent.java | 5 +- .../event/entity/EntityCreationEvent.java | 7 +-- .../event/game/PlayerCreationEvent.java | 5 +- .../game/ReceiveCommandFeedbackEvent.java | 6 +-- .../server/event/game/ReceivePacketEvent.java | 5 +- .../server/event/game/SendPacketEvent.java | 5 +- .../event/player/PlayerForgeItemEvent.java | 3 +- .../event/player/PlayerOpenChestEvent.java | 6 +-- .../event/player/PlayerReceiveMailEvent.java | 5 +- .../utils/objects/ServerLogEventAppender.java | 5 +- 44 files changed, 122 insertions(+), 312 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java index bbfb47078..ff2cf4c2c 100644 --- a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java @@ -93,9 +93,10 @@ public final class ClearCommand implements CommandHandler { } } + @Setter private static class ClearItemParameters { - @Setter public int lvl = 1; - @Setter public int refinement = 1; - @Setter public int rank = 4; + public int lvl = 1; + public int refinement = 1; + public int rank = 4; } } diff --git a/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java b/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java index 32d3f205d..0ddb6c439 100644 --- a/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/StatuePromoteData.java @@ -4,14 +4,15 @@ import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; import lombok.*; +@Setter @Getter @ResourceType(name = "StatuePromoteExcelConfigData.json") public class StatuePromoteData extends GameResource { - @Setter private int level; - @Setter private int cityId; - @Setter private ItemParamData[] costItems; - @Setter private int[] rewardIdList; - @Setter private int stamina; + private int level; + private int cityId; + private ItemParamData[] costItems; + private int[] rewardIdList; + private int stamina; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index bbdab85c4..35f54dafd 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -9,24 +9,30 @@ import java.util.*; import java.util.stream.Stream; import lombok.Getter; +import lombok.Setter; import org.bson.Document; @Entity(value = "accounts", useDiscriminator = false) public class Account { + @Setter @Getter @Id private String id; + @Setter @Getter @Indexed(options = @IndexOptions(unique = true)) @Collation(locale = "simple", caseLevel = true) private String username; + @Setter @Getter private String password; // Unused for now private int reservedPlayerId; + @Setter private String email; + @Setter @Getter private String token; @Getter @@ -37,13 +43,17 @@ public class Account { */ @Getter private final List permissions; + @Setter @Getter private Locale locale; + @Setter @Getter private String banReason; + @Setter @Getter private int banEndTime; + @Setter @Getter private int banStartTime; private boolean isBanned; @@ -80,22 +90,6 @@ public class Account { return (wildcardParts.length == permissionParts.length); } - public void setId(String id) { - this.id = id; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setToken(String token) { - this.token = token; - } - public int getReservedPlayerUid() { return this.reservedPlayerId; } @@ -113,32 +107,12 @@ public class Account { } } - public void setEmail(String email) { - this.email = email; - } - public String generateSessionKey() { this.sessionKey = Utils.bytesToHex(Crypto.createSessionKey(32)); this.save(); return this.sessionKey; } - public void setLocale(Locale locale) { - this.locale = locale; - } - - public void setBanReason(String banReason) { - this.banReason = banReason; - } - - public void setBanEndTime(int banEndTime) { - this.banEndTime = banEndTime; - } - - public void setBanStartTime(int banStartTime) { - this.banStartTime = banStartTime; - } - public boolean isBanned() { if (banEndTime > 0 && banEndTime < System.currentTimeMillis() / 1000) { this.isBanned = false; diff --git a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java index 20835fe81..76f358a05 100644 --- a/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java +++ b/src/main/java/emu/grasscutter/game/activity/trialavatar/TrialAvatarActivityHandler.java @@ -16,10 +16,11 @@ import java.util.*; import java.util.stream.Stream; import lombok.*; +@Setter @Getter @GameActivity(ActivityType.NEW_ACTIVITY_TRIAL_AVATAR) public class TrialAvatarActivityHandler extends ActivityHandler { - @Setter private int selectedTrialAvatarIndex; + private int selectedTrialAvatarIndex; @Override public void onInitPlayerActivityData(PlayerActivityData playerActivityData) { diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java index 27286ad00..b22bc7de0 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java @@ -5,13 +5,16 @@ import emu.grasscutter.data.GameData; import emu.grasscutter.data.excels.BattlePassMissionData; import emu.grasscutter.game.props.BattlePassMissionStatus; import lombok.Getter; +import lombok.Setter; @Entity public class BattlePassMission { @Getter private int id; + @Setter @Getter private int progress; + @Setter private BattlePassMissionStatus status; @Transient private BattlePassMissionData data; @@ -30,10 +33,6 @@ public class BattlePassMission { return this.data; } - public void setProgress(int value) { - this.progress = value; - } - public void addProgress(int addProgress, int maxProgress) { this.progress = Math.min(addProgress + this.progress, maxProgress); } @@ -43,10 +42,6 @@ public class BattlePassMission { return status; } - public void setStatus(BattlePassMissionStatus status) { - this.status = status; - } - public boolean isFinshed() { return getStatus().getValue() >= 2; } diff --git a/src/main/java/emu/grasscutter/game/city/CityInfoData.java b/src/main/java/emu/grasscutter/game/city/CityInfoData.java index 6cff23158..e9fa10657 100644 --- a/src/main/java/emu/grasscutter/game/city/CityInfoData.java +++ b/src/main/java/emu/grasscutter/game/city/CityInfoData.java @@ -4,15 +4,15 @@ import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.CityInfoOuterClass.CityInfo; import lombok.*; +@Setter @Getter @Entity public class CityInfoData { - @Setter private int cityId; + private int cityId; - @Setter private int level = 1; // level of the city (include level SotS, level Frostbearing Trees, etc.) - @Setter private int numCrystal = 0; // number of crystals in the city + private int numCrystal = 0; // number of crystals in the city public CityInfoData(int cityId) { this.cityId = cityId; diff --git a/src/main/java/emu/grasscutter/game/combine/CombineResult.java b/src/main/java/emu/grasscutter/game/combine/CombineResult.java index e5099e755..4f372cc25 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineResult.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineResult.java @@ -2,9 +2,11 @@ package emu.grasscutter.game.combine; import emu.grasscutter.data.common.ItemParamData; import lombok.Getter; +import lombok.Setter; import java.util.List; +@Setter @Getter public class CombineResult { private List material; @@ -12,19 +14,4 @@ public class CombineResult { private List extra; private List back; - public void setMaterial(List material) { - this.material = material; - } - - public void setResult(List result) { - this.result = result; - } - - public void setExtra(List extra) { - this.extra = extra; - } - - public void setBack(List back) { - this.back = back; - } } diff --git a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java index ae2697af5..cf6427752 100644 --- a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java +++ b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java @@ -1,19 +1,14 @@ package emu.grasscutter.game.combine; import lombok.Getter; +import lombok.Setter; import java.util.List; +@Setter @Getter public class ReliquaryDecomposeEntry { private int configId; private List items; - public void setConfigId(int configId) { - this.configId = configId; - } - - public void setItems(List items) { - this.items = items; - } } diff --git a/src/main/java/emu/grasscutter/game/drop/DropData.java b/src/main/java/emu/grasscutter/game/drop/DropData.java index 9cc033b02..5d2cbbef0 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropData.java +++ b/src/main/java/emu/grasscutter/game/drop/DropData.java @@ -1,26 +1,21 @@ package emu.grasscutter.game.drop; import lombok.Getter; +import lombok.Setter; @Getter @Deprecated public class DropData { private int minWeight; private int maxWeight; + @Setter private int itemId; private int minCount; private int maxCount; private boolean share = false; + @Setter private boolean give = false; - public void setGive(boolean give) { - this.give = give; - } - - public void setItemId(int itemId) { - this.itemId = itemId; - } - public void setIsShare(boolean share) { this.share = share; } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java index 23807a498..941b39405 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java @@ -1,19 +1,14 @@ package emu.grasscutter.game.dungeons; import lombok.Getter; +import lombok.Setter; import java.util.List; +@Setter @Getter public class DungeonDrop { private int dungeonId; private List drops; - public void setDungeonId(int dungeonId) { - this.dungeonId = dungeonId; - } - - public void setDrops(List drops) { - this.drops = drops; - } } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java index a44592b54..a509a1786 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java @@ -1,9 +1,11 @@ package emu.grasscutter.game.dungeons; import lombok.Getter; +import lombok.Setter; import java.util.List; +@Setter @Getter public class DungeonDropEntry { private List counts; @@ -12,23 +14,4 @@ public class DungeonDropEntry { private List itemProbabilities; private boolean mpDouble; - public void setCounts(List counts) { - this.counts = counts; - } - - public void setItems(List items) { - this.items = items; - } - - public void setProbabilities(List probabilities) { - this.probabilities = probabilities; - } - - public void setItemProbabilities(List itemProbabilities) { - this.itemProbabilities = itemProbabilities; - } - - public void setMpDouble(boolean mpDouble) { - this.mpDouble = mpDouble; - } } diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java index ab218b57f..adeef9d21 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/DungeonChallenge.java @@ -5,9 +5,11 @@ import emu.grasscutter.game.dungeons.enums.DungeonPassConditionType; import emu.grasscutter.game.world.Scene; import emu.grasscutter.scripts.data.SceneGroup; import lombok.Getter; +import lombok.Setter; import java.util.List; +@Setter @Getter public final class DungeonChallenge extends WorldChallenge { @@ -24,10 +26,6 @@ public final class DungeonChallenge extends WorldChallenge { super(scene, group, challengeId, challengeIndex, paramList, timeLimit, goal, challengeTriggers); } - public void setStage(boolean stage) { - this.stage = stage; - } - @Override public void done() { super.done(); 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 221cfbd90..5786cb384 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 @@ -6,13 +6,14 @@ import emu.grasscutter.net.proto.PlatformInfoOuterClass.PlatformInfo; import emu.grasscutter.scripts.data.SceneGadget; import lombok.*; +@Setter @Getter public abstract class BaseRoute { - @Setter private boolean isStarted; - @Setter private boolean isActive; - @Setter private Position startRot; - @Setter private int startSceneTime; - @Setter private int stopSceneTime; + private boolean isStarted; + private boolean isActive; + private Position startRot; + private int startSceneTime; + private int stopSceneTime; BaseRoute(Position startRot, boolean isStarted, boolean isActive) { this.startRot = startRot; diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java b/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java index 26ff78b29..b79f10ca4 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/platform/ConfigRoute.java @@ -6,12 +6,13 @@ import emu.grasscutter.scripts.data.SceneGadget; import java.util.*; import lombok.*; +@Setter @Getter public class ConfigRoute extends BaseRoute { - @Setter private int routeId; - @Setter private int startIndex; - @Setter private List scheduledIndexes; + private int routeId; + private int startIndex; + private List scheduledIndexes; public ConfigRoute(SceneGadget gadget) { super(gadget); diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java b/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java index 3174ba9e7..b3455e739 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/platform/PointArrayRoute.java @@ -6,11 +6,12 @@ import emu.grasscutter.scripts.data.SceneGadget; import lombok.*; /** TODO implement point array routes, read from missing resources */ +@Setter @Getter public class PointArrayRoute extends BaseRoute { - @Setter int currentPoint; - @Setter int pointArrayId; + int currentPoint; + int pointArrayId; public PointArrayRoute(SceneGadget gadget) { super(gadget); diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index 41d80133a..af17ea1ac 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -8,12 +8,14 @@ import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.PlatformTypeOuterClass; import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture; import lombok.Getter; +import lombok.Setter; import org.bson.types.ObjectId; @Entity(value = "friendships", useDiscriminator = false) public class Friendship { @Id private ObjectId id; + @Setter @Getter @Transient private Player owner; @@ -21,7 +23,9 @@ public class Friendship { @Indexed private int ownerId; @Getter @Indexed private int friendId; + @Setter private boolean isFriend; + @Setter @Getter private int askerId; @@ -38,22 +42,10 @@ public class Friendship { this.askerId = asker.getUid(); } - public void setOwner(Player owner) { - this.owner = owner; - } - public boolean isFriend() { return isFriend; } - public void setIsFriend(boolean b) { - this.isFriend = b; - } - - public void setAskerId(int askerId) { - this.askerId = askerId; - } - public PlayerProfile getFriendProfile() { return profile; } diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java index 3122e81b2..d66c12f3d 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java @@ -4,8 +4,10 @@ import dev.morphia.annotations.*; import java.util.Date; import lombok.Getter; +import lombok.Setter; import org.bson.types.ObjectId; +@Setter @Getter @Entity(value = "gachas", useDiscriminator = false) public class GachaRecord { @@ -26,26 +28,6 @@ public class GachaRecord { this.gachaType = gachaType; } - public void setOwnerId(int ownerId) { - this.ownerId = ownerId; - } - - public void setGachaType(int type) { - this.gachaType = type; - } - - public void setTransactionDate(Date transactionDate) { - this.transactionDate = transactionDate; - } - - public void setItemID(int itemID) { - this.itemID = itemID; - } - - public void setId(ObjectId id) { - this.id = id; - } - public String toString() { return toJsonString(); } diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java index c1dd29797..e09d40a97 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java @@ -1,7 +1,9 @@ package emu.grasscutter.game.inventory; import lombok.Getter; +import lombok.Setter; +@Setter @Getter public class ItemDef { private int itemId; @@ -12,11 +14,4 @@ public class ItemDef { this.count = count; } - public void setItemId(int itemId) { - this.itemId = itemId; - } - - public void setCount(int count) { - this.count = count; - } } diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index be585a000..8558e9de2 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -13,12 +13,14 @@ import java.time.Instant; import java.util.*; import lombok.Getter; +import lombok.Setter; import org.bson.types.ObjectId; @Entity(value = "mail", useDiscriminator = false) public final class Mail { @Getter @Id private ObjectId id; + @Setter @Getter @Indexed private int ownerUid; public final MailContent mailContent; @@ -63,10 +65,6 @@ public final class Mail { this.stateValue = state; // Different mailboxes, 1 = Default, 3 = Gift-box. } - public void setOwnerUid(int ownerUid) { - this.ownerUid = ownerUid; - } - public MailDataOuterClass.MailData toProto(Player player) { return MailDataOuterClass.MailData.newBuilder() .setMailId(player.getMailId(this)) diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java index f27d5cc9a..dedb26ac8 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java @@ -2,22 +2,29 @@ package emu.grasscutter.game.managers.forging; import dev.morphia.annotations.Entity; import lombok.Getter; +import lombok.Setter; @Entity public class ActiveForgeData { + @Setter @Getter private int forgeId; + @Setter @Getter private int avatarId; + @Setter @Getter private int count; + @Setter @Getter private int startTime; + @Setter @Getter private int forgeTime; private int lastUnfinishedCount; + @Setter @Getter private boolean changed; @@ -42,30 +49,6 @@ public class ActiveForgeData { return this.startTime + this.forgeTime * this.count; } - public void setForgeId(int value) { - this.forgeId = value; - } - - public void setAvatarId(int value) { - this.avatarId = value; - } - - public void setCount(int value) { - this.count = value; - } - - public void setStartTime(int value) { - this.startTime = value; - } - - public void setForgeTime(int value) { - this.forgeTime = value; - } - - public void setChanged(boolean value) { - this.changed = value; - } - public boolean updateChanged(int currentTime) { int currentUnfinished = this.getUnfinishedCount(currentTime); diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 86c76fef5..4fffba9a4 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -6,12 +6,14 @@ import dev.morphia.annotations.Entity; import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; import lombok.Getter; +import lombok.Setter; import java.util.*; @Getter @Entity public final class TeamInfo { + @Setter private String name; private final List avatars; @@ -25,10 +27,6 @@ public final class TeamInfo { this.avatars = avatars; } - public void setName(String name) { - this.name = name; - } - public int size() { return avatars.size(); } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java index e75e7ef24..376d46326 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java @@ -2,7 +2,9 @@ package emu.grasscutter.game.shop; import dev.morphia.annotations.Entity; import lombok.Getter; +import lombok.Setter; +@Setter @Getter @Entity public class ShopLimit { @@ -11,19 +13,4 @@ public class ShopLimit { private int hasBoughtInPeriod = 0; private int nextRefreshTime = 0; - public void setShopGoodId(int shopGoodId) { - this.shopGoodId = shopGoodId; - } - - public void setHasBought(int hasBought) { - this.hasBought = hasBought; - } - - public void setNextRefreshTime(int nextRefreshTime) { - this.nextRefreshTime = nextRefreshTime; - } - - public void setHasBoughtInPeriod(int hasBoughtInPeriod) { - this.hasBoughtInPeriod = hasBoughtInPeriod; - } } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopTable.java b/src/main/java/emu/grasscutter/game/shop/ShopTable.java index 78a8c201e..1cd9831a2 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopTable.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopTable.java @@ -1,19 +1,14 @@ package emu.grasscutter.game.shop; import lombok.Getter; +import lombok.Setter; import java.util.*; +@Setter @Getter public class ShopTable { private int shopId; private List items = new ArrayList<>(); - public void setShopId(int shopId) { - this.shopId = shopId; - } - - public void setItems(List items) { - this.items = items; - } } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java index 12afe9f58..a63cbf0f4 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java @@ -2,9 +2,11 @@ package emu.grasscutter.game.tower; import dev.morphia.annotations.Entity; import lombok.Getter; +import lombok.Setter; import java.util.*; +@Setter @Getter @Entity public class TowerLevelRecord { @@ -36,15 +38,4 @@ public class TowerLevelRecord { return passedLevelMap.values().stream().mapToInt(Integer::intValue).sum(); } - public void setFloorId(int floorId) { - this.floorId = floorId; - } - - public void setPassedLevelMap(Map passedLevelMap) { - this.passedLevelMap = passedLevelMap; - } - - public void setFloorStarRewardProgress(int floorStarRewardProgress) { - this.floorStarRewardProgress = floorStarRewardProgress; - } } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java index c82ca6e23..fa4e653c0 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java @@ -1,9 +1,11 @@ package emu.grasscutter.game.tower; import lombok.Getter; +import lombok.Setter; import java.util.Date; +@Setter @Getter public class TowerScheduleConfig { private int scheduleId; @@ -11,15 +13,4 @@ public class TowerScheduleConfig { private Date scheduleStartTime; private Date nextScheduleChangeTime; - public void setScheduleId(int scheduleId) { - this.scheduleId = scheduleId; - } - - public void setScheduleStartTime(Date scheduleStartTime) { - this.scheduleStartTime = scheduleStartTime; - } - - public void setNextScheduleChangeTime(Date nextScheduleChangeTime) { - this.nextScheduleChangeTime = nextScheduleChangeTime; - } } diff --git a/src/main/java/emu/grasscutter/game/world/GridPosition.java b/src/main/java/emu/grasscutter/game/world/GridPosition.java index e7e02d5ba..13caa8eaa 100644 --- a/src/main/java/emu/grasscutter/game/world/GridPosition.java +++ b/src/main/java/emu/grasscutter/game/world/GridPosition.java @@ -6,17 +6,18 @@ import java.io.*; import java.util.List; import lombok.*; +@Setter @Getter @Entity public final class GridPosition implements Serializable { @Serial private static final long serialVersionUID = -2001232300615923575L; - @Setter private int x; + private int x; - @Setter private int z; + private int z; - @Setter private int width; + private int width; public GridPosition() {} diff --git a/src/main/java/emu/grasscutter/game/world/Location.java b/src/main/java/emu/grasscutter/game/world/Location.java index a1c720ee5..16ed72ae4 100644 --- a/src/main/java/emu/grasscutter/game/world/Location.java +++ b/src/main/java/emu/grasscutter/game/world/Location.java @@ -3,11 +3,12 @@ package emu.grasscutter.game.world; import dev.morphia.annotations.*; import lombok.*; +@Setter @Getter @Entity public class Location extends Position { @Transient - @Setter private Scene scene; + private Scene scene; public Location(Scene scene, Position position) { this.set(position); diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 854c57aaa..6e3348e02 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -12,6 +12,7 @@ import java.util.List; import lombok.*; import lombok.experimental.Accessors; +@Setter @Getter @Entity @Accessors(chain = true) @@ -25,19 +26,16 @@ public class Position implements Serializable { @SerializedName( value = "x", alternate = {"_x", "X"}) - @Setter private float x; @SerializedName( value = "y", alternate = {"_y", "Y"}) - @Setter private float y; @SerializedName( value = "z", alternate = {"_z", "Z"}) - @Setter private float z; public Position() {} diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index bc7c6b8b7..ed32b1e1a 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -39,6 +39,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.annotation.Nullable; import lombok.Getter; +import lombok.Setter; import lombok.val; import org.jetbrains.annotations.NotNull; @@ -51,6 +52,7 @@ public class World implements Iterable { @Getter private final EntityWorld entity; private int nextEntityId = 0; private int nextPeerId = 0; + @Setter @Getter private int worldLevel; @@ -122,10 +124,6 @@ public class World implements Iterable { return ++this.nextPeerId; } - public void setWorldLevel(int worldLevel) { - this.worldLevel = worldLevel; - } - protected synchronized void setHost(Player host) { this.host = host; } diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index e6bf489f6..438b98f89 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -3,6 +3,7 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; import lombok.Getter; +import lombok.Setter; import java.io.*; @@ -10,14 +11,18 @@ public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; + @Setter @Getter private int opcode; private boolean shouldBuildHeader = false; + @Setter @Getter private byte[] header; + @Setter @Getter private byte[] data; // Encryption + @Setter private boolean useDispatchKey; public BasePacket(int opcode) { @@ -34,30 +39,14 @@ public class BasePacket { this.shouldBuildHeader = buildHeader; } - public void setOpcode(int opcode) { - this.opcode = opcode; - } - public boolean useDispatchKey() { return useDispatchKey; } - public void setUseDispatchKey(boolean useDispatchKey) { - this.useDispatchKey = useDispatchKey; - } - - public void setHeader(byte[] header) { - this.header = header; - } - public boolean shouldBuildHeader() { return shouldBuildHeader; } - public void setData(byte[] data) { - this.data = data; - } - public void setData(GeneratedMessageV3 proto) { this.data = proto.toByteArray(); } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index 58138fa27..782ef2a8c 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -22,13 +22,10 @@ public class SceneBlock { public Map groups; public RTree sceneGroupIndex; + @Setter @Getter private transient boolean loaded; // Not an actual variable in the scripts either - public void setLoaded(boolean loaded) { - this.loaded = loaded; - } - public boolean contains(Position pos) { int range = Grasscutter.getConfig().server.game.loadEntitiesForPlayerRange; return pos.getX() <= (this.max.getX() + range) diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java index 8c8821ca7..8cd7d6d9c 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java @@ -24,6 +24,7 @@ public class SceneGadget extends SceneObject { * isOneOff=false, like investigation points, it will disappear temporarily, and appear again in * next big world resource refresh routine. */ + @Setter public boolean isOneoff; public int draft_id; @@ -35,7 +36,4 @@ public class SceneGadget extends SceneObject { public Explore explore; public int trigger_count; - public void setIsOneoff(boolean isOneoff) { - this.isOneoff = isOneoff; - } } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index 9728ca900..ccfe70b82 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -37,6 +37,7 @@ public final class SceneGroup { public SceneReplaceable is_replaceable; /* These are not script variables. */ + @Setter @Getter private transient boolean loaded; @Getter @@ -51,10 +52,6 @@ public final class SceneGroup { return group; } - public void setLoaded(boolean loaded) { - this.loaded = loaded; - } - public int getBusinessType() { return this.business == null ? 0 : this.business.type; } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java index e2f4c3439..c54b4750c 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java @@ -2,7 +2,9 @@ package emu.grasscutter.server.event.dispatch; import emu.grasscutter.server.event.types.ServerEvent; import lombok.Getter; +import lombok.Setter; +@Setter @Getter public final class QueryAllRegionsEvent extends ServerEvent { private String regionList; @@ -13,7 +15,4 @@ public final class QueryAllRegionsEvent extends ServerEvent { this.regionList = regionList; } - public void setRegionList(String regionList) { - this.regionList = regionList; - } } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java index c0a8e4743..b6c0a0cff 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java @@ -2,7 +2,9 @@ package emu.grasscutter.server.event.dispatch; import emu.grasscutter.server.event.types.ServerEvent; import lombok.Getter; +import lombok.Setter; +@Setter @Getter public final class QueryCurrentRegionEvent extends ServerEvent { private String regionInfo; @@ -13,7 +15,4 @@ public final class QueryCurrentRegionEvent extends ServerEvent { this.regionInfo = regionInfo; } - public void setRegionInfo(String regionInfo) { - this.regionInfo = regionInfo; - } } diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java index e6dc26fe9..9019d1ca4 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityCreationEvent.java @@ -6,6 +6,7 @@ import javax.annotation.Nullable; import lombok.*; /** Invoked when an entity is created. */ +@Setter @Getter @AllArgsConstructor public final class EntityCreationEvent extends Event { @@ -22,9 +23,9 @@ public final class EntityCreationEvent extends Event { return type.cast(event.getEntity()); } - @Setter private Class entityType; - @Setter private Class[] constructorArgTypes; - @Setter private Object[] constructorArgs; + private Class entityType; + private Class[] constructorArgTypes; + private Object[] constructorArgs; /** * Creates a new entity. Returns null if the entity could not be created. diff --git a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java index b234c8e1c..699105d16 100644 --- a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java @@ -4,10 +4,12 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.GameEvent; import emu.grasscutter.server.game.GameSession; import lombok.Getter; +import lombok.Setter; @Getter public final class PlayerCreationEvent extends GameEvent { private final GameSession session; + @Setter private Class playerClass; public PlayerCreationEvent(GameSession session, Class playerClass) { @@ -15,7 +17,4 @@ public final class PlayerCreationEvent extends GameEvent { this.playerClass = playerClass; } - public void setPlayerClass(Class playerClass) { - this.playerClass = playerClass; - } } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java index 5709deb30..fc6f247cc 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java @@ -4,11 +4,13 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; import lombok.Getter; +import lombok.Setter; import javax.annotation.Nullable; public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Cancellable { @Nullable private final Player player; + @Setter @Getter private String message; @@ -19,10 +21,6 @@ public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Ca this.message = message; } - public void setMessage(String message) { - this.message = message; - } - @Nullable public Player getPlayer() { return this.player; } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java index 8eab8e2c9..9419aef77 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java @@ -4,11 +4,13 @@ import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.game.GameSession; import lombok.Getter; +import lombok.Setter; @Getter public final class ReceivePacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; private final int packetId; + @Setter private byte[] packetData; public ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetData) { @@ -19,7 +21,4 @@ public final class ReceivePacketEvent extends ServerEvent implements Cancellable this.packetData = packetData; } - public void setPacketData(byte[] packetData) { - this.packetData = packetData; - } } diff --git a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java index b37722bd4..9d6d724ca 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java @@ -5,10 +5,12 @@ import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.game.GameSession; import lombok.Getter; +import lombok.Setter; @Getter public final class SendPacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; + @Setter private BasePacket packet; public SendPacketEvent(GameSession gameSession, BasePacket packet) { @@ -18,7 +20,4 @@ public final class SendPacketEvent extends ServerEvent implements Cancellable { this.packet = packet; } - public void setPacket(BasePacket packet) { - this.packet = packet; - } } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java index 42681438f..b62394331 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerForgeItemEvent.java @@ -5,9 +5,10 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.*; +@Setter @Getter public final class PlayerForgeItemEvent extends PlayerEvent { - @Setter private GameItem itemForged; + private GameItem itemForged; public PlayerForgeItemEvent(Player player, GameItem itemForged) { super(player); diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java index 9d6059226..05f440733 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java @@ -6,10 +6,12 @@ import emu.grasscutter.game.world.ChestReward; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.Getter; +import lombok.Setter; @Getter public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellable { private final GadgetChest chest; + @Setter private ChestReward reward; public PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward) { @@ -19,8 +21,4 @@ public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellab this.reward = reward; } - public void setReward(ChestReward reward) { - this.reward = reward; - } - } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java index c71ef50f8..7cfe831aa 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java @@ -5,7 +5,9 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.PlayerEvent; import lombok.Getter; +import lombok.Setter; +@Setter @Getter public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancellable { private Mail message; @@ -16,7 +18,4 @@ public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancell this.message = message; } - public void setMessage(Mail message) { - this.message = message; - } } diff --git a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java index 5bcfbda13..5b6b8abc0 100644 --- a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java +++ b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java @@ -5,9 +5,11 @@ import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.encoder.Encoder; import emu.grasscutter.server.event.internal.ServerLogEvent; import lombok.Getter; +import lombok.Setter; import java.nio.charset.StandardCharsets; +@Setter @Getter public final class ServerLogEventAppender extends AppenderBase { private Encoder encoder; @@ -20,7 +22,4 @@ public final class ServerLogEventAppender extends AppenderBase { sle.call(); } - public void setEncoder(Encoder encoder) { - this.encoder = encoder; - } } From 4b03304cdc58f11bb1ad555719e8423dfcc71798 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:56:58 -0300 Subject: [PATCH 36/59] perf: this is just Math.min --- src/main/java/emu/grasscutter/game/gacha/GachaSystem.java | 2 +- .../emu/grasscutter/game/managers/blossom/BlossomManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java index 3ef45bd39..e119201eb 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java @@ -104,7 +104,7 @@ public class GachaSystem extends BaseGameSystem { } total += weight; } - int roll = ThreadLocalRandom.current().nextInt((total < cutoff) ? total : cutoff); + int roll = ThreadLocalRandom.current().nextInt(Math.min(total, cutoff)); int subTotal = 0; for (int i = 0; i < weights.length; i++) { subTotal += weights[i]; diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java index 8dfcaea69..d1f59bf99 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java @@ -118,7 +118,7 @@ public class BlossomManager { public void notifyIcon() { final int wl = getWorldLevel(); - final int worldLevel = (wl < 0) ? 0 : ((wl > 8) ? 8 : wl); + final int worldLevel = (wl < 0) ? 0 : (Math.min(wl, 8)); final var worldLevelData = GameData.getWorldLevelDataMap().get(worldLevel); final int monsterLevel = (worldLevelData != null) ? worldLevelData.getMonsterLevel() : 1; List blossoms = new ArrayList<>(); From f01da54eaa700ace6238cc292578dc87c7598746 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:57:41 -0300 Subject: [PATCH 37/59] perf: size cannot be negative --- .../emu/grasscutter/game/managers/forging/ForgingManager.java | 2 +- src/main/java/emu/grasscutter/game/player/TeamManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java b/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java index deca11dda..e8edc63b7 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java @@ -299,7 +299,7 @@ public final class ForgingManager extends BasePlayerManager { // Determine if sending an update is necessary. // We only send an update if there are forges in the forge queue // that have changed since the last notification. - if (this.player.getActiveForges().size() <= 0) { + if (this.player.getActiveForges().size() == 0) { return; } diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index f79cb422d..a29d4f082 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -363,7 +363,7 @@ public final class TeamManager extends BasePlayerDataManager { public void updateTeamEntities(BasePacket responsePacket) { // Sanity check - Should never happen - if (this.getCurrentTeamInfo().getAvatars().size() <= 0) { + if (this.getCurrentTeamInfo().getAvatars().size() == 0) { return; } From 8f8a6a7bfeb72d85d03c5a9f76c16b26e8818029 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:58:25 -0300 Subject: [PATCH 38/59] perf: simplify optional chain --- src/main/java/emu/grasscutter/scripts/ScriptLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLib.java b/src/main/java/emu/grasscutter/scripts/ScriptLib.java index 6eaac1849..2118ea861 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -1997,7 +1997,7 @@ public class ScriptLib { logger.debug("[LUA] Call DropSubfield with {}", printTable(table)); String subfield_name = table.get("subfield_name").toString(); var entity = getCurrentEntity(); - if (!entity.isPresent()) return -1; + if (entity.isEmpty()) return -1; entity.get().dropSubfield(subfield_name); From 85ca8777c9c4bbf3c38d24d46ca5f3340dd8d66f Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 09:59:16 -0300 Subject: [PATCH 39/59] perf: remove redundant collection operation --- .../send/PacketPlayerWorldSceneInfoListNotify.java | 2 +- .../emu/grasscutter/utils/StartupArguments.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java index dd7d0be1e..a61386691 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java @@ -27,7 +27,7 @@ public class PacketPlayerWorldSceneInfoListNotify extends BasePacket { /* Add scene-specific data */ // Scenetags - if (sceneTags.keySet().contains(scene)) { + if (sceneTags.containsKey(scene)) { worldInfoBuilder.addAllSceneTagIdList( sceneTags.entrySet().stream() .filter(e -> e.getKey().equals(scene)) diff --git a/src/main/java/emu/grasscutter/utils/StartupArguments.java b/src/main/java/emu/grasscutter/utils/StartupArguments.java index 1aae558bb..d538c729a 100644 --- a/src/main/java/emu/grasscutter/utils/StartupArguments.java +++ b/src/main/java/emu/grasscutter/utils/StartupArguments.java @@ -61,13 +61,12 @@ public interface StartupArguments { // Aliases. "-v", StartupArguments::printVersion)); - putAll( - Map.of( - "-debugall", - parameter -> { - StartupArguments.enableDebug("all"); - return false; - })); + put( + "-debugall", + parameter -> { + StartupArguments.enableDebug("all"); + return false; + }); } }; From 3d00abcc91609c4e67ea84f4142e783a02385160 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:00:07 -0300 Subject: [PATCH 40/59] perf: we can just equalsIgnoreCase --- .../command/commands/TrialAvatarActivityCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/command/commands/TrialAvatarActivityCommand.java b/src/main/java/emu/grasscutter/command/commands/TrialAvatarActivityCommand.java index d375f490d..46382bf9d 100644 --- a/src/main/java/emu/grasscutter/command/commands/TrialAvatarActivityCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/TrialAvatarActivityCommand.java @@ -131,7 +131,7 @@ public final class TrialAvatarActivityCommand implements CommandHandler { translate( sender, "commands.trialAvatarActivity.success_reward", Integer.parseInt(param))); } else { - if (!param.toLowerCase().equals("all")) { + if (!param.equalsIgnoreCase("all")) { CommandHandler.sendMessage( sender, translate(sender, "commands.trialAvatarActivity.invalid_param")); return; From 45bf5edb138b396e15a06d66b96d096af50f9ad7 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:01:03 -0300 Subject: [PATCH 41/59] perf: stream api can be simplified here --- .../emu/grasscutter/game/managers/forging/ForgingManager.java | 2 +- .../server/packet/send/PacketCreateVehicleRsp.java | 4 ++-- .../server/packet/send/PacketStoreItemDelNotify.java | 2 +- src/main/java/emu/grasscutter/utils/lang/Language.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java b/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java index e8edc63b7..07a9685a6 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ForgingManager.java @@ -314,6 +314,6 @@ public final class ForgingManager extends BasePlayerManager { this.sendForgeQueueDataNotify(); // Reset changed flags. - this.player.getActiveForges().stream().forEach(forge -> forge.setChanged(false)); + this.player.getActiveForges().forEach(forge -> forge.setChanged(false)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java index 3f7a8a088..2d6403e42 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java @@ -26,13 +26,13 @@ public class PacketCreateVehicleRsp extends BasePacket { && ((EntityVehicle) entity).getOwner().equals(player)) .toList(); - previousVehicles.stream() + previousVehicles .forEach( entity -> { List vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList(); - vehicleMembers.stream() + vehicleMembers .forEach( vehicleMember -> player .getScene() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java index aa1ea7bed..c1183a935 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketStoreItemDelNotify.java @@ -29,7 +29,7 @@ public class PacketStoreItemDelNotify extends BasePacket { StoreItemDelNotify.Builder proto = StoreItemDelNotify.newBuilder().setStoreType(StoreType.STORE_TYPE_PACK); - items.stream().forEach(item -> proto.addGuidList(item.getGuid())); + items.forEach(item -> proto.addGuidList(item.getGuid())); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index fe172270e..0ef2207c4 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -264,7 +264,7 @@ public final class Language { List> languageMaps = IntStream.range(0, TextStrings.NUM_LANGUAGES) .mapToObj(mapLanguageMaps::get) - .collect(Collectors.toList()); + .toList(); Map canonicalTextStrings = new HashMap<>(); return new Int2ObjectOpenHashMap<>( From 809009f96c827f8a6f24e01bc3db427eb0a700a2 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:02:56 -0300 Subject: [PATCH 42/59] refactor: null check is not necessary, we have instanceof --- .../server/packet/recv/HandlerSceneEntityDrownReq.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java index bfeaafd9a..133c06cfc 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java @@ -16,7 +16,7 @@ public class HandlerSceneEntityDrownReq extends PacketHandler { GameEntity entity = session.getPlayer().getScene().getEntityById(req.getEntityId()); - if (entity == null || !(entity instanceof EntityMonster || entity instanceof EntityAvatar)) { + if (!(entity instanceof EntityMonster || entity instanceof EntityAvatar)) { return; } From db280387ba918b64d6dacdae998c16f73edf8f54 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:06:57 -0300 Subject: [PATCH 43/59] chore: fix codestyle indentation --- .../command/commands/GiveCommand.java | 159 ++++++------------ .../cooking/CookingCompoundManager.java | 65 +++---- .../game/world/SceneGroupInstance.java | 57 +++++-- .../server/game/GameServerPacketHandler.java | 18 +- .../emu/grasscutter/utils/JsonAdapters.java | 44 +++-- 5 files changed, 154 insertions(+), 189 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index f7b02892b..b196e09a2 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java @@ -1,59 +1,43 @@ package emu.grasscutter.command.commands; +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.data.GameData; +import emu.grasscutter.data.GameDepot; +import emu.grasscutter.data.excels.ItemData; +import emu.grasscutter.data.excels.avatar.AvatarData; +import emu.grasscutter.data.excels.reliquary.ReliquaryAffixData; +import emu.grasscutter.data.excels.reliquary.ReliquaryMainPropData; +import emu.grasscutter.game.avatar.Avatar; +import emu.grasscutter.game.inventory.GameItem; +import emu.grasscutter.game.inventory.ItemType; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.props.ActionReason; +import emu.grasscutter.game.props.FightProperty; +import lombok.Setter; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.regex.Pattern; + import static emu.grasscutter.GameConstants.*; import static emu.grasscutter.command.CommandHelpers.*; -import emu.grasscutter.command.*; -import emu.grasscutter.data.*; -import emu.grasscutter.data.excels.ItemData; -import emu.grasscutter.data.excels.avatar.AvatarData; -import emu.grasscutter.data.excels.reliquary.*; -import emu.grasscutter.game.avatar.Avatar; -import emu.grasscutter.game.inventory.*; -import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.props.*; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.regex.Pattern; -import lombok.Setter; - -@Command( - label = "give", - aliases = {"g", "item", "giveitem"}, - usage = { - "(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", - " [lv] [x] [] [[,]]..." - }, - permission = "player.give", - permissionTargeted = "player.give.others", - threading = true) +@Command(label = "give", aliases = {"g", "item", "giveitem"}, usage = {"(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", " [lv] [x] [] [[,]]..."}, permission = "player.give", permissionTargeted = "player.give.others", threading = true) public final class GiveCommand implements CommandHandler { - private static final Map> intCommandHandlers = - Map.ofEntries( - Map.entry(lvlRegex, GiveItemParameters::setLvl), - Map.entry(refineRegex, GiveItemParameters::setRefinement), - Map.entry(amountRegex, GiveItemParameters::setAmount), - Map.entry(constellationRegex, GiveItemParameters::setConstellation), - Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); + private static final Map> intCommandHandlers = Map.ofEntries(Map.entry(lvlRegex, GiveItemParameters::setLvl), Map.entry(refineRegex, GiveItemParameters::setRefinement), Map.entry(amountRegex, GiveItemParameters::setAmount), Map.entry(constellationRegex, GiveItemParameters::setConstellation), Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); private static Avatar makeAvatar(GiveItemParameters param) { - return makeAvatar( - param.avatarData, - param.lvl, - Avatar.getMinPromoteLevel(param.lvl), - param.constellation, - param.skillLevel); + return makeAvatar(param.avatarData, param.lvl, Avatar.getMinPromoteLevel(param.lvl), param.constellation, param.skillLevel); } - private static Avatar makeAvatar( - AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { + private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { Avatar avatar = new Avatar(avatarData); avatar.setLevel(level); avatar.setPromoteLevel(promoteLevel); - avatar - .getSkillDepot() - .getSkillsAndEnergySkill() - .forEach(id -> avatar.setSkillLevel(id, skillLevel)); + avatar.getSkillDepot().getSkillsAndEnergySkill().forEach(id -> avatar.setSkillLevel(id, skillLevel)); avatar.forceConstellationLevel(constellation); avatar.recalcStats(true); avatar.save(); @@ -63,16 +47,13 @@ public final class GiveCommand implements CommandHandler { private static void giveAllAvatars(Player player, GiveItemParameters param) { int promoteLevel = Avatar.getMinPromoteLevel(param.lvl); if (param.constellation < 0 || param.constellation > 6) - param.constellation = - 6; // constellation's default is -1 so if no parameters set for constellations it'll + param.constellation = 6; // constellation's default is -1 so if no parameters set for constellations it'll // automatically be 6 for (AvatarData avatarData : GameData.getAvatarDataMap().values()) { int id = avatarData.getId(); if (id < 10000002 || id >= 11000000) continue; // Exclude test avatars // Don't try to add each avatar to the current team - player.addAvatar( - makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), - false); + player.addAvatar(makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), false); } } @@ -112,7 +93,7 @@ public final class GiveCommand implements CommandHandler { item.setTotalExp(totalExp); int numAffixes = param.data.getAppendPropNum() + (param.lvl - 1) / 4; if (param.mainPropId > 0) // Keep random mainProp if we didn't specify one - item.setMainPropId(param.mainPropId); + item.setMainPropId(param.mainPropId); if (param.appendPropIdList != null) { item.getAppendPropIdList().clear(); item.getAppendPropIdList().addAll(param.appendPropIdList); @@ -124,17 +105,14 @@ public final class GiveCommand implements CommandHandler { return items; } - private static int getArtifactMainProp(ItemData itemData, FightProperty prop) - throws IllegalArgumentException { + private static int getArtifactMainProp(ItemData itemData, FightProperty prop) throws IllegalArgumentException { if (prop != FightProperty.FIGHT_PROP_NONE) - for (ReliquaryMainPropData data : - GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) + for (ReliquaryMainPropData data : GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) if (data.getWeight() > 0 && data.getFightProp() == prop) return data.getId(); throw new IllegalArgumentException(); } - private static List getArtifactAffixes(ItemData itemData, FightProperty prop) - throws IllegalArgumentException { + private static List getArtifactAffixes(ItemData itemData, FightProperty prop) throws IllegalArgumentException { if (prop == FightProperty.FIGHT_PROP_NONE) { throw new IllegalArgumentException(); } @@ -147,8 +125,7 @@ public final class GiveCommand implements CommandHandler { return affixes; } - private static int getAppendPropId(String substatText, ItemData itemData) - throws IllegalArgumentException { + private static int getAppendPropId(String substatText, ItemData itemData) throws IllegalArgumentException { // If the given substat text is an integer, we just use that as the append prop ID. try { return Integer.parseInt(substatText); @@ -165,8 +142,7 @@ public final class GiveCommand implements CommandHandler { substatTier = Integer.parseInt(substatArgs[1]); } - List substats = - getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); + List substats = getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); if (substats.isEmpty()) { throw new IllegalArgumentException(); @@ -178,8 +154,7 @@ public final class GiveCommand implements CommandHandler { } } - private static void parseRelicArgs(GiveItemParameters param, List args) - throws IllegalArgumentException { + private static void parseRelicArgs(GiveItemParameters param, List args) throws IllegalArgumentException { // Get the main stat from the arguments. // If the given argument is an integer, we use that. // If not, we check if the argument string is in the main prop map. @@ -189,8 +164,7 @@ public final class GiveCommand implements CommandHandler { param.mainPropId = Integer.parseInt(mainPropIdString); } catch (NumberFormatException ignored) { // This can in turn throw an exception which we don't want to catch here. - param.mainPropId = - getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); + param.mainPropId = getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); } // Get substats. @@ -271,8 +245,7 @@ public final class GiveCommand implements CommandHandler { giveAllWeapons(player, param); } - private GiveItemParameters parseArgs(Player sender, List args) - throws IllegalArgumentException { + private GiveItemParameters parseArgs(Player sender, List args) throws IllegalArgumentException { GiveItemParameters param = new GiveItemParameters(); // Extract any tagged arguments (e.g. "lv90", "x100", "r5") @@ -314,9 +287,7 @@ public final class GiveCommand implements CommandHandler { param.avatarData = GameData.getAvatarDataMap().get(param.id - 1000 + 10_000_000); isRelic = ((param.data != null) && (param.data.getItemType() == ItemType.ITEM_RELIQUARY)); - if (!isRelic - && !args.isEmpty() - && (param.amount == 1)) { // A concession for the people that truly hate [x]. + if (!isRelic && !args.isEmpty() && (param.amount == 1)) { // A concession for the people that truly hate [x]. try { param.amount = Integer.parseInt(args.remove(0)); } catch (NumberFormatException e) { @@ -394,8 +365,7 @@ public final class GiveCommand implements CommandHandler { if (param.avatarData != null) { Avatar avatar = makeAvatar(param); targetPlayer.addAvatar(avatar); - CommandHandler.sendTranslatedMessage( - sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage(sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); return; } // If it's not an avatar, it needs to be a valid item @@ -406,54 +376,37 @@ public final class GiveCommand implements CommandHandler { switch (param.data.getItemType()) { case ITEM_WEAPON: - targetPlayer - .getInventory() - .addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage( - sender, - "commands.give.given_with_level_and_refinement", - param.id, - param.lvl, - param.refinement, - param.amount, - targetPlayer.getUid()); + targetPlayer.getInventory().addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage(sender, "commands.give.given_with_level_and_refinement", param.id, param.lvl, param.refinement, param.amount, targetPlayer.getUid()); return; case ITEM_RELIQUARY: targetPlayer.getInventory().addItems(makeArtifacts(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage( - sender, - "commands.give.given_level", - param.id, - param.lvl, - param.amount, - targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage(sender, "commands.give.given_level", param.id, param.lvl, param.amount, targetPlayer.getUid()); return; default: - targetPlayer - .getInventory() - .addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage( - sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); + targetPlayer.getInventory().addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage(sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); } } catch (IllegalArgumentException ignored) { } } private enum GiveAllType { - NONE, - ALL, - WEAPONS, - MATS, - AVATARS + NONE, ALL, WEAPONS, MATS, AVATARS } private static class GiveItemParameters { public int id; - @Setter public int lvl = 0; - @Setter public int amount = 1; - @Setter public int refinement = 1; - @Setter public int constellation = -1; - @Setter public int skillLevel = 1; + @Setter + public int lvl = 0; + @Setter + public int amount = 1; + @Setter + public int refinement = 1; + @Setter + public int constellation = -1; + @Setter + public int skillLevel = 1; public int mainPropId = -1; public List appendPropIdList; public ItemData data; diff --git a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java index 0f1b1453f..793bfdcab 100644 --- a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java +++ b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java @@ -4,7 +4,8 @@ import emu.grasscutter.data.GameData; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.excels.CompoundData; import emu.grasscutter.game.inventory.GameItem; -import emu.grasscutter.game.player.*; +import emu.grasscutter.game.player.BasePlayerManager; +import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.net.proto.CompoundQueueDataOuterClass.CompoundQueueData; import emu.grasscutter.net.proto.GetCompoundDataReqOuterClass.GetCompoundDataReq; @@ -12,8 +13,12 @@ import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.PlayerCompoundMaterialReqOuterClass.PlayerCompoundMaterialReq; import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode; import emu.grasscutter.net.proto.TakeCompoundOutputReqOuterClass.TakeCompoundOutputReq; -import emu.grasscutter.server.packet.send.*; +import emu.grasscutter.server.packet.send.PackageTakeCompoundOutputRsp; +import emu.grasscutter.server.packet.send.PacketCompoundDataNotify; +import emu.grasscutter.server.packet.send.PacketGetCompoundDataRsp; +import emu.grasscutter.server.packet.send.PacketPlayerCompoundMaterialRsp; import emu.grasscutter.utils.Utils; + import java.util.*; public class CookingCompoundManager extends BasePlayerManager { @@ -29,33 +34,24 @@ public class CookingCompoundManager extends BasePlayerManager { public static void initialize() { defaultUnlockedCompounds = new HashSet<>(); compoundGroups = new HashMap<>(); - GameData.getCompoundDataMap() - .forEach( - (id, compound) -> { - if (compound.isDefaultUnlocked()) { - defaultUnlockedCompounds.add(id); - } - compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); - }); + GameData.getCompoundDataMap().forEach((id, compound) -> { + if (compound.isDefaultUnlocked()) { + defaultUnlockedCompounds.add(id); + } + compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); + }); // TODO:Because we haven't implemented fishing feature,unlock all compounds related to // fish.Besides,it should be bound to player rather than manager. unlocked = new HashSet<>(defaultUnlockedCompounds); if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error - unlocked.addAll(compoundGroups.get(3)); + unlocked.addAll(compoundGroups.get(3)); } private synchronized List getCompoundQueueData() { - List compoundQueueData = - new ArrayList<>(player.getActiveCookCompounds().size()); + List compoundQueueData = new ArrayList<>(player.getActiveCookCompounds().size()); int currentTime = Utils.getCurrentSeconds(); for (var item : player.getActiveCookCompounds().values()) { - var data = - CompoundQueueData.newBuilder() - .setCompoundId(item.getCompoundId()) - .setOutputCount(item.getOutputCount(currentTime)) - .setOutputTime(item.getOutputTime(currentTime)) - .setWaitCount(item.getWaitCount(currentTime)) - .build(); + var data = CompoundQueueData.newBuilder().setCompoundId(item.getCompoundId()).setOutputCount(item.getOutputCount(currentTime)).setOutputTime(item.getOutputTime(currentTime)).setWaitCount(item.getWaitCount(currentTime)).build(); compoundQueueData.add(data); } return compoundQueueData; @@ -77,16 +73,14 @@ public class CookingCompoundManager extends BasePlayerManager { return; } // check whether the queue is full - if (activeCompounds.containsKey(id) - && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { + if (activeCompounds.containsKey(id) && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_COMPOUND_QUEUE_FULL_VALUE)); return; } // try to consume raw materials if (!player.getInventory().payItems(compound.getInputVec(), count)) { // TODO:I'm not sure whether retcode is correct. - player.sendPacket( - new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); + player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); return; } ActiveCookCompoundData c; @@ -98,13 +92,7 @@ public class CookingCompoundManager extends BasePlayerManager { c = new ActiveCookCompoundData(id, compound.getCostTime(), count, currentTime); activeCompounds.put(id, c); } - var data = - CompoundQueueData.newBuilder() - .setCompoundId(id) - .setOutputCount(c.getOutputCount(currentTime)) - .setOutputTime(c.getOutputTime(currentTime)) - .setWaitCount(c.getWaitCount(currentTime)) - .build(); + var data = CompoundQueueData.newBuilder().setCompoundId(id).setOutputCount(c.getOutputCount(currentTime)).setOutputTime(c.getOutputTime(currentTime)).setWaitCount(c.getWaitCount(currentTime)).build(); player.sendPacket(new PacketPlayerCompoundMaterialRsp(data)); } @@ -136,20 +124,9 @@ public class CookingCompoundManager extends BasePlayerManager { // give player the rewards if (success) { player.getInventory().addItems(allRewards.values(), ActionReason.Compound); - player.sendPacket( - new PackageTakeCompoundOutputRsp( - allRewards.values().stream() - .map( - i -> - ItemParam.newBuilder() - .setItemId(i.getItemId()) - .setCount(i.getCount()) - .build()) - .toList(), - Retcode.RET_SUCC_VALUE)); + player.sendPacket(new PackageTakeCompoundOutputRsp(allRewards.values().stream().map(i -> ItemParam.newBuilder().setItemId(i.getItemId()).setCount(i.getCount()).build()).toList(), Retcode.RET_SUCC_VALUE)); } else { - player.sendPacket( - new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); + player.sendPacket(new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java index a57dc5830..949747717 100644 --- a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java +++ b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java @@ -1,31 +1,51 @@ package emu.grasscutter.game.world; -import dev.morphia.annotations.*; +import dev.morphia.annotations.Entity; +import dev.morphia.annotations.Id; +import dev.morphia.annotations.Indexed; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; -import emu.grasscutter.scripts.data.*; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import lombok.*; +import emu.grasscutter.scripts.data.SceneGadget; +import emu.grasscutter.scripts.data.SceneGroup; +import lombok.Getter; +import lombok.Setter; import org.bson.types.ObjectId; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + @Entity(value = "group_instances", useDiscriminator = false) public final class SceneGroupInstance { - @Id private ObjectId id; + @Id + private ObjectId id; - @Indexed private int ownerUid; // This group is owned by the host player - @Getter private int groupId; + @Indexed + private int ownerUid; // This group is owned by the host player + @Getter + private int groupId; - @Getter private transient SceneGroup luaGroup; - @Getter @Setter private int targetSuiteId; - @Getter @Setter private int activeSuiteId; - @Getter private final Set deadEntities; // Config_ids + @Getter + private transient SceneGroup luaGroup; + @Getter + @Setter + private int targetSuiteId; + @Getter + @Setter + private int activeSuiteId; + @Getter + private final Set deadEntities; // Config_ids private boolean isCached; - @Getter private final Map cachedGadgetStates; - @Getter private final Map cachedVariables; + @Getter + private final Map cachedGadgetStates; + @Getter + private final Map cachedVariables; - @Getter @Setter private int lastTimeRefreshed; + @Getter + @Setter + private int lastTimeRefreshed; public SceneGroupInstance(SceneGroup group, Player owner) { this.luaGroup = group; @@ -39,10 +59,11 @@ public final class SceneGroupInstance { this.cachedVariables = new ConcurrentHashMap<>(); this.isCached = - false; // This is true when the group is not loaded on scene but caches suite data + false; // This is true when the group is not loaded on scene but caches suite data } - @Deprecated // Morphia only! + @Deprecated + // Morphia only! SceneGroupInstance() { this.cachedVariables = new ConcurrentHashMap<>(); this.deadEntities = new HashSet<>(); @@ -65,7 +86,7 @@ public final class SceneGroupInstance { public void cacheGadgetState(SceneGadget g, int state) { if (g.persistent) // Only cache when is persistent - cachedGadgetStates.put(g.config_id, state); + cachedGadgetStates.put(g.config_id, state); } public int getCachedGadgetState(SceneGadget g) { diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index 0cdeb63cd..d1e47b54d 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -1,13 +1,17 @@ package emu.grasscutter.server.game; -import static emu.grasscutter.config.Configuration.GAME_INFO; - import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; -import emu.grasscutter.net.packet.*; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.packet.PacketOpcodesUtils; import emu.grasscutter.server.event.game.ReceivePacketEvent; import emu.grasscutter.server.game.GameSession.SessionState; -import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; + +import static emu.grasscutter.config.Configuration.GAME_INFO; public final class GameServerPacketHandler { private final Int2ObjectMap handlers; @@ -29,7 +33,7 @@ public final class GameServerPacketHandler { this.handlers.put(opcode.value(), packetHandler); } catch (Exception e) { Grasscutter.getLogger() - .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); + .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); } } @@ -79,7 +83,7 @@ public final class GameServerPacketHandler { ReceivePacketEvent event = new ReceivePacketEvent(session, opcode, payload); event.call(); if (!event.isCanceled()) // If event is not canceled, continue. - handler.handle(session, header, event.getPacketData()); + handler.handle(session, header, event.getPacketData()); } catch (Exception ex) { // TODO Remove this when no more needed ex.printStackTrace(); @@ -89,7 +93,7 @@ public final class GameServerPacketHandler { // Log unhandled packets if (GAME_INFO.logPackets == ServerDebugMode.MISSING - || GAME_INFO.logPackets == ServerDebugMode.ALL) { + || GAME_INFO.logPackets == ServerDebugMode.ALL) { Grasscutter.getLogger() .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); } diff --git a/src/main/java/emu/grasscutter/utils/JsonAdapters.java b/src/main/java/emu/grasscutter/utils/JsonAdapters.java index a44e46bac..d5f765bee 100644 --- a/src/main/java/emu/grasscutter/utils/JsonAdapters.java +++ b/src/main/java/emu/grasscutter/utils/JsonAdapters.java @@ -1,16 +1,25 @@ package emu.grasscutter.utils; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.*; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; import emu.grasscutter.data.common.DynamicFloat; -import emu.grasscutter.game.world.*; +import emu.grasscutter.game.world.GridPosition; +import emu.grasscutter.game.world.Position; import it.unimi.dsi.fastutil.floats.FloatArrayList; -import it.unimi.dsi.fastutil.ints.*; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import lombok.val; + import java.io.IOException; import java.lang.reflect.Field; -import java.util.*; -import lombok.val; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Objects; public interface JsonAdapters { class DynamicFloatAdapter extends TypeAdapter { @@ -31,24 +40,25 @@ public interface JsonAdapters { val opStack = new ArrayList(); while (reader.hasNext()) { opStack.add( - switch (reader.peek()) { - case STRING -> new DynamicFloat.StackOp(reader.nextString()); - case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); - case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); - default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); - }); + switch (reader.peek()) { + case STRING -> new DynamicFloat.StackOp(reader.nextString()); + case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); + case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); + default -> throw new IOException( + "Invalid DynamicFloat definition - " + reader.peek().name()); + }); } reader.endArray(); return new DynamicFloat(opStack); } default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); + "Invalid DynamicFloat definition - " + reader.peek().name()); } } @Override - public void write(JsonWriter writer, DynamicFloat f) {} + public void write(JsonWriter writer, DynamicFloat f) { + } } class IntListAdapter extends TypeAdapter { @@ -70,7 +80,7 @@ public interface JsonAdapters { public void write(JsonWriter writer, IntList l) throws IOException { writer.beginArray(); for (val i : l) // .forEach() doesn't appreciate exceptions - writer.value(i); + writer.value(i); writer.endArray(); } } @@ -107,7 +117,7 @@ public interface JsonAdapters { throw new IOException("Invalid GridPosition definition - " + in.peek().name()); return new GridPosition( - Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); + Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); } } From 3b6864533053a3a794eba114458294a3cf5977a5 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:09:59 -0300 Subject: [PATCH 44/59] refactor: number comparison --- .../data/excels/RefreshPolicyExcelConfigData.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java index 6c48ec1b2..580eeeb75 100644 --- a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java @@ -49,9 +49,9 @@ public class RefreshPolicyExcelConfigData extends GameResource { upperBound( params, (int) params.get(0), (int) params.get(params.size() - 1), (int) temp); var upper_bound = params.get(upper_bound_idx); - if (params.get(params.size() - 1) == upper_bound) { + if (params.get(params.size() - 1).equals(upper_bound)) { return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7; - } else if (params.get(0) == upper_bound) { + } else if (params.get(0).equals(upper_bound)) { return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7; } return (params.get(upper_bound_idx - 1) - params.get(0)); @@ -65,9 +65,9 @@ public class RefreshPolicyExcelConfigData extends GameResource { upperBound( params, (int) params.get(0), (int) params.get(params.size() - 1), (int) temp); var upper_bound = params.get(upper_bound_idx); - if (params.get(params.size() - 1) == upper_bound) { + if (params.get(params.size() - 1).equals(upper_bound)) { return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7; - } else if (params.get(0) == upper_bound) { + } else if (params.get(0).equals(upper_bound)) { return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7; } return (params.get(upper_bound_idx - 1) - params.get(0)); From d4ce7aac08824851a50ebd677447191d394f3943 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 10:26:58 -0300 Subject: [PATCH 45/59] refactor: fix nullable params --- .../game/achievement/Achievements.java | 4 + .../AllActivityConditionBuilder.java | 2 +- .../emu/grasscutter/game/avatar/Avatar.java | 655 ++++++++---------- .../emu/grasscutter/utils/lang/Language.java | 2 +- 4 files changed, 279 insertions(+), 384 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index 40b180bb0..d6acf9e11 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievements.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievements.java @@ -231,6 +231,10 @@ public class Achievements { }); var a = this.getAchievement(i); + if(a == null) { + Grasscutter.getLogger().warn("null returned while getting achievement!"); + return; + } a.setStatus(Status.STATUS_REWARD_TAKEN); this.save(); this.sendUpdatePacket(a); diff --git a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java index ea7a4b30e..d13cefb45 100644 --- a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java +++ b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java @@ -25,7 +25,7 @@ public class AllActivityConditionBuilder { private Map initActivityConditions() { Reflections reflector = Grasscutter.reflector; return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream() - .map(this::newInstance) + .map(this::newInstance).filter(Objects::nonNull) .map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h)) .collect( Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index a3070c609..c939c7727 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -1,25 +1,37 @@ 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; import emu.grasscutter.data.binout.OpenConfigEntry; import emu.grasscutter.data.binout.OpenConfigEntry.SkillPointModifier; import emu.grasscutter.data.common.FightPropData; -import emu.grasscutter.data.excels.*; +import emu.grasscutter.data.excels.EquipAffixData; import emu.grasscutter.data.excels.ItemData.WeaponProperty; -import emu.grasscutter.data.excels.avatar.*; +import emu.grasscutter.data.excels.ProudSkillData; +import emu.grasscutter.data.excels.avatar.AvatarData; +import emu.grasscutter.data.excels.avatar.AvatarSkillData; +import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData; import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData.InherentProudSkillOpens; -import emu.grasscutter.data.excels.reliquary.*; +import emu.grasscutter.data.excels.avatar.AvatarTalentData; +import emu.grasscutter.data.excels.reliquary.ReliquaryAffixData; +import emu.grasscutter.data.excels.reliquary.ReliquaryLevelData; +import emu.grasscutter.data.excels.reliquary.ReliquaryMainPropData; +import emu.grasscutter.data.excels.reliquary.ReliquarySetData; import emu.grasscutter.data.excels.trial.TrialAvatarTemplateData; -import emu.grasscutter.data.excels.weapon.*; +import emu.grasscutter.data.excels.weapon.WeaponCurveData; +import emu.grasscutter.data.excels.weapon.WeaponPromoteData; import emu.grasscutter.database.DatabaseHelper; -import emu.grasscutter.game.entity.*; -import emu.grasscutter.game.inventory.*; +import emu.grasscutter.game.entity.EntityAvatar; +import emu.grasscutter.game.entity.EntityWeapon; +import emu.grasscutter.game.inventory.EquipType; +import emu.grasscutter.game.inventory.GameItem; +import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.props.*; +import emu.grasscutter.game.props.ElementType; +import emu.grasscutter.game.props.FetterState; +import emu.grasscutter.game.props.FightProperty; +import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo; import emu.grasscutter.net.proto.AvatarInfoOuterClass.AvatarInfo; import emu.grasscutter.net.proto.AvatarSkillInfoOuterClass.AvatarSkillInfo; @@ -32,68 +44,130 @@ 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.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; +import lombok.val; +import org.bson.types.ObjectId; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.*; import java.util.stream.Stream; -import javax.annotation.*; -import lombok.*; -import org.bson.types.ObjectId; + +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; @Entity(value = "avatars", useDiscriminator = false) public class Avatar { - @Transient @Getter private final Int2ObjectMap equips; - @Transient @Getter private final Int2FloatOpenHashMap fightProperties; - @Transient @Getter private final Int2FloatOpenHashMap fightPropOverrides; - @Id private ObjectId id; - @Indexed @Getter private int ownerId; // Id of player that this avatar belongs to - @Transient private Player owner; - @Transient @Getter private AvatarData avatarData; - @Nullable @Transient @Getter private AvatarSkillDepotData skillDepot; - @Transient @Getter private long guid; // Player unique id - @Getter private int avatarId; // Id of avatar - @Getter @Setter private int level = 1; - @Getter @Setter private int exp; - @Getter @Setter private int promoteLevel; - @Getter @Setter private int satiation; // Fullness - @Getter @Setter private int satiationPenalty; // When eating too much - @Getter @Setter private float currentHp; + @Transient + @Getter + private final Int2ObjectMap equips; + @Transient + @Getter + private final Int2FloatOpenHashMap fightProperties; + @Transient + @Getter + private final Int2FloatOpenHashMap fightPropOverrides; + @Id + private ObjectId id; + @Indexed + @Getter + private int ownerId; // Id of player that this avatar belongs to + @Transient + private Player owner; + @Transient + @Getter + private AvatarData avatarData; + @Nullable + @Transient + @Getter + private AvatarSkillDepotData skillDepot; + @Transient + @Getter + private long guid; // Player unique id + @Getter + private int avatarId; // Id of avatar + @Getter + @Setter + private int level = 1; + @Getter + @Setter + private int exp; + @Getter + @Setter + private int promoteLevel; + @Getter + @Setter + private int satiation; // Fullness + @Getter + @Setter + private int satiationPenalty; // When eating too much + @Getter + @Setter + private float currentHp; private float currentEnergy; - @Transient @Getter private Set extraAbilityEmbryos; + @Transient + @Getter + private Set extraAbilityEmbryos; private List fetters; private final Map skillLevelMap = new Int2IntArrayMap(7); // Talent levels - @Transient @Getter + @Transient + @Getter private final Map skillExtraChargeMap = new Int2IntArrayMap(2); // Charges @Transient - private final Map proudSkillBonusMap = - new Int2IntArrayMap(2); // Talent bonus levels (from const) + private final Map proudSkillBonusMap = new Int2IntArrayMap(2); // Talent bonus levels (from const) - @Getter private int skillDepotId; + @Getter + private int skillDepotId; private Set talentIdList; // Constellation id list - @Getter private Set proudSkillList; // Character passives + @Getter + private Set proudSkillList; // Character passives - @Getter @Setter private int flyCloak; - @Getter @Setter private int costume; - @Getter private int bornTime; + @Getter + @Setter + private int flyCloak; + @Getter + @Setter + private int costume; + @Getter + private int bornTime; - @Getter @Setter private int fetterLevel = 1; - @Getter @Setter private int fetterExp; + @Getter + @Setter + private int fetterLevel = 1; + @Getter + @Setter + private int fetterExp; - @Getter @Setter private int nameCardRewardId; - @Getter @Setter private int nameCardId; + @Getter + @Setter + private int nameCardRewardId; + @Getter + @Setter + private int nameCardId; // trial avatar property - @Getter @Setter private int trialAvatarId = 0; + @Getter + @Setter + private int trialAvatarId = 0; // cannot store to db if grant reason is not integer - @Getter @Setter + @Getter + @Setter private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber(); - @Getter @Setter private int fromParentQuestId = 0; + @Getter + @Setter + private int fromParentQuestId = 0; // so far no outer class or prop value has information of this, but from packet: // 1 = normal, 2 = trial avatar - @Transient @Getter @Setter private int avatarType = Type.NORMAL.getNumber(); + @Transient + @Getter + @Setter + private int avatarType = Type.NORMAL.getNumber(); @Deprecated // Do not use. Morhpia only! public Avatar() { @@ -123,18 +197,13 @@ public class Avatar { this.proudSkillList = new HashSet<>(); // Combat properties - Stream.of(FightProperty.values()) - .map(FightProperty::getId) - .filter(id -> (id > 0) && (id < 3000)) - .forEach(id -> this.setFightProperty(id, 0f)); + Stream.of(FightProperty.values()).map(FightProperty::getId).filter(id -> (id > 0) && (id < 3000)).forEach(id -> this.setFightProperty(id, 0f)); - this.setSkillDepotData( - switch (this.getAvatarId()) { - case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); - case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap() - .get(701); - default -> data.getSkillDepot(); - }); + this.setSkillDepotData(switch (this.getAvatarId()) { + case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); + case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap().get(701); + default -> data.getSkillDepot(); + }); // Set stats this.recalcStats(); @@ -166,8 +235,7 @@ public class Avatar { * @return True if the avatar is a main character. */ public boolean isMainCharacter() { - return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE) - .contains(this.getAvatarId()); + return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE).contains(this.getAvatarId()); } public Player getPlayer() { @@ -229,7 +297,8 @@ public class Avatar { /** * @return The avatar's equipped weapon. */ - @Nullable public GameItem getWeapon() { + @Nullable + public GameItem getWeapon() { return this.getEquipBySlot(EquipType.EQUIP_WEAPON); } @@ -259,24 +328,17 @@ public class Avatar { * Changes this avatar's skill depot. * * @param skillDepot The new skill depot. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. */ public void setSkillDepotData(AvatarSkillDepotData skillDepot, boolean notify) { // Set id and depot this.skillDepotId = skillDepot.getId(); this.skillDepot = skillDepot; // Add any missing skills - this.skillDepot - .getSkillsAndEnergySkill() - .forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); + this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); // Add proud skills this.proudSkillList.clear(); - skillDepot.getInherentProudSkillOpens().stream() - .filter(openData -> openData.getProudSkillGroupId() > 0) - .filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) - .mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1) - .filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)) - .forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); + skillDepot.getInherentProudSkillOpens().stream().filter(openData -> openData.getProudSkillGroupId() > 0).filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()).mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1).filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)).forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); this.recalcStats(); if (notify) { @@ -300,7 +362,7 @@ public class Avatar { * in its 'candSkillDepot's. * * @param elementTypeToChange The new element to change to. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. * @return True if the element was changed, false otherwise. */ public boolean changeElement(@Nonnull ElementType elementTypeToChange, boolean notify) { @@ -348,8 +410,7 @@ public class Avatar { ElementType element = depot.getElementType(); var maxEnergy = depot.getEnergySkillData().getCostElemVal(); this.setFightProperty(element.getMaxEnergyProp(), maxEnergy); - this.setFightProperty( - element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); + this.setFightProperty(element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); } } @@ -377,13 +438,10 @@ public class Avatar { return getFightProperties().getOrDefault(prop.getId(), 0f); } - public Map - getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. + public Map getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. var map = new Int2IntOpenHashMap(); - this.skillDepot - .getSkillsAndEnergySkill() - .forEach( - skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); + if (this.skillDepot == null) return map; + this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); return map; } @@ -391,21 +449,19 @@ public class Avatar { // levels. public Map getProudSkillBonusMap() { var map = new Int2IntArrayMap(); - this.skillDepot - .getSkillsAndEnergySkill() - .forEach( - skillId -> { - val skillData = GameData.getAvatarSkillDataMap().get(skillId); - if (skillData == null) return; - int proudSkillGroupId = skillData.getProudSkillGroupId(); - int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); - int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); - int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); - if (maxLevel > 0) { - bonus = Math.min(bonus, maxLevel - curLevel); - } - map.put(proudSkillGroupId, bonus); - }); + if (this.skillDepot == null) return map; + this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> { + val skillData = GameData.getAvatarSkillDataMap().get(skillId); + if (skillData == null) return; + int proudSkillGroupId = skillData.getProudSkillGroupId(); + int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); + int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); + int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); + if (maxLevel > 0) { + bonus = Math.min(bonus, maxLevel - curLevel); + } + map.put(proudSkillGroupId, bonus); + }); return map; } @@ -439,9 +495,7 @@ public class Avatar { if (otherAvatar != null) { // Unequip other avatar's item if (otherAvatar.unequipItem(item.getItemData().getEquipType())) { - getPlayer() - .sendPacket( - new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); + getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); } // Swap with other avatar if (getEquips().containsKey(itemEquipType.getValue())) { @@ -459,14 +513,9 @@ public class Avatar { this.getEquips().put(itemEquipType.getValue(), item); if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) { - if (!(item.getWeaponEntity() != null - && item.getWeaponEntity().getScene() == getPlayer().getScene())) { - item.setWeaponEntity( - new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); - this.getPlayer() - .getScene() - .getWeaponEntities() - .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) { + item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); + this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); } // item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); } @@ -504,8 +553,7 @@ public class Avatar { public void recalcStats(boolean forceSendAbilityChange) { // Setup var data = this.getAvatarData(); - var promoteData = - GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); + var promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); var setMap = new Int2IntOpenHashMap(); // Extra ability embryos @@ -518,27 +566,18 @@ public class Avatar { this.setNameCardId(data.getNameCardId()); // Get hp percent, set to 100% if none - float hpPercent = - this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 - ? 1f - : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) - / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); + float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); // Store current energy value for later - float currentEnergy = - (this.getSkillDepot() != null) - ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) - : 0f; + float currentEnergy = (this.getSkillDepot() != null) ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) : 0f; // Clear properties this.getFightProperties().clear(); // Base stats this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel())); - this.setFightProperty( - FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); - this.setFightProperty( - FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); + this.setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); + this.setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical()); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt()); this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f); @@ -560,14 +599,11 @@ public class Avatar { continue; } // Artifact main stat - ReliquaryMainPropData mainPropData = - GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); + ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); if (mainPropData != null) { - ReliquaryLevelData levelData = - GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); + ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); if (levelData != null) { - this.addFightProperty( - mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); + this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); } } // Artifact sub stats @@ -584,32 +620,31 @@ public class Avatar { } // Set stuff - setMap.forEach( - (setId, amount) -> { - ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); - if (setData == null) return; + setMap.forEach((setId, amount) -> { + ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); + if (setData == null) return; - // Calculate how many items are from the set - // Add affix data from set bonus - val setNeedNum = setData.getSetNeedNum(); - for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { - if (amount < setNeedNum[setIndex]) break; + // Calculate how many items are from the set + // Add affix data from set bonus + val setNeedNum = setData.getSetNeedNum(); + for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { + if (amount < setNeedNum[setIndex]) break; - int affixId = (setData.getEquipAffixId() * 10) + setIndex; - EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); - if (affix == null) { - continue; - } + int affixId = (setData.getEquipAffixId() * 10) + setIndex; + EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); + if (affix == null) { + continue; + } - // Add properties from this affix to our avatar - for (FightPropData prop : affix.getAddProps()) { - this.addFightProperty(prop.getProp(), prop.getValue()); - } + // Add properties from this affix to our avatar + for (FightPropData prop : affix.getAddProps()) { + this.addFightProperty(prop.getProp(), prop.getValue()); + } - // Add any skill strings from this affix - this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); - } - }); + // Add any skill strings from this affix + this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); + } + }); // Weapon GameItem weapon = this.getWeapon(); @@ -618,15 +653,11 @@ public class Avatar { WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel()); if (curveData != null) { for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) { - this.addFightProperty( - weaponProperty.getPropType(), - weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); + this.addFightProperty(weaponProperty.getPropType(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); } } // Weapon promotion stats - WeaponPromoteData wepPromoteData = - GameData.getWeaponPromoteData( - weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); + WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); if (wepPromoteData != null) { for (FightPropData prop : wepPromoteData.getAddProps()) { if (prop.getValue() == 0f || prop.getProp() == null) { @@ -661,8 +692,7 @@ public class Avatar { } // Add proud skills and unlock them if needed - AvatarSkillDepotData skillDepot = - GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); + AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); this.getProudSkillList().clear(); if (skillDepot != null) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { @@ -695,31 +725,17 @@ public class Avatar { } // Constellations - this.getTalentIdList() - .intStream() - .mapToObj(GameData.getAvatarTalentDataMap()::get) - .filter(Objects::nonNull) - .map(AvatarTalentData::getOpenConfig) - .filter(Objects::nonNull) - .forEach(this::addToExtraAbilityEmbryos); + this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).forEach(this::addToExtraAbilityEmbryos); // Add any skill strings from this constellation // Set % stats - FightProperty.forEachCompoundProperty( - c -> - this.setFightProperty( - c.getResult(), - this.getFightProperty(c.getFlat()) - + (this.getFightProperty(c.getBase()) - * (1f + this.getFightProperty(c.getPercent()))))); + FightProperty.forEachCompoundProperty(c -> this.setFightProperty(c.getResult(), this.getFightProperty(c.getFlat()) + (this.getFightProperty(c.getBase()) * (1f + this.getFightProperty(c.getPercent()))))); // Reapply all overrides this.fightProperties.putAll(this.fightPropOverrides); // Set current hp - this.setFightProperty( - FightProperty.FIGHT_PROP_CUR_HP, - this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); + this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); // Packet if (getPlayer() != null && getPlayer().hasSentLoginPackets()) { @@ -727,9 +743,7 @@ public class Avatar { getPlayer().sendPacket(new PacketAvatarFightPropNotify(this)); // Update client abilities EntityAvatar entity = this.getAsEntity(); - if (entity != null - && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) - || forceSendAbilityChange)) { + if (entity != null && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) || forceSendAbilityChange)) { getPlayer().sendPacket(new PacketAbilityChangeNotify(entity)); } } @@ -767,19 +781,12 @@ public class Avatar { // Check if new constellation adds +3 to a skill level if (this.calcConstellationExtraLevels(entry) && notifyClient) { // Packet - this.getPlayer() - .sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); + this.getPlayer().sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); } // Check if new constellation adds skill charges if (this.calcConstellationExtraCharges(entry) && notifyClient) { // Packet - Stream.of(entry.getSkillPointModifiers()) - .mapToInt(SkillPointModifier::getSkillId) - .forEach( - skillId -> this.getPlayer() - .sendPacket( - new PacketAvatarSkillMaxChargeCountNotify( - this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); + Stream.of(entry.getSkillPointModifiers()).mapToInt(SkillPointModifier::getSkillId).forEach(skillId -> this.getPlayer().sendPacket(new PacketAvatarSkillMaxChargeCountNotify(this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); } } @@ -793,16 +800,7 @@ public class Avatar { return; } - this.getTalentIdList() - .intStream() - .mapToObj(GameData.getAvatarTalentDataMap()::get) - .filter(Objects::nonNull) - .map(AvatarTalentData::getOpenConfig) - .filter(Objects::nonNull) - .filter(openConfig -> !openConfig.isEmpty()) - .map(GameData.getOpenConfigEntries()::get) - .filter(Objects::nonNull) - .forEach(e -> this.calcConstellation(e, false)); + this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).filter(openConfig -> !openConfig.isEmpty()).map(GameData.getOpenConfigEntries()::get).filter(Objects::nonNull).forEach(e -> this.calcConstellation(e, false)); } private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { @@ -822,17 +820,14 @@ public class Avatar { } private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { - int skillId = - switch (entry.getExtraTalentIndex()) { - case 9 -> this.skillDepot.getEnergySkill(); // Ult skill - case 2 -> (this.skillDepot.getSkills().size() >= 2) - ? this.skillDepot.getSkills().get(1) - : 0; // E skill - case 1 -> (!this.skillDepot.getSkills().isEmpty()) - ? this.skillDepot.getSkills().get(0) - : 0; // Normal Attack (Liney) - default -> 0; - }; + if(this.skillDepot == null) return false; + int skillId = switch (entry.getExtraTalentIndex()) { + case 9 -> this.skillDepot.getEnergySkill(); // Ult skill + case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill + case 1 -> + (!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) + default -> 0; + }; // Sanity check if (skillId == 0) { return false; @@ -851,8 +846,7 @@ public class Avatar { } private int addProudSkillLevelBonus(int proudSkillGroupId, int bonus) { - return this.proudSkillBonusMap.compute( - proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); + return this.proudSkillBonusMap.compute(proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); } public boolean upgradeSkill(int skillId) { @@ -883,9 +877,7 @@ public class Avatar { if (level < 0 || level > 15) return false; var validLevels = GameData.getAvatarSkillLevels(skillId); if (validLevels != null && !validLevels.contains(level)) return false; - int oldLevel = - this.skillLevelMap.getOrDefault( - skillId, 0); // just taking the return value of put would have null concerns + int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns this.skillLevelMap.put(skillId, level); this.save(); @@ -904,7 +896,7 @@ public class Avatar { public boolean unlockConstellation(boolean skipPayment) { int currentTalentLevel = this.getCoreProudSkillLevel(); - if (currentTalentLevel < 0) return false; + if (currentTalentLevel < 0 || this.skillDepot == null) return false; int talentId = this.skillDepot.getTalents().get(currentTalentLevel); return this.unlockConstellation(talentId, skipPayment); } @@ -920,9 +912,7 @@ public class Avatar { var player = this.getPlayer(); // Pay constellation item if possible - if (!skipPayment - && (player != null) - && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { + if (!skipPayment && (player != null) && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { return false; } @@ -953,8 +943,7 @@ public class Avatar { this.save(); return; } - this.talentIdList.removeAll( - this.getTalentIdList()); // Only remove constellations from active depot + this.talentIdList.removeAll(this.getTalentIdList()); // Only remove constellations from active depot for (int i = 0; i < level; i++) this.unlockConstellation(true); this.recalcStats(); this.save(); @@ -963,12 +952,7 @@ public class Avatar { public boolean sendSkillExtraChargeMap() { val map = this.getSkillExtraChargeMap(); if (map.isEmpty()) return false; - this.getPlayer() - .sendPacket( - new PacketAvatarSkillInfoNotify( - this.guid, - new Int2IntArrayMap( - map))); // TODO: Remove this allocation when updating interfaces to FastUtils + this.getPlayer().sendPacket(new PacketAvatarSkillInfoNotify(this.guid, new Int2IntArrayMap(map))); // TODO: Remove this allocation when updating interfaces to FastUtils // later return true; } @@ -1000,12 +984,7 @@ public class Avatar { } if (this.fetters != null) { - this.fetters.forEach( - fetterId -> - avatarFetter.addFetterList( - FetterData.newBuilder() - .setFetterId(fetterId) - .setFetterState(FetterState.FINISH.getValue()))); + this.fetters.forEach(fetterId -> avatarFetter.addFetterList(FetterData.newBuilder().setFetterId(fetterId).setFetterState(FetterState.FINISH.getValue()))); } int cardId = this.getNameCardId(); @@ -1014,100 +993,40 @@ public class Avatar { avatarFetter.addRewardedFetterLevelList(10); } - AvatarInfo.Builder avatarInfo = - AvatarInfo.newBuilder() - .setAvatarId(this.getAvatarId()) - .setGuid(this.getGuid()) - .setLifeState(1) - .addAllTalentIdList(this.getTalentIdList()) - .putAllFightPropMap(this.getFightProperties()) - .setSkillDepotId(this.getSkillDepotId()) - .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) - .putAllSkillLevelMap(this.getSkillLevelMap()) - .addAllInherentProudSkillList(this.getProudSkillList()) - .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) - .setAvatarType(this.getAvatarType()) - .setBornTime(this.getBornTime()) - .setFetterInfo(avatarFetter) - .setWearingFlycloakId(this.getFlyCloak()) - .setCostumeId(this.getCostume()); + AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder().setAvatarId(this.getAvatarId()).setGuid(this.getGuid()).setLifeState(1).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).putAllSkillLevelMap(this.getSkillLevelMap()).addAllInherentProudSkillList(this.getProudSkillList()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setAvatarType(this.getAvatarType()).setBornTime(this.getBornTime()).setFetterInfo(avatarFetter).setWearingFlycloakId(this.getFlyCloak()).setCostumeId(this.getCostume()); - this.getSkillExtraChargeMap() - .forEach( - (skillId, count) -> - avatarInfo.putSkillMap( - skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); + this.getSkillExtraChargeMap().forEach((skillId, count) -> avatarInfo.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); this.getEquips().forEach((k, item) -> avatarInfo.addEquipGuidList(item.getGuid())); - avatarInfo.putPropMap( - PlayerProperty.PROP_LEVEL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - avatarInfo.putPropMap( - PlayerProperty.PROP_EXP.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - avatarInfo.putPropMap( - PlayerProperty.PROP_BREAK_LEVEL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - avatarInfo.putPropMap( - PlayerProperty.PROP_SATIATION_VAL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - avatarInfo.putPropMap( - PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), - ProtoHelper.newPropValue( - PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + avatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + avatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + avatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); return avatarInfo.build(); } // used only in character showcase public ShowAvatarInfo toShowAvatarInfoProto() { - AvatarFetterInfo.Builder avatarFetter = - AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); + AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); - ShowAvatarInfo.Builder showAvatarInfo = - ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder() - .setAvatarId(avatarId) - .addAllTalentIdList(this.getTalentIdList()) - .putAllFightPropMap(this.getFightProperties()) - .setSkillDepotId(this.getSkillDepotId()) - .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) - .addAllInherentProudSkillList(this.getProudSkillList()) - .putAllSkillLevelMap(this.getSkillLevelMap()) - .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) - .setFetterInfo(avatarFetter) - .setCostumeId(this.getCostume()); + ShowAvatarInfo.Builder showAvatarInfo = ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder().setAvatarId(avatarId).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).addAllInherentProudSkillList(this.getProudSkillList()).putAllSkillLevelMap(this.getSkillLevelMap()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setFetterInfo(avatarFetter).setCostumeId(this.getCostume()); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_LEVEL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_EXP.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_BREAK_LEVEL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_SATIATION_VAL.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), - ProtoHelper.newPropValue( - PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + showAvatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + showAvatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + showAvatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA); - showAvatarInfo.putPropMap( - PlayerProperty.PROP_MAX_STAMINA.getId(), - ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); + showAvatarInfo.putPropMap(PlayerProperty.PROP_MAX_STAMINA.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); for (GameItem item : this.getEquips().values()) { if (item.getItemType() == ItemType.ITEM_RELIQUARY) { - showAvatarInfo.addEquipList( - ShowEquip.newBuilder() - .setItemId(item.getItemId()) - .setReliquary(item.toReliquaryProto())); + showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setReliquary(item.toReliquaryProto())); } else if (item.getItemType() == ItemType.ITEM_WEAPON) { - showAvatarInfo.addEquipList( - ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); + showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); } } @@ -1117,13 +1036,12 @@ public class Avatar { /** * Converts this avatar into a trial avatar. * - * @param level The avatar's level. - * @param avatarId The ID of the avatar. + * @param level The avatar's level. + * @param avatarId The ID of the avatar. * @param grantReason The reason for granting the avatar. - * @param questId The ID of the quest that granted the avatar. + * @param questId The ID of the quest that granted the avatar. */ - public void setTrialAvatarInfo( - int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { + public void setTrialAvatarInfo(int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { this.setLevel(level); this.setPromoteLevel(getMinPromoteLevel(level)); this.setTrialAvatarId(avatarId); @@ -1140,10 +1058,7 @@ public class Avatar { * @return The avatar's template. */ private int getTrialTemplate() { - return this.getLevel() <= 9 - ? 1 - : (int) - (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels + return this.getLevel() <= 9 ? 1 : (int) (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels } /** @@ -1165,11 +1080,11 @@ public class Avatar { return trialData.getCoreProudSkillLevel(); // enhanced version of weapon } - /** Applies the correct skill level for the trial avatar. */ + /** + * Applies the correct skill level for the trial avatar. + */ public void applyTrialSkillLevels() { - this.getSkillLevelMap() - .keySet() - .forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); + this.getSkillLevelMap().keySet().forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); } /** @@ -1181,9 +1096,7 @@ public class Avatar { if (GameData.getTrialAvatarDataMap().get(this.getTrialAvatarId()) == null) return this.getAvatarData().getInitialWeapon(); - return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null - ? getAvatarData().getInitialWeapon() - : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon + return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null ? getAvatarData().getInitialWeapon() : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon } // Use custom data. @@ -1191,9 +1104,7 @@ public class Avatar { if (trialData == null) return 0; var trialCustomParams = trialData.getTrialAvatarParamList(); - return trialCustomParams.size() < 2 - ? getAvatarData().getInitialWeapon() - : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); + return trialCustomParams.size() < 2 ? getAvatarData().getInitialWeapon() : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); } /** @@ -1204,8 +1115,7 @@ public class Avatar { if (GameData.getTrialAvatarCustomData().isEmpty()) { int trialAvatarTemplateLevel = getTrialTemplate(); - TrialAvatarTemplateData templateData = - GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); + TrialAvatarTemplateData templateData = GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); return templateData == null ? List.of() : templateData.getTrialReliquaryList(); } @@ -1213,14 +1123,13 @@ public class Avatar { var trialData = GameData.getTrialAvatarCustomData().get(this.getTrialAvatarId()); if (trialData == null) return List.of(); - var trialCustomParams = - GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); - return trialCustomParams.size() < 3 - ? List.of() - : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); + var trialCustomParams = GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); + return trialCustomParams.size() < 3 ? List.of() : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); } - /** Applies the correct items for the trial avatar. */ + /** + * Applies the correct items for the trial avatar. + */ public void applyTrialItems() { // Use an enhanced version of the weapon if available. var weapon = new GameItem(this.getTrialWeaponId()); @@ -1230,55 +1139,44 @@ public class Avatar { this.getEquips().put(weapon.getEquipSlot(), weapon); // Add artifacts for the trial avatar. - this.getTrialReliquary() - .forEach( - id -> { - var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); - if (reliquaryData == null) return; + this.getTrialReliquary().forEach(id -> { + var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); + if (reliquaryData == null) return; - var relic = new GameItem(reliquaryData.getReliquaryId()); - relic.setLevel(reliquaryData.getLevel()); - relic.setMainPropId(reliquaryData.getMainPropId()); - relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); - this.getEquips().put(relic.getEquipSlot(), relic); - }); + var relic = new GameItem(reliquaryData.getReliquaryId()); + relic.setLevel(reliquaryData.getLevel()); + relic.setMainPropId(reliquaryData.getMainPropId()); + relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); + this.getEquips().put(relic.getEquipSlot(), relic); + }); // 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()); - }); + GameData.getAvatarCostumeDataItemIdMap().values().forEach(costumeData -> { + if (costumeData.getCharacterId() != this.getAvatarId()) return; + this.setCostume(costumeData.getId()); + }); } } - /** Equips the items applied from {@link Avatar#applyTrialItems()}. */ + /** + * Equips the items applied from {@link Avatar#applyTrialItems()}. + */ public void equipTrialItems() { var player = this.getPlayer(); - this.getEquips() - .values() - .forEach( - item -> { - item.setEquipCharacter(this.getAvatarId()); - item.setOwner(player); - if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { - if (!(item.getWeaponEntity() != null - && item.getWeaponEntity().getScene() == player.getScene())) { - item.setWeaponEntity( - new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); - player - .getScene() - .getWeaponEntities() - .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); - } + this.getEquips().values().forEach(item -> { + item.setEquipCharacter(this.getAvatarId()); + item.setOwner(player); + if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { + if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) { + item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); + player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + } - player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); - } - }); + player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); + } + }); } /** @@ -1287,26 +1185,20 @@ public class Avatar { * @return The trial info protocol buffer. */ public TrialAvatarInfo toTrialInfo() { - var trialAvatar = - TrialAvatarInfo.newBuilder() - .setTrialAvatarId(this.getTrialAvatarId()) - .setGrantRecord( - TrialAvatarGrantRecord.newBuilder() - .setGrantReason(this.getGrantReason()) - .setFromParentQuestId(this.getFromParentQuestId())); + var trialAvatar = TrialAvatarInfo.newBuilder().setTrialAvatarId(this.getTrialAvatarId()).setGrantRecord(TrialAvatarGrantRecord.newBuilder().setGrantReason(this.getGrantReason()).setFromParentQuestId(this.getFromParentQuestId())); // Check if the avatar is a trial avatar. if (this.getTrialAvatarId() > 0) { // Add the artifacts and weapons for the avatar. - trialAvatar.addAllTrialEquipList( - this.getEquips().values().stream().map(GameItem::toProto).toList()); + trialAvatar.addAllTrialEquipList(this.getEquips().values().stream().map(GameItem::toProto).toList()); } return trialAvatar.build(); } @PostLoad - private void onLoad() {} + private void onLoad() { + } @PrePersist private void prePersist() { @@ -1316,8 +1208,7 @@ public class Avatar { @AllArgsConstructor @Getter enum Type { - NORMAL(1), - TRIAL(2); + NORMAL(1), TRIAL(2); final int number; } diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 0ef2207c4..293ecd4be 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -347,7 +347,7 @@ public final class Language { return Files.getLastModifiedTime(path).toMillis(); } catch (Exception ignored) { Grasscutter.getLogger() - .debug("Exception while checking modified time: ", path); + .debug("Exception while checking modified time: {}", path); return Long.MAX_VALUE; // Don't use cache, something has gone wrong } }) From 8c53f2b6796fc42a7dbe28677656beac6e26b72d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:49:49 +0000 Subject: [PATCH 46/59] Format code [skip actions] --- .../emu/grasscutter/command/CommandMap.java | 13 +- .../command/commands/AchievementCommand.java | 25 +- .../command/commands/GiveCommand.java | 132 ++-- .../command/commands/SendMailCommand.java | 3 +- .../command/commands/SetSceneTagCommand.java | 3 +- .../java/emu/grasscutter/data/DataLoader.java | 24 +- .../java/emu/grasscutter/data/GameData.java | 14 +- .../emu/grasscutter/data/ResourceLoader.java | 55 +- .../data/binout/AbilityEmbryoEntry.java | 1 - .../data/binout/AbilityMixinData.java | 4 +- .../data/binout/AbilityModifier.java | 4 +- .../data/binout/AbilityModifierEntry.java | 13 +- .../data/binout/MainQuestData.java | 24 +- .../data/binout/OpenConfigEntry.java | 4 +- .../grasscutter/data/common/CurveInfo.java | 1 - .../grasscutter/data/common/ItemUseData.java | 4 +- .../grasscutter/data/common/OpenCondData.java | 3 +- .../data/common/PropGrowCurve.java | 1 - .../grasscutter/data/excels/CombineData.java | 34 +- .../excels/EnvAnimalGatherConfigData.java | 9 +- .../data/excels/EquipAffixData.java | 18 +- .../data/excels/FetterCharacterCardData.java | 3 +- .../grasscutter/data/excels/FetterData.java | 6 +- .../grasscutter/data/excels/GatherData.java | 9 +- .../data/excels/ProudSkillData.java | 3 +- .../grasscutter/data/excels/RewardData.java | 6 +- .../data/excels/ShopGoodsData.java | 40 +- .../data/excels/avatar/AvatarCostumeData.java | 9 +- .../data/excels/avatar/AvatarCurveData.java | 6 +- .../excels/avatar/AvatarFlycloakData.java | 3 +- .../data/excels/avatar/AvatarLevelData.java | 1 - .../data/excels/avatar/AvatarPromoteData.java | 21 +- .../data/excels/avatar/AvatarTalentData.java | 24 +- .../data/excels/codex/CodexQuestData.java | 12 +- .../data/excels/codex/CodexWeaponData.java | 9 +- .../dungeon/DungeonChallengeConfigData.java | 5 +- .../excels/reliquary/ReliquarySetData.java | 3 +- .../data/excels/tower/TowerScheduleData.java | 4 +- .../data/excels/weapon/WeaponLevelData.java | 1 - .../data/excels/weapon/WeaponPromoteData.java | 3 +- .../data/excels/world/WorldLevelData.java | 3 +- .../emu/grasscutter/data/server/Grid.java | 6 +- .../grasscutter/database/DatabaseHelper.java | 2 +- .../grasscutter/database/DatabaseManager.java | 3 +- .../java/emu/grasscutter/game/Account.java | 44 +- .../emu/grasscutter/game/ability/Ability.java | 3 +- .../game/ability/AbilityManager.java | 23 +- .../game/achievement/Achievements.java | 22 +- .../AllActivityConditionBuilder.java | 3 +- .../emu/grasscutter/game/avatar/Avatar.java | 625 +++++++++++------- .../game/avatar/AvatarStorage.java | 6 +- .../game/battlepass/BattlePassMission.java | 10 +- .../game/battlepass/BattlePassReward.java | 9 +- .../emu/grasscutter/game/chat/ChatSystem.java | 6 +- .../game/combine/CombineManger.java | 3 +- .../game/combine/CombineResult.java | 4 +- .../game/combine/ReliquaryDecomposeEntry.java | 4 +- .../emu/grasscutter/game/drop/DropData.java | 6 +- .../emu/grasscutter/game/drop/DropInfo.java | 4 +- .../game/drop/DropSystemLegacy.java | 3 +- .../game/dungeons/DungeonDrop.java | 4 +- .../game/dungeons/DungeonDropEntry.java | 4 +- ...illMonsterTimeChallengeFactoryHandler.java | 3 +- .../grasscutter/game/entity/EntityRegion.java | 2 +- .../entity/gadget/GadgetGatherObject.java | 3 +- .../grasscutter/game/friends/Friendship.java | 17 +- .../grasscutter/game/gacha/GachaBanner.java | 5 +- .../grasscutter/game/gacha/GachaRecord.java | 1 - .../grasscutter/game/gacha/GachaSystem.java | 4 +- .../emu/grasscutter/game/home/GameHome.java | 17 +- .../game/home/HomeModuleManager.java | 35 +- .../grasscutter/game/home/HomeSceneItem.java | 11 +- .../grasscutter/game/inventory/GameItem.java | 3 +- .../grasscutter/game/inventory/Inventory.java | 28 +- .../grasscutter/game/inventory/ItemDef.java | 1 - .../java/emu/grasscutter/game/mail/Mail.java | 10 +- .../grasscutter/game/mail/MailHandler.java | 10 +- .../game/managers/SotSManager.java | 5 +- .../managers/blossom/BlossomActivity.java | 9 +- .../game/managers/blossom/BlossomManager.java | 2 +- .../cooking/CookingCompoundManager.java | 57 +- .../managers/deforestation/HitTreeRecord.java | 9 +- .../game/managers/energy/EnergyDropEntry.java | 4 +- .../game/managers/energy/EnergyDropInfo.java | 1 - .../game/managers/energy/EnergyManager.java | 3 +- .../energy/SkillParticleGenerationEntry.java | 4 +- .../energy/SkillParticleGenerationInfo.java | 1 - .../managers/forging/ActiveForgeData.java | 24 +- .../game/managers/mapmark/MapMark.java | 1 - .../grasscutter/game/player/PlayerCodex.java | 18 +- .../game/player/PlayerCollectionRecords.java | 4 +- .../emu/grasscutter/game/player/TeamInfo.java | 6 +- .../grasscutter/game/props/ActionReason.java | 4 +- .../props/BattlePassMissionRefreshType.java | 1 - .../game/props/BattlePassMissionStatus.java | 1 - .../game/props/CampTargetType.java | 3 +- .../grasscutter/game/props/ClimateType.java | 3 +- .../grasscutter/game/props/EnterReason.java | 4 +- .../grasscutter/game/props/EntityIdType.java | 4 +- .../grasscutter/game/props/EntityType.java | 4 +- .../grasscutter/game/props/FetterState.java | 4 +- .../emu/grasscutter/game/props/GrowCurve.java | 4 +- .../emu/grasscutter/game/props/ItemUseOp.java | 8 +- .../grasscutter/game/props/ItemUseTarget.java | 8 +- .../emu/grasscutter/game/props/LifeState.java | 4 +- .../grasscutter/game/props/MonsterType.java | 4 +- .../grasscutter/game/props/RefreshType.java | 3 +- .../emu/grasscutter/game/props/SceneType.java | 4 +- .../game/props/ServerBuffType.java | 8 +- .../game/props/WatcherTriggerType.java | 4 +- .../grasscutter/game/props/WeaponType.java | 4 +- .../emu/grasscutter/game/quest/GameQuest.java | 3 +- .../game/quest/enums/LogicType.java | 2 - .../game/quest/enums/ParentQuestState.java | 1 - .../game/quest/enums/QuestCond.java | 3 +- .../game/quest/enums/QuestContent.java | 3 +- .../game/quest/enums/QuestExec.java | 3 +- .../game/quest/enums/QuestGuideType.java | 1 - .../game/quest/enums/QuestShowType.java | 1 - .../game/quest/enums/QuestState.java | 1 - .../game/quest/enums/QuestType.java | 1 - .../game/quest/enums/ShowQuestGuideType.java | 1 - .../emu/grasscutter/game/shop/ShopLimit.java | 1 - .../emu/grasscutter/game/shop/ShopSystem.java | 6 +- .../emu/grasscutter/game/shop/ShopTable.java | 4 +- .../game/systems/InventorySystem.java | 5 +- .../game/tower/TowerLevelRecord.java | 4 +- .../game/tower/TowerScheduleConfig.java | 4 +- .../grasscutter/game/tower/TowerSystem.java | 3 +- .../grasscutter/game/world/GridPosition.java | 3 +- .../emu/grasscutter/game/world/Location.java | 3 +- .../emu/grasscutter/game/world/Position.java | 4 +- .../emu/grasscutter/game/world/Scene.java | 3 +- .../game/world/SceneGroupInstance.java | 46 +- .../emu/grasscutter/game/world/World.java | 4 +- .../game/world/WorldDataSystem.java | 2 +- .../grasscutter/net/packet/BasePacket.java | 18 +- .../java/emu/grasscutter/plugin/Plugin.java | 2 +- .../grasscutter/plugin/api/ServerHelper.java | 10 +- .../scripts/SceneScriptManager.java | 28 +- .../emu/grasscutter/scripts/ScriptLoader.java | 3 +- .../grasscutter/scripts/data/SceneBlock.java | 7 +- .../grasscutter/scripts/data/SceneGadget.java | 4 +- .../grasscutter/scripts/data/SceneGroup.java | 13 +- .../grasscutter/scripts/data/ScriptArgs.java | 9 +- .../server/event/EventHandler.java | 7 +- .../event/dispatch/QueryAllRegionsEvent.java | 1 - .../dispatch/QueryCurrentRegionEvent.java | 1 - .../server/event/entity/EntityMoveEvent.java | 1 - .../event/game/PlayerCreationEvent.java | 4 +- .../game/ReceiveCommandFeedbackEvent.java | 7 +- .../server/event/game/ReceivePacketEvent.java | 4 +- .../server/event/game/SendPacketEvent.java | 4 +- .../server/event/internal/ServerLogEvent.java | 1 - .../event/internal/ServerStartEvent.java | 4 +- .../event/internal/ServerStopEvent.java | 4 +- .../event/player/PlayerOpenChestEvent.java | 4 +- .../event/player/PlayerReceiveMailEvent.java | 1 - .../server/event/types/EntityEvent.java | 1 - .../server/event/types/PlayerEvent.java | 1 - .../server/game/BaseGameSystem.java | 1 - .../server/game/GameServerPacketHandler.java | 14 +- .../grasscutter/server/game/GameSession.java | 5 +- .../server/game/GameSessionManager.java | 1 + .../server/http/dispatch/RegionHandler.java | 2 - .../server/http/objects/HttpJsonResponse.java | 13 +- .../packet/recv/HandlerBuyGoodsReq.java | 3 +- .../recv/HandlerCombatInvocationsNotify.java | 15 +- .../packet/recv/HandlerHomeKickPlayerReq.java | 11 +- .../recv/HandlerSetPlayerBirthdayReq.java | 1 - .../packet/recv/HandlerTryEnterHomeReq.java | 20 +- .../PacketActivityScheduleInfoNotify.java | 17 +- .../PacketBattlePassMissionUpdateNotify.java | 3 +- .../send/PacketCodexDataFullNotify.java | 7 +- .../packet/send/PacketCreateVehicleRsp.java | 33 +- .../packet/send/PacketMailChangeNotify.java | 10 +- .../packet/send/PacketPlayerDataNotify.java | 5 +- .../packet/send/PacketVehicleInteractRsp.java | 4 +- .../server/scheduler/AsyncServerTask.java | 6 +- .../java/emu/grasscutter/task/TaskMap.java | 6 +- .../java/emu/grasscutter/tools/Dumpers.java | 2 +- .../java/emu/grasscutter/tools/Tools.java | 25 +- .../java/emu/grasscutter/utils/FileUtils.java | 6 +- .../emu/grasscutter/utils/JsonAdapters.java | 26 +- .../java/emu/grasscutter/utils/TsvUtils.java | 44 +- .../java/emu/grasscutter/utils/Utils.java | 2 +- .../utils/algorithms/KahnsSort.java | 3 +- .../emu/grasscutter/utils/lang/Language.java | 52 +- .../utils/objects/ServerLogEventAppender.java | 4 +- 189 files changed, 1138 insertions(+), 1185 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index 1947cab8e..ffa66fa7b 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -230,7 +230,11 @@ public final class CommandMap { if (SERVER.logCommands) { if (player != null) { Grasscutter.getLogger() - .info("Command used by [{} (Player UID: {})]: {}", player.getAccount().getUsername(), player.getUid(), rawMessage); + .info( + "Command used by [{} (Player UID: {})]: {}", + player.getAccount().getUsername(), + player.getUid(), + rawMessage); } else { Grasscutter.getLogger().info("Command used by server console: {}", rawMessage); } @@ -344,10 +348,13 @@ public final class CommandMap { this.registerCommand(cmdData.label(), (CommandHandler) object); else Grasscutter.getLogger() - .error("Class {} is not a CommandHandler!", annotated.getName()); + .error("Class {} is not a CommandHandler!", annotated.getName()); } catch (Exception exception) { Grasscutter.getLogger() - .error("Failed to register command handler for {}", annotated.getSimpleName(), exception); + .error( + "Failed to register command handler for {}", + annotated.getSimpleName(), + exception); } }); } diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index c78425c90..90b202982 100644 --- a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java @@ -136,18 +136,19 @@ public final class AchievementCommand implements CommandHandler { parseInt(args.remove(0)) .ifPresentOrElse( - integer -> parseInt(args.remove(0)) - .ifPresentOrElse( - progress -> { - var ret = achievements.progress(integer, progress); - switch (ret.getRet()) { - case SUCCESS -> sendSuccessMessage( - sender, "progress", targetPlayer.getNickname(), integer, progress); - case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( - sender, ret.getRet().getKey()); - } - }, - () -> this.sendUsageMessage(sender)), + integer -> + parseInt(args.remove(0)) + .ifPresentOrElse( + progress -> { + var ret = achievements.progress(integer, progress); + switch (ret.getRet()) { + case SUCCESS -> sendSuccessMessage( + sender, "progress", targetPlayer.getNickname(), integer, progress); + case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( + sender, ret.getRet().getKey()); + } + }, + () -> this.sendUsageMessage(sender)), () -> this.sendUsageMessage(sender)); } } diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index b196e09a2..67c06a4b3 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java @@ -1,5 +1,8 @@ package emu.grasscutter.command.commands; +import static emu.grasscutter.GameConstants.*; +import static emu.grasscutter.command.CommandHelpers.*; + import emu.grasscutter.command.Command; import emu.grasscutter.command.CommandHandler; import emu.grasscutter.data.GameData; @@ -14,30 +17,50 @@ import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.FightProperty; -import lombok.Setter; - import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import java.util.regex.Pattern; +import lombok.Setter; -import static emu.grasscutter.GameConstants.*; -import static emu.grasscutter.command.CommandHelpers.*; - -@Command(label = "give", aliases = {"g", "item", "giveitem"}, usage = {"(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", " [lv] [x] [] [[,]]..."}, permission = "player.give", permissionTargeted = "player.give.others", threading = true) +@Command( + label = "give", + aliases = {"g", "item", "giveitem"}, + usage = { + "(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", + " [lv] [x] [] [[,]]..." + }, + permission = "player.give", + permissionTargeted = "player.give.others", + threading = true) public final class GiveCommand implements CommandHandler { - private static final Map> intCommandHandlers = Map.ofEntries(Map.entry(lvlRegex, GiveItemParameters::setLvl), Map.entry(refineRegex, GiveItemParameters::setRefinement), Map.entry(amountRegex, GiveItemParameters::setAmount), Map.entry(constellationRegex, GiveItemParameters::setConstellation), Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); + private static final Map> intCommandHandlers = + Map.ofEntries( + Map.entry(lvlRegex, GiveItemParameters::setLvl), + Map.entry(refineRegex, GiveItemParameters::setRefinement), + Map.entry(amountRegex, GiveItemParameters::setAmount), + Map.entry(constellationRegex, GiveItemParameters::setConstellation), + Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); private static Avatar makeAvatar(GiveItemParameters param) { - return makeAvatar(param.avatarData, param.lvl, Avatar.getMinPromoteLevel(param.lvl), param.constellation, param.skillLevel); + return makeAvatar( + param.avatarData, + param.lvl, + Avatar.getMinPromoteLevel(param.lvl), + param.constellation, + param.skillLevel); } - private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { + private static Avatar makeAvatar( + AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { Avatar avatar = new Avatar(avatarData); avatar.setLevel(level); avatar.setPromoteLevel(promoteLevel); - avatar.getSkillDepot().getSkillsAndEnergySkill().forEach(id -> avatar.setSkillLevel(id, skillLevel)); + avatar + .getSkillDepot() + .getSkillsAndEnergySkill() + .forEach(id -> avatar.setSkillLevel(id, skillLevel)); avatar.forceConstellationLevel(constellation); avatar.recalcStats(true); avatar.save(); @@ -47,13 +70,16 @@ public final class GiveCommand implements CommandHandler { private static void giveAllAvatars(Player player, GiveItemParameters param) { int promoteLevel = Avatar.getMinPromoteLevel(param.lvl); if (param.constellation < 0 || param.constellation > 6) - param.constellation = 6; // constellation's default is -1 so if no parameters set for constellations it'll + param.constellation = + 6; // constellation's default is -1 so if no parameters set for constellations it'll // automatically be 6 for (AvatarData avatarData : GameData.getAvatarDataMap().values()) { int id = avatarData.getId(); if (id < 10000002 || id >= 11000000) continue; // Exclude test avatars // Don't try to add each avatar to the current team - player.addAvatar(makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), false); + player.addAvatar( + makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), + false); } } @@ -93,7 +119,7 @@ public final class GiveCommand implements CommandHandler { item.setTotalExp(totalExp); int numAffixes = param.data.getAppendPropNum() + (param.lvl - 1) / 4; if (param.mainPropId > 0) // Keep random mainProp if we didn't specify one - item.setMainPropId(param.mainPropId); + item.setMainPropId(param.mainPropId); if (param.appendPropIdList != null) { item.getAppendPropIdList().clear(); item.getAppendPropIdList().addAll(param.appendPropIdList); @@ -105,14 +131,17 @@ public final class GiveCommand implements CommandHandler { return items; } - private static int getArtifactMainProp(ItemData itemData, FightProperty prop) throws IllegalArgumentException { + private static int getArtifactMainProp(ItemData itemData, FightProperty prop) + throws IllegalArgumentException { if (prop != FightProperty.FIGHT_PROP_NONE) - for (ReliquaryMainPropData data : GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) + for (ReliquaryMainPropData data : + GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) if (data.getWeight() > 0 && data.getFightProp() == prop) return data.getId(); throw new IllegalArgumentException(); } - private static List getArtifactAffixes(ItemData itemData, FightProperty prop) throws IllegalArgumentException { + private static List getArtifactAffixes(ItemData itemData, FightProperty prop) + throws IllegalArgumentException { if (prop == FightProperty.FIGHT_PROP_NONE) { throw new IllegalArgumentException(); } @@ -125,7 +154,8 @@ public final class GiveCommand implements CommandHandler { return affixes; } - private static int getAppendPropId(String substatText, ItemData itemData) throws IllegalArgumentException { + private static int getAppendPropId(String substatText, ItemData itemData) + throws IllegalArgumentException { // If the given substat text is an integer, we just use that as the append prop ID. try { return Integer.parseInt(substatText); @@ -142,7 +172,8 @@ public final class GiveCommand implements CommandHandler { substatTier = Integer.parseInt(substatArgs[1]); } - List substats = getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); + List substats = + getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); if (substats.isEmpty()) { throw new IllegalArgumentException(); @@ -154,7 +185,8 @@ public final class GiveCommand implements CommandHandler { } } - private static void parseRelicArgs(GiveItemParameters param, List args) throws IllegalArgumentException { + private static void parseRelicArgs(GiveItemParameters param, List args) + throws IllegalArgumentException { // Get the main stat from the arguments. // If the given argument is an integer, we use that. // If not, we check if the argument string is in the main prop map. @@ -164,7 +196,8 @@ public final class GiveCommand implements CommandHandler { param.mainPropId = Integer.parseInt(mainPropIdString); } catch (NumberFormatException ignored) { // This can in turn throw an exception which we don't want to catch here. - param.mainPropId = getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); + param.mainPropId = + getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); } // Get substats. @@ -245,7 +278,8 @@ public final class GiveCommand implements CommandHandler { giveAllWeapons(player, param); } - private GiveItemParameters parseArgs(Player sender, List args) throws IllegalArgumentException { + private GiveItemParameters parseArgs(Player sender, List args) + throws IllegalArgumentException { GiveItemParameters param = new GiveItemParameters(); // Extract any tagged arguments (e.g. "lv90", "x100", "r5") @@ -287,7 +321,9 @@ public final class GiveCommand implements CommandHandler { param.avatarData = GameData.getAvatarDataMap().get(param.id - 1000 + 10_000_000); isRelic = ((param.data != null) && (param.data.getItemType() == ItemType.ITEM_RELIQUARY)); - if (!isRelic && !args.isEmpty() && (param.amount == 1)) { // A concession for the people that truly hate [x]. + if (!isRelic + && !args.isEmpty() + && (param.amount == 1)) { // A concession for the people that truly hate [x]. try { param.amount = Integer.parseInt(args.remove(0)); } catch (NumberFormatException e) { @@ -365,7 +401,8 @@ public final class GiveCommand implements CommandHandler { if (param.avatarData != null) { Avatar avatar = makeAvatar(param); targetPlayer.addAvatar(avatar); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage( + sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); return; } // If it's not an avatar, it needs to be a valid item @@ -376,37 +413,54 @@ public final class GiveCommand implements CommandHandler { switch (param.data.getItemType()) { case ITEM_WEAPON: - targetPlayer.getInventory().addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_with_level_and_refinement", param.id, param.lvl, param.refinement, param.amount, targetPlayer.getUid()); + targetPlayer + .getInventory() + .addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage( + sender, + "commands.give.given_with_level_and_refinement", + param.id, + param.lvl, + param.refinement, + param.amount, + targetPlayer.getUid()); return; case ITEM_RELIQUARY: targetPlayer.getInventory().addItems(makeArtifacts(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_level", param.id, param.lvl, param.amount, targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage( + sender, + "commands.give.given_level", + param.id, + param.lvl, + param.amount, + targetPlayer.getUid()); return; default: - targetPlayer.getInventory().addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); + targetPlayer + .getInventory() + .addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage( + sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); } } catch (IllegalArgumentException ignored) { } } private enum GiveAllType { - NONE, ALL, WEAPONS, MATS, AVATARS + NONE, + ALL, + WEAPONS, + MATS, + AVATARS } private static class GiveItemParameters { public int id; - @Setter - public int lvl = 0; - @Setter - public int amount = 1; - @Setter - public int refinement = 1; - @Setter - public int constellation = -1; - @Setter - public int skillLevel = 1; + @Setter public int lvl = 0; + @Setter public int amount = 1; + @Setter public int refinement = 1; + @Setter public int constellation = -1; + @Setter public int skillLevel = 1; public int mainPropId = -1; public List appendPropIdList; public ItemData data; diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index 4c0f60907..5f21dae4a 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -24,8 +24,7 @@ public final class SendMailCommand implements CommandHandler { // the command system (again). For now this will do // Key = User that is constructing the mail. - private static final HashMap mailBeingConstructed = - new HashMap<>(); + private static final HashMap mailBeingConstructed = new HashMap<>(); // Yes this is awful and I hate it. @Override diff --git a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java index d16c97213..70e7fc6c2 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java @@ -95,7 +95,8 @@ public final class SetSceneTagCommand implements CommandHandler { // Only remove for big world as some other scenes only have defaults .filter(sceneTag -> sceneTag.getSceneId() == 3) .forEach( - sceneTag -> targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); + sceneTag -> + targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); this.setSceneTags(targetPlayer); } diff --git a/src/main/java/emu/grasscutter/data/DataLoader.java b/src/main/java/emu/grasscutter/data/DataLoader.java index 0d19c11f0..8a91fac9d 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -4,8 +4,6 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.JsonUtils; import emu.grasscutter.utils.TsvUtils; -import lombok.val; - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -14,6 +12,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Map; +import lombok.val; public class DataLoader { @@ -36,7 +35,7 @@ public class DataLoader { * * @param resourcePath The path to the data file to be loaded. * @return InputStreamReader of the data file. - * @throws IOException If the file is not found. + * @throws IOException If the file is not found. * @throws FileNotFoundException If the file is not found. * @see #load(String, boolean) */ @@ -50,19 +49,22 @@ public class DataLoader { * Load a data file by its name. * * @param resourcePath The path to the data file to be loaded. - * @param useFallback If the file does not exist in the /data directory, should it use the default - * file in the jar? + * @param useFallback If the file does not exist in the /data directory, should it use the default + * file in the jar? * @return InputStream of the data file. * @throws FileNotFoundException If the file is not found. */ - public static InputStream load(String resourcePath, boolean useFallback) throws FileNotFoundException { - Path path = useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); + public static InputStream load(String resourcePath, boolean useFallback) + throws FileNotFoundException { + Path path = + useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); if (Files.exists(path)) { // Data is in the resource directory try { return Files.newInputStream(path); } catch (IOException e) { - throw new FileNotFoundException(e.getMessage()); // This is evil but so is changing the function signature at this point + throw new FileNotFoundException( + e.getMessage()); // This is evil but so is changing the function signature at this point } } return null; @@ -80,13 +82,15 @@ public class DataLoader { } } - public static Map loadMap(String resourcePath, Class keyType, Class valueType) throws IOException { + public static Map loadMap( + String resourcePath, Class keyType, Class valueType) throws IOException { try (InputStreamReader reader = loadReader(resourcePath)) { return JsonUtils.loadToMap(reader, keyType, valueType); } } - public static List loadTableToList(String resourcePath, Class classType) throws IOException { + public static List loadTableToList(String resourcePath, Class classType) + throws IOException { val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); Grasscutter.getLogger().trace("Loading data table from: {}", path); return switch (FileUtils.getFileExtension(path)) { diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index be1d2a25e..96735f346 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -630,15 +630,21 @@ public final class GameData { // Non-nullable value getters public static int getAvatarLevelExpRequired(int level) { - return Optional.ofNullable(avatarLevelDataMap.get(level)).map(AvatarLevelData::getExp).orElse(0); + return Optional.ofNullable(avatarLevelDataMap.get(level)) + .map(AvatarLevelData::getExp) + .orElse(0); } public static int getAvatarFetterLevelExpRequired(int level) { - return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(AvatarFetterLevelData::getExp).orElse(0); + return Optional.ofNullable(avatarFetterLevelDataMap.get(level)) + .map(AvatarFetterLevelData::getExp) + .orElse(0); } public static int getRelicExpRequired(int rankLevel, int level) { - return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(ReliquaryLevelData::getExp).orElse(0); + return Optional.ofNullable(getRelicLevelData(rankLevel, level)) + .map(ReliquaryLevelData::getExp) + .orElse(0); } // Generic getter @@ -655,7 +661,7 @@ public final class GameData { field.setAccessible(false); } catch (Exception e) { Grasscutter.getLogger() - .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); + .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); } return map; diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index d7e7df051..3d14cc4d2 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,27 +140,28 @@ public final class ResourceLoader { getResourceDefClassesPrioritySets() .forEach( - classes -> classes.stream() - .parallel() - .unordered() - .forEach( - c -> { - val type = c.getAnnotation(ResourceType.class); - if (type == null) return; + classes -> + classes.stream() + .parallel() + .unordered() + .forEach( + c -> { + val type = c.getAnnotation(ResourceType.class); + if (type == null) return; - val map = GameData.getMapByResourceDef(c); - if (map == null) return; + val map = GameData.getMapByResourceDef(c); + if (map == null) return; - try { - loadFromResource(c, type, map, doReload); - } catch (Exception e) { - errors.add(Pair.of(Arrays.toString(type.name()), e)); - } - })); + try { + loadFromResource(c, type, map, doReload); + } catch (Exception e) { + errors.add(Pair.of(Arrays.toString(type.name()), e)); + } + })); errors.forEach( pair -> - Grasscutter.getLogger() - .error("Error loading resource file: {}", pair.left(), pair.right())); + Grasscutter.getLogger() + .error("Error loading resource file: {}", pair.left(), pair.right())); long endTime = System.nanoTime(); long ns = (endTime - startTime); // divide by 1000000 to get milliseconds. Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000); @@ -168,7 +169,7 @@ public final class ResourceLoader { @SuppressWarnings("rawtypes") private static void loadFromResource( - Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { + Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { val simpleName = c.getSimpleName(); if (doReload || !loadedResources.contains(simpleName)) { for (String name : type.name()) { @@ -281,7 +282,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); + .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneRouteData folder."); } @@ -402,7 +403,7 @@ public final class ResourceLoader { .forEach(data -> loadAbilityData(data.Default)); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path {}: ", path.toString(), e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -464,7 +465,7 @@ public final class ResourceLoader { path, String.class, new TypeToken>() {}.getType())); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path {}: ", path.toString(), e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -531,7 +532,7 @@ public final class ResourceLoader { }); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading open config: no files found in {}", folderName); + .error("Error loading open config: no files found in {}", folderName); return; } } @@ -587,7 +588,7 @@ public final class ResourceLoader { } Grasscutter.getLogger() - .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); + .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); } public static void loadScriptSceneData() { @@ -605,7 +606,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); + .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); } catch (IOException e) { Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty."); } @@ -629,7 +630,9 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} HomeworldDefaultSaveDatas.", GameData.getHomeworldDefaultSaveData().size()); + .debug( + "Loaded {} HomeworldDefaultSaveDatas.", + GameData.getHomeworldDefaultSaveData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder."); } @@ -654,7 +657,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); + .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder."); } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java index a7b1ee98a..c191368e7 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java @@ -13,5 +13,4 @@ public class AbilityEmbryoEntry { this.name = avatarName; this.abilities = array; } - } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java index 9fa16b9ca..72030788b 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java @@ -3,14 +3,12 @@ package emu.grasscutter.data.binout; import com.google.gson.*; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; - import java.io.Serial; import java.io.Serializable; import java.util.*; public class AbilityMixinData implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public enum Type { AttachToGadgetStateMixin, diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 099bb49ce..937944812 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -3,14 +3,12 @@ package emu.grasscutter.data.binout; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.game.props.ElementType; - import java.io.Serial; import java.io.Serializable; import lombok.ToString; public class AbilityModifier implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public State state; diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java index 8787b5304..c829c0936 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java @@ -1,18 +1,14 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class AbilityModifierEntry { public final List onModifierAdded; - @Getter - public final List onThinkInterval; - @Getter - public final List onRemoved; - @Getter - private final String name; // Custom value + @Getter public final List onThinkInterval; + @Getter public final List onRemoved; + @Getter private final String name; // Custom value public AbilityModifierEntry(String name) { this.name = name; @@ -24,5 +20,4 @@ public class AbilityModifierEntry { public List getOnAdded() { return onModifierAdded; } - } diff --git a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java index 72e427294..6ec95006c 100644 --- a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java +++ b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java @@ -8,25 +8,17 @@ import lombok.Data; import lombok.Getter; public class MainQuestData { - @Getter - private int id; + @Getter private int id; private int ICLLDPJFIMA; - @Getter - private int series; - @Getter - private QuestType type; + @Getter private int series; + @Getter private QuestType type; - @Getter - private long titleTextMapHash; - @Getter - private int[] suggestTrackMainQuestList; - @Getter - private int[] rewardIdList; + @Getter private long titleTextMapHash; + @Getter private int[] suggestTrackMainQuestList; + @Getter private int[] rewardIdList; - @Getter - private SubQuestData[] subQuests; - @Getter - private List talks; + @Getter private SubQuestData[] subQuests; + @Getter private List talks; private long[] preloadLuaList; public void onLoad() { diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index 21a301207..54735a129 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -1,9 +1,8 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.ResourceLoader.OpenConfigData; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class OpenConfigEntry { @@ -46,6 +45,5 @@ public class OpenConfigEntry { this.skillId = skillId; this.delta = delta; } - } } diff --git a/src/main/java/emu/grasscutter/data/common/CurveInfo.java b/src/main/java/emu/grasscutter/data/common/CurveInfo.java index ffb6ae2be..bcc6fd8f5 100644 --- a/src/main/java/emu/grasscutter/data/common/CurveInfo.java +++ b/src/main/java/emu/grasscutter/data/common/CurveInfo.java @@ -7,5 +7,4 @@ public class CurveInfo { private String type; private String arith; private float value; - } diff --git a/src/main/java/emu/grasscutter/data/common/ItemUseData.java b/src/main/java/emu/grasscutter/data/common/ItemUseData.java index bd09ca4d8..92341b325 100644 --- a/src/main/java/emu/grasscutter/data/common/ItemUseData.java +++ b/src/main/java/emu/grasscutter/data/common/ItemUseData.java @@ -5,8 +5,7 @@ import lombok.Getter; public class ItemUseData { private ItemUseOp useOp; - @Getter - private String[] useParam; + @Getter private String[] useParam; public ItemUseOp getUseOp() { if (useOp == null) { @@ -14,5 +13,4 @@ public class ItemUseData { } return useOp; } - } diff --git a/src/main/java/emu/grasscutter/data/common/OpenCondData.java b/src/main/java/emu/grasscutter/data/common/OpenCondData.java index 8627c681f..e3658a75e 100644 --- a/src/main/java/emu/grasscutter/data/common/OpenCondData.java +++ b/src/main/java/emu/grasscutter/data/common/OpenCondData.java @@ -1,8 +1,7 @@ package emu.grasscutter.data.common; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class OpenCondData { diff --git a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java index 8c60834b2..a0e6c1bbe 100644 --- a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java +++ b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java @@ -6,5 +6,4 @@ import lombok.Getter; public class PropGrowCurve { private String type; private String growCurve; - } diff --git a/src/main/java/emu/grasscutter/data/excels/CombineData.java b/src/main/java/emu/grasscutter/data/excels/CombineData.java index d15de8ff2..430eaefda 100644 --- a/src/main/java/emu/grasscutter/data/excels/CombineData.java +++ b/src/main/java/emu/grasscutter/data/excels/CombineData.java @@ -2,35 +2,24 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; @ResourceType(name = "CombineExcelConfigData.json") public class CombineData extends GameResource { - @Getter - private int combineId; - @Getter - private int playerLevel; + @Getter private int combineId; + @Getter private int playerLevel; private boolean isDefaultShow; - @Getter - private int combineType; - @Getter - private int subCombineType; - @Getter - private int resultItemId; - @Getter - private int resultItemCount; - @Getter - private int scoinCost; - @Getter - private List randomItems; - @Getter - private List materialItems; - @Getter - private String recipeType; + @Getter private int combineType; + @Getter private int subCombineType; + @Getter private int resultItemId; + @Getter private int resultItemCount; + @Getter private int scoinCost; + @Getter private List randomItems; + @Getter private List materialItems; + @Getter private String recipeType; @Override public int getId() { @@ -50,5 +39,4 @@ public class CombineData extends GameResource { public boolean isDefaultShow() { return isDefaultShow; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java index 9612eb3ed..8c51cfde2 100644 --- a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java @@ -2,18 +2,15 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType( name = "EnvAnimalGatherExcelConfigData.json", loadPriority = ResourceType.LoadPriority.LOW) public class EnvAnimalGatherConfigData extends GameResource { - @Getter - private int animalId; - @Getter - private String entityType; + @Getter private int animalId; + @Getter private String entityType; private List gatherItemId; private String excludeWeathers; private int aliveTime; diff --git a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java index 194ef810f..d566c422d 100644 --- a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java +++ b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java @@ -2,25 +2,19 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.FightPropData; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "EquipAffixExcelConfigData.json") public class EquipAffixData extends GameResource { private int affixId; private int id; - @Getter - private int level; - @Getter - private long nameTextMapHash; - @Getter - private String openConfig; - @Getter - private FightPropData[] addProps; - @Getter - private float[] paramList; + @Getter private int level; + @Getter private long nameTextMapHash; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java index 7097e7c7c..7b4dce107 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java @@ -7,8 +7,7 @@ import lombok.Getter; @ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class FetterCharacterCardData extends GameResource { private int avatarId; - @Getter - private int rewardId; + @Getter private int rewardId; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/FetterData.java b/src/main/java/emu/grasscutter/data/excels/FetterData.java index 94c42c217..24401a900 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterData.java @@ -3,9 +3,8 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.OpenCondData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType( name = { @@ -17,8 +16,7 @@ import java.util.List; }, loadPriority = LoadPriority.HIGHEST) public class FetterData extends GameResource { - @Getter - private int avatarId; + @Getter private int avatarId; private int fetterId; private List openCond; diff --git a/src/main/java/emu/grasscutter/data/excels/GatherData.java b/src/main/java/emu/grasscutter/data/excels/GatherData.java index 716974af9..2eca6b64c 100644 --- a/src/main/java/emu/grasscutter/data/excels/GatherData.java +++ b/src/main/java/emu/grasscutter/data/excels/GatherData.java @@ -7,12 +7,9 @@ import lombok.Getter; public class GatherData extends GameResource { private int pointType; private int id; - @Getter - private int gadgetId; - @Getter - private int itemId; - @Getter - private int cd; // Probably hours + @Getter private int gadgetId; + @Getter private int itemId; + @Getter private int cd; // Probably hours private boolean isForbidGuest; private boolean initDisableInteract; diff --git a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java index fb17b3594..671e712a8 100644 --- a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java +++ b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java @@ -25,7 +25,8 @@ public class ProudSkillData extends GameResource { @Getter private long nameTextMapHash; @Transient private Iterable totalCostItems; - @Transient @Getter private final Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); + @Transient @Getter + private final Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/RewardData.java b/src/main/java/emu/grasscutter/data/excels/RewardData.java index ecf799e05..6a076a49a 100644 --- a/src/main/java/emu/grasscutter/data/excels/RewardData.java +++ b/src/main/java/emu/grasscutter/data/excels/RewardData.java @@ -2,15 +2,13 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType(name = "RewardExcelConfigData.json") public class RewardData extends GameResource { public int rewardId; - @Getter - public List rewardItemList; + @Getter public List rewardItemList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java index 697ea74a3..4a95ea2ca 100644 --- a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java +++ b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java @@ -4,38 +4,26 @@ import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.game.shop.ShopInfo; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType(name = "ShopGoodsExcelConfigData.json") public class ShopGoodsData extends GameResource { - @Getter - private int goodsId; - @Getter - private int shopType; - @Getter - private int itemId; + @Getter private int goodsId; + @Getter private int shopType; + @Getter private int itemId; - @Getter - private int itemCount; + @Getter private int itemCount; - @Getter - private int costScoin; - @Getter - private int costHcoin; - @Getter - private int costMcoin; + @Getter private int costScoin; + @Getter private int costHcoin; + @Getter private int costMcoin; - @Getter - private List costItems; - @Getter - private int minPlayerLevel; - @Getter - private int maxPlayerLevel; + @Getter private List costItems; + @Getter private int minPlayerLevel; + @Getter private int maxPlayerLevel; - @Getter - private int buyLimit; + @Getter private int buyLimit; @Getter @SerializedName( @@ -46,8 +34,7 @@ public class ShopGoodsData extends GameResource { private String refreshType; private transient ShopInfo.ShopRefreshType refreshTypeEnum; - @Getter - private int refreshParam; + @Getter private int refreshParam; @Override public void onLoad() { @@ -71,5 +58,4 @@ public class ShopGoodsData extends GameResource { public ShopInfo.ShopRefreshType getRefreshType() { return refreshTypeEnum; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java index 47b4db756..dc611d29c 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java @@ -9,12 +9,9 @@ public class AvatarCostumeData extends GameResource { @SerializedName(value = "skinId", alternate = "costumeId") private int skinId; - @Getter - private int itemId; - @Getter - private int characterId; - @Getter - private int quality; + @Getter private int itemId; + @Getter private int characterId; + @Getter private int quality; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java index 5b201156f..9ede54999 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java @@ -2,15 +2,13 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.CurveInfo; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @ResourceType(name = "AvatarCurveExcelConfigData.json") public class AvatarCurveData extends GameResource { - @Getter - private int level; + @Getter private int level; private CurveInfo[] curveInfos; private Map curveInfoMap; diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java index 8799c1ba6..105e55d29 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java @@ -6,8 +6,7 @@ import lombok.Getter; @ResourceType(name = "AvatarFlycloakExcelConfigData.json") public class AvatarFlycloakData extends GameResource { private int flycloakId; - @Getter - private long nameTextMapHash; + @Getter private long nameTextMapHash; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java index a2d30b13d..a26fe6c3a 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java @@ -13,5 +13,4 @@ public class AvatarLevelData extends GameResource { public int getId() { return this.level; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java index b871929fc..acf0d826c 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java @@ -2,26 +2,19 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "AvatarPromoteExcelConfigData.json") public class AvatarPromoteData extends GameResource { - @Getter - private int avatarPromoteId; - @Getter - private int promoteLevel; + @Getter private int avatarPromoteId; + @Getter private int promoteLevel; private int scoinCost; - @Getter - private ItemParamData[] costItems; - @Getter - private int unlockMaxLevel; - @Getter - private FightPropData[] addProps; - @Getter - private int requiredPlayerLevel; + @Getter private ItemParamData[] costItems; + @Getter private int unlockMaxLevel; + @Getter private FightPropData[] addProps; + @Getter private int requiredPlayerLevel; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java index 291f75877..d317edf43 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java @@ -3,28 +3,20 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.FightPropData; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class AvatarTalentData extends GameResource { private int talentId; private int prevTalent; - @Getter - private long nameTextMapHash; - @Getter - private String icon; - @Getter - private int mainCostItemId; - @Getter - private int mainCostItemCount; - @Getter - private String openConfig; - @Getter - private FightPropData[] addProps; - @Getter - private float[] paramList; + @Getter private long nameTextMapHash; + @Getter private String icon; + @Getter private int mainCostItemId; + @Getter private int mainCostItemCount; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java index 547d89f8b..4969e350a 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java @@ -5,14 +5,10 @@ import lombok.Getter; @ResourceType(name = {"QuestCodexExcelConfigData.json"}) public class CodexQuestData extends GameResource { - @Getter - private int Id; - @Getter - private int parentQuestId; - @Getter - private int chapterId; - @Getter - private int sortOrder; + @Getter private int Id; + @Getter private int parentQuestId; + @Getter private int chapterId; + @Getter private int sortOrder; private boolean isDisuse; public boolean getIsDisuse() { diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java index a7124bda1..30e7e4a62 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java @@ -5,13 +5,10 @@ import lombok.Getter; @ResourceType(name = {"WeaponCodexExcelConfigData.json"}) public class CodexWeaponData extends GameResource { - @Getter - private int Id; - @Getter - private int weaponId; + @Getter private int Id; + @Getter private int weaponId; private int gadgetId; - @Getter - private int sortOrder; + @Getter private int sortOrder; public int getGadgetId() { return weaponId; diff --git a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java index fd9722f1f..cdd5aab13 100644 --- a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java @@ -9,8 +9,7 @@ import lombok.Getter; @Getter @ResourceType(name = "DungeonChallengeConfigData.json") public class DungeonChallengeConfigData extends GameResource { - @Getter - private int id; + @Getter private int id; private ChallengeType challengeType; private boolean noSuccessHint; private boolean noFailHint; @@ -43,7 +42,7 @@ public class DungeonChallengeConfigData extends GameResource { alternate = {"NJBJIKAIENN"}) private AllowAnimationType animationOnSubFail; - public enum InterruptButtonType { + public enum InterruptButtonType { INTERRUPT_BUTTON_TYPE_NONE, INTERRUPT_BUTTON_TYPE_HOST, INTERRUPT_BUTTON_TYPE_ALL diff --git a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java index 153c0777e..05eb34e1e 100644 --- a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java +++ b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java @@ -7,8 +7,7 @@ import lombok.Getter; @ResourceType(name = "ReliquarySetExcelConfigData.json") public class ReliquarySetData extends GameResource { private int setId; - @Getter - private int[] setNeedNum; + @Getter private int[] setNeedNum; @Getter @SerializedName( diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java index 321d04e62..77712523d 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java @@ -1,9 +1,8 @@ package emu.grasscutter.data.excels.tower; import emu.grasscutter.data.*; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @ResourceType(name = "TowerScheduleExcelConfigData.json") @@ -28,6 +27,5 @@ public class TowerScheduleData extends GameResource { @Getter public static class ScheduleDetail { private List floorList; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java index 3d326ea6b..a89b36287 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java @@ -13,5 +13,4 @@ public class WeaponLevelData extends GameResource { public int getId() { return this.level; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java index 228716f8f..84751156a 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java @@ -2,9 +2,8 @@ package emu.grasscutter.data.excels.weapon; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @Getter @ResourceType(name = "WeaponPromoteExcelConfigData.json") diff --git a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java index 00cc9b87a..0ffc01556 100644 --- a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java @@ -6,8 +6,7 @@ import lombok.Getter; @ResourceType(name = "WorldLevelExcelConfigData.json") public class WorldLevelData extends GameResource { private int level; - @Getter - private int monsterLevel; + @Getter private int monsterLevel; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/server/Grid.java b/src/main/java/emu/grasscutter/data/server/Grid.java index c42431c30..126e24768 100644 --- a/src/main/java/emu/grasscutter/data/server/Grid.java +++ b/src/main/java/emu/grasscutter/data/server/Grid.java @@ -5,9 +5,8 @@ import com.github.davidmoten.rtreemulti.geometry.Geometry; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.SceneIndexManager; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class Grid { public transient RTree>, Geometry> gridOptimized = null; @@ -18,8 +17,7 @@ public class Grid { * * @return The correctly loaded grid map. */ - @Getter - public Map> grid = new LinkedHashMap<>(); + @Getter public Map> grid = new LinkedHashMap<>(); /** Creates an optimized cache of the grid. */ private void optimize() { diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index d1b149adc..4847a19cb 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -550,7 +550,7 @@ public final class DatabaseHelper { .first(); } catch (IllegalArgumentException e) { Grasscutter.getLogger() - .debug("Error occurred while getting uid {}'s achievement data", uid, e); + .debug("Error occurred while getting uid {}'s achievement data", uid, e); DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid)); return null; } diff --git a/src/main/java/emu/grasscutter/database/DatabaseManager.java b/src/main/java/emu/grasscutter/database/DatabaseManager.java index 52fc274f7..0330d64a3 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -14,8 +14,7 @@ import emu.grasscutter.game.Account; import lombok.Getter; public final class DatabaseManager { - @Getter - private static Datastore gameDatastore; + @Getter private static Datastore gameDatastore; private static Datastore dispatchDatastore; public static Datastore getAccountDatastore() { diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index 35f54dafd..4c66ebedf 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -7,16 +7,13 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.utils.*; import java.util.*; import java.util.stream.Stream; - import lombok.Getter; import lombok.Setter; import org.bson.Document; @Entity(value = "accounts", useDiscriminator = false) public class Account { - @Setter - @Getter - @Id private String id; + @Setter @Getter @Id private String id; @Setter @Getter @@ -24,38 +21,21 @@ public class Account { @Collation(locale = "simple", caseLevel = true) private String username; - @Setter - @Getter - private String password; // Unused for now + @Setter @Getter private String password; // Unused for now private int reservedPlayerId; - @Setter - private String email; + @Setter private String email; - @Setter - @Getter - private String token; - @Getter - private String sessionKey; // Session token for dispatch server - /** - * -- GETTER -- - * The collection of a player's permissions. - */ - @Getter - private final List permissions; - @Setter - @Getter - private Locale locale; + @Setter @Getter private String token; + @Getter private String sessionKey; // Session token for dispatch server + /** -- GETTER -- The collection of a player's permissions. */ + @Getter private final List permissions; - @Setter - @Getter - private String banReason; - @Setter - @Getter - private int banEndTime; - @Setter - @Getter - private int banStartTime; + @Setter @Getter private Locale locale; + + @Setter @Getter private String banReason; + @Setter @Getter private int banEndTime; + @Setter @Getter private int banStartTime; private boolean isBanned; @Deprecated diff --git a/src/main/java/emu/grasscutter/game/ability/Ability.java b/src/main/java/emu/grasscutter/game/ability/Ability.java index 76263f87c..92ee5c080 100644 --- a/src/main/java/emu/grasscutter/game/ability/Ability.java +++ b/src/main/java/emu/grasscutter/game/ability/Ability.java @@ -22,7 +22,8 @@ public class Ability { @Getter private final Object2FloatMap abilitySpecials = new Object2FloatOpenHashMap<>(); @Getter - private static final Map> abilitySpecialsModified = new HashMap<>(); + private static final Map> abilitySpecialsModified = + new HashMap<>(); @Getter private final int hash; @Getter private final Set avatarSkillStartIds; diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 1711c3b06..c23dc5fc1 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -83,12 +83,13 @@ public final class AbilityManager extends BasePlayerManager { boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; if (modifier.onAdded != null) { skillInvincibility |= - !Arrays.stream(modifier.onAdded) - .filter( - action -> - action.type == AbilityModifierAction.Type.AttachAbilityStateResistance - && action.resistanceListID == 11002) - .toList().isEmpty(); + !Arrays.stream(modifier.onAdded) + .filter( + action -> + action.type == AbilityModifierAction.Type.AttachAbilityStateResistance + && action.resistanceListID == 11002) + .toList() + .isEmpty(); } if (this.burstCasterId == entityId @@ -177,7 +178,12 @@ public final class AbilityManager extends BasePlayerManager { public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { Grasscutter.getLogger() - .trace("Ability invoke: {} {} ({}): {}", invoke, invoke.getArgumentType(), invoke.getArgumentTypeValue(), this.player.getScene().getEntityById(invoke.getEntityId())); + .trace( + "Ability invoke: {} {} ({}): {}", + invoke, + invoke.getArgumentType(), + invoke.getArgumentTypeValue(), + this.player.getScene().getEntityById(invoke.getEntityId())); var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if (entity != null) { Grasscutter.getLogger() @@ -204,7 +210,8 @@ public final class AbilityManager extends BasePlayerManager { if (invoke.getHead().getTargetId() != 0) { Grasscutter.getLogger() - .trace("Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); + .trace( + "Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); } if (invoke.getHead().getLocalId() != 0) { this.handleServerInvoke(invoke); diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index d6acf9e11..acc55006e 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievements.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievements.java @@ -61,9 +61,10 @@ public class Achievements { GameData.getAchievementDataMap().values().stream() .filter(AchievementData::isUsed) .forEach( - a -> map.put( - a.getId(), - new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); + a -> + map.put( + a.getId(), + new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); return map; } @@ -175,12 +176,13 @@ public class Achievements { return this.getAchievementList() .computeIfAbsent( achievementId, - id -> new Achievement( - Status.STATUS_UNFINISHED, - id, - GameData.getAchievementDataMap().get(id.intValue()).getProgress(), - 0, - 0)); + id -> + new Achievement( + Status.STATUS_UNFINISHED, + id, + GameData.getAchievementDataMap().get(id.intValue()).getProgress(), + 0, + 0)); } public boolean isInvalid(int achievementId) { @@ -231,7 +233,7 @@ public class Achievements { }); var a = this.getAchievement(i); - if(a == null) { + if (a == null) { Grasscutter.getLogger().warn("null returned while getting achievement!"); return; } diff --git a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java index d13cefb45..222971c3b 100644 --- a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java +++ b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java @@ -25,7 +25,8 @@ public class AllActivityConditionBuilder { private Map initActivityConditions() { Reflections reflector = Grasscutter.reflector; return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream() - .map(this::newInstance).filter(Objects::nonNull) + .map(this::newInstance) + .filter(Objects::nonNull) .map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h)) .collect( Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index c939c7727..932930b59 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; @@ -44,130 +46,72 @@ 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 java.util.*; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.val; import org.bson.types.ObjectId; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.*; -import java.util.stream.Stream; - -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; - @Entity(value = "avatars", useDiscriminator = false) public class Avatar { - @Transient - @Getter - private final Int2ObjectMap equips; - @Transient - @Getter - private final Int2FloatOpenHashMap fightProperties; - @Transient - @Getter - private final Int2FloatOpenHashMap fightPropOverrides; - @Id - private ObjectId id; - @Indexed - @Getter - private int ownerId; // Id of player that this avatar belongs to - @Transient - private Player owner; - @Transient - @Getter - private AvatarData avatarData; - @Nullable - @Transient - @Getter - private AvatarSkillDepotData skillDepot; - @Transient - @Getter - private long guid; // Player unique id - @Getter - private int avatarId; // Id of avatar - @Getter - @Setter - private int level = 1; - @Getter - @Setter - private int exp; - @Getter - @Setter - private int promoteLevel; - @Getter - @Setter - private int satiation; // Fullness - @Getter - @Setter - private int satiationPenalty; // When eating too much - @Getter - @Setter - private float currentHp; + @Transient @Getter private final Int2ObjectMap equips; + @Transient @Getter private final Int2FloatOpenHashMap fightProperties; + @Transient @Getter private final Int2FloatOpenHashMap fightPropOverrides; + @Id private ObjectId id; + @Indexed @Getter private int ownerId; // Id of player that this avatar belongs to + @Transient private Player owner; + @Transient @Getter private AvatarData avatarData; + @Nullable @Transient @Getter private AvatarSkillDepotData skillDepot; + @Transient @Getter private long guid; // Player unique id + @Getter private int avatarId; // Id of avatar + @Getter @Setter private int level = 1; + @Getter @Setter private int exp; + @Getter @Setter private int promoteLevel; + @Getter @Setter private int satiation; // Fullness + @Getter @Setter private int satiationPenalty; // When eating too much + @Getter @Setter private float currentHp; private float currentEnergy; - @Transient - @Getter - private Set extraAbilityEmbryos; + @Transient @Getter private Set extraAbilityEmbryos; private List fetters; private final Map skillLevelMap = new Int2IntArrayMap(7); // Talent levels - @Transient - @Getter + @Transient @Getter private final Map skillExtraChargeMap = new Int2IntArrayMap(2); // Charges @Transient - private final Map proudSkillBonusMap = new Int2IntArrayMap(2); // Talent bonus levels (from const) + private final Map proudSkillBonusMap = + new Int2IntArrayMap(2); // Talent bonus levels (from const) - @Getter - private int skillDepotId; + @Getter private int skillDepotId; private Set talentIdList; // Constellation id list - @Getter - private Set proudSkillList; // Character passives + @Getter private Set proudSkillList; // Character passives - @Getter - @Setter - private int flyCloak; - @Getter - @Setter - private int costume; - @Getter - private int bornTime; + @Getter @Setter private int flyCloak; + @Getter @Setter private int costume; + @Getter private int bornTime; - @Getter - @Setter - private int fetterLevel = 1; - @Getter - @Setter - private int fetterExp; + @Getter @Setter private int fetterLevel = 1; + @Getter @Setter private int fetterExp; - @Getter - @Setter - private int nameCardRewardId; - @Getter - @Setter - private int nameCardId; + @Getter @Setter private int nameCardRewardId; + @Getter @Setter private int nameCardId; // trial avatar property - @Getter - @Setter - private int trialAvatarId = 0; + @Getter @Setter private int trialAvatarId = 0; // cannot store to db if grant reason is not integer - @Getter - @Setter + @Getter @Setter private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber(); - @Getter - @Setter - private int fromParentQuestId = 0; + @Getter @Setter private int fromParentQuestId = 0; // so far no outer class or prop value has information of this, but from packet: // 1 = normal, 2 = trial avatar - @Transient - @Getter - @Setter - private int avatarType = Type.NORMAL.getNumber(); + @Transient @Getter @Setter private int avatarType = Type.NORMAL.getNumber(); @Deprecated // Do not use. Morhpia only! public Avatar() { @@ -197,13 +141,18 @@ public class Avatar { this.proudSkillList = new HashSet<>(); // Combat properties - Stream.of(FightProperty.values()).map(FightProperty::getId).filter(id -> (id > 0) && (id < 3000)).forEach(id -> this.setFightProperty(id, 0f)); + Stream.of(FightProperty.values()) + .map(FightProperty::getId) + .filter(id -> (id > 0) && (id < 3000)) + .forEach(id -> this.setFightProperty(id, 0f)); - this.setSkillDepotData(switch (this.getAvatarId()) { - case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); - case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap().get(701); - default -> data.getSkillDepot(); - }); + this.setSkillDepotData( + switch (this.getAvatarId()) { + case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); + case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap() + .get(701); + default -> data.getSkillDepot(); + }); // Set stats this.recalcStats(); @@ -235,7 +184,8 @@ public class Avatar { * @return True if the avatar is a main character. */ public boolean isMainCharacter() { - return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE).contains(this.getAvatarId()); + return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE) + .contains(this.getAvatarId()); } public Player getPlayer() { @@ -297,8 +247,7 @@ public class Avatar { /** * @return The avatar's equipped weapon. */ - @Nullable - public GameItem getWeapon() { + @Nullable public GameItem getWeapon() { return this.getEquipBySlot(EquipType.EQUIP_WEAPON); } @@ -328,17 +277,24 @@ public class Avatar { * Changes this avatar's skill depot. * * @param skillDepot The new skill depot. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. */ public void setSkillDepotData(AvatarSkillDepotData skillDepot, boolean notify) { // Set id and depot this.skillDepotId = skillDepot.getId(); this.skillDepot = skillDepot; // Add any missing skills - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); // Add proud skills this.proudSkillList.clear(); - skillDepot.getInherentProudSkillOpens().stream().filter(openData -> openData.getProudSkillGroupId() > 0).filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()).mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1).filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)).forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); + skillDepot.getInherentProudSkillOpens().stream() + .filter(openData -> openData.getProudSkillGroupId() > 0) + .filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) + .mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1) + .filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)) + .forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); this.recalcStats(); if (notify) { @@ -362,7 +318,7 @@ public class Avatar { * in its 'candSkillDepot's. * * @param elementTypeToChange The new element to change to. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. * @return True if the element was changed, false otherwise. */ public boolean changeElement(@Nonnull ElementType elementTypeToChange, boolean notify) { @@ -410,7 +366,8 @@ public class Avatar { ElementType element = depot.getElementType(); var maxEnergy = depot.getEnergySkillData().getCostElemVal(); this.setFightProperty(element.getMaxEnergyProp(), maxEnergy); - this.setFightProperty(element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); + this.setFightProperty( + element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); } } @@ -438,10 +395,14 @@ public class Avatar { return getFightProperties().getOrDefault(prop.getId(), 0f); } - public Map getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. + public Map + getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. var map = new Int2IntOpenHashMap(); if (this.skillDepot == null) return map; - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach( + skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); return map; } @@ -450,18 +411,21 @@ public class Avatar { public Map getProudSkillBonusMap() { var map = new Int2IntArrayMap(); if (this.skillDepot == null) return map; - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> { - val skillData = GameData.getAvatarSkillDataMap().get(skillId); - if (skillData == null) return; - int proudSkillGroupId = skillData.getProudSkillGroupId(); - int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); - int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); - int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); - if (maxLevel > 0) { - bonus = Math.min(bonus, maxLevel - curLevel); - } - map.put(proudSkillGroupId, bonus); - }); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach( + skillId -> { + val skillData = GameData.getAvatarSkillDataMap().get(skillId); + if (skillData == null) return; + int proudSkillGroupId = skillData.getProudSkillGroupId(); + int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); + int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); + int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); + if (maxLevel > 0) { + bonus = Math.min(bonus, maxLevel - curLevel); + } + map.put(proudSkillGroupId, bonus); + }); return map; } @@ -495,7 +459,9 @@ public class Avatar { if (otherAvatar != null) { // Unequip other avatar's item if (otherAvatar.unequipItem(item.getItemData().getEquipType())) { - getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); + getPlayer() + .sendPacket( + new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); } // Swap with other avatar if (getEquips().containsKey(itemEquipType.getValue())) { @@ -513,9 +479,14 @@ public class Avatar { this.getEquips().put(itemEquipType.getValue(), item); if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) { - item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); - this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == getPlayer().getScene())) { + item.setWeaponEntity( + new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); + this.getPlayer() + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); } // item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); } @@ -553,7 +524,8 @@ public class Avatar { public void recalcStats(boolean forceSendAbilityChange) { // Setup var data = this.getAvatarData(); - var promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); + var promoteData = + GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); var setMap = new Int2IntOpenHashMap(); // Extra ability embryos @@ -566,18 +538,27 @@ public class Avatar { this.setNameCardId(data.getNameCardId()); // Get hp percent, set to 100% if none - float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); + float hpPercent = + this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 + ? 1f + : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) + / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); // Store current energy value for later - float currentEnergy = (this.getSkillDepot() != null) ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) : 0f; + float currentEnergy = + (this.getSkillDepot() != null) + ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) + : 0f; // Clear properties this.getFightProperties().clear(); // Base stats this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel())); - this.setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); - this.setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); + this.setFightProperty( + FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); + this.setFightProperty( + FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical()); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt()); this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f); @@ -599,11 +580,14 @@ public class Avatar { continue; } // Artifact main stat - ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); + ReliquaryMainPropData mainPropData = + GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); if (mainPropData != null) { - ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); + ReliquaryLevelData levelData = + GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); if (levelData != null) { - this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); + this.addFightProperty( + mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); } } // Artifact sub stats @@ -620,31 +604,32 @@ public class Avatar { } // Set stuff - setMap.forEach((setId, amount) -> { - ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); - if (setData == null) return; + setMap.forEach( + (setId, amount) -> { + ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); + if (setData == null) return; - // Calculate how many items are from the set - // Add affix data from set bonus - val setNeedNum = setData.getSetNeedNum(); - for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { - if (amount < setNeedNum[setIndex]) break; + // Calculate how many items are from the set + // Add affix data from set bonus + val setNeedNum = setData.getSetNeedNum(); + for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { + if (amount < setNeedNum[setIndex]) break; - int affixId = (setData.getEquipAffixId() * 10) + setIndex; - EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); - if (affix == null) { - continue; - } + int affixId = (setData.getEquipAffixId() * 10) + setIndex; + EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); + if (affix == null) { + continue; + } - // Add properties from this affix to our avatar - for (FightPropData prop : affix.getAddProps()) { - this.addFightProperty(prop.getProp(), prop.getValue()); - } + // Add properties from this affix to our avatar + for (FightPropData prop : affix.getAddProps()) { + this.addFightProperty(prop.getProp(), prop.getValue()); + } - // Add any skill strings from this affix - this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); - } - }); + // Add any skill strings from this affix + this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); + } + }); // Weapon GameItem weapon = this.getWeapon(); @@ -653,11 +638,15 @@ public class Avatar { WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel()); if (curveData != null) { for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) { - this.addFightProperty(weaponProperty.getPropType(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); + this.addFightProperty( + weaponProperty.getPropType(), + weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); } } // Weapon promotion stats - WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); + WeaponPromoteData wepPromoteData = + GameData.getWeaponPromoteData( + weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); if (wepPromoteData != null) { for (FightPropData prop : wepPromoteData.getAddProps()) { if (prop.getValue() == 0f || prop.getProp() == null) { @@ -692,7 +681,8 @@ public class Avatar { } // Add proud skills and unlock them if needed - AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); + AvatarSkillDepotData skillDepot = + GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); this.getProudSkillList().clear(); if (skillDepot != null) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { @@ -725,17 +715,31 @@ public class Avatar { } // Constellations - this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).forEach(this::addToExtraAbilityEmbryos); + this.getTalentIdList() + .intStream() + .mapToObj(GameData.getAvatarTalentDataMap()::get) + .filter(Objects::nonNull) + .map(AvatarTalentData::getOpenConfig) + .filter(Objects::nonNull) + .forEach(this::addToExtraAbilityEmbryos); // Add any skill strings from this constellation // Set % stats - FightProperty.forEachCompoundProperty(c -> this.setFightProperty(c.getResult(), this.getFightProperty(c.getFlat()) + (this.getFightProperty(c.getBase()) * (1f + this.getFightProperty(c.getPercent()))))); + FightProperty.forEachCompoundProperty( + c -> + this.setFightProperty( + c.getResult(), + this.getFightProperty(c.getFlat()) + + (this.getFightProperty(c.getBase()) + * (1f + this.getFightProperty(c.getPercent()))))); // Reapply all overrides this.fightProperties.putAll(this.fightPropOverrides); // Set current hp - this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); + this.setFightProperty( + FightProperty.FIGHT_PROP_CUR_HP, + this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); // Packet if (getPlayer() != null && getPlayer().hasSentLoginPackets()) { @@ -743,7 +747,9 @@ public class Avatar { getPlayer().sendPacket(new PacketAvatarFightPropNotify(this)); // Update client abilities EntityAvatar entity = this.getAsEntity(); - if (entity != null && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) || forceSendAbilityChange)) { + if (entity != null + && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) + || forceSendAbilityChange)) { getPlayer().sendPacket(new PacketAbilityChangeNotify(entity)); } } @@ -781,12 +787,22 @@ public class Avatar { // Check if new constellation adds +3 to a skill level if (this.calcConstellationExtraLevels(entry) && notifyClient) { // Packet - this.getPlayer().sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); + this.getPlayer() + .sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); } // Check if new constellation adds skill charges if (this.calcConstellationExtraCharges(entry) && notifyClient) { // Packet - Stream.of(entry.getSkillPointModifiers()).mapToInt(SkillPointModifier::getSkillId).forEach(skillId -> this.getPlayer().sendPacket(new PacketAvatarSkillMaxChargeCountNotify(this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); + Stream.of(entry.getSkillPointModifiers()) + .mapToInt(SkillPointModifier::getSkillId) + .forEach( + skillId -> + this.getPlayer() + .sendPacket( + new PacketAvatarSkillMaxChargeCountNotify( + this, + skillId, + this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); } } @@ -800,7 +816,16 @@ public class Avatar { return; } - this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).filter(openConfig -> !openConfig.isEmpty()).map(GameData.getOpenConfigEntries()::get).filter(Objects::nonNull).forEach(e -> this.calcConstellation(e, false)); + this.getTalentIdList() + .intStream() + .mapToObj(GameData.getAvatarTalentDataMap()::get) + .filter(Objects::nonNull) + .map(AvatarTalentData::getOpenConfig) + .filter(Objects::nonNull) + .filter(openConfig -> !openConfig.isEmpty()) + .map(GameData.getOpenConfigEntries()::get) + .filter(Objects::nonNull) + .forEach(e -> this.calcConstellation(e, false)); } private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { @@ -820,14 +845,18 @@ public class Avatar { } private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { - if(this.skillDepot == null) return false; - int skillId = switch (entry.getExtraTalentIndex()) { - case 9 -> this.skillDepot.getEnergySkill(); // Ult skill - case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill - case 1 -> - (!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) - default -> 0; - }; + if (this.skillDepot == null) return false; + int skillId = + switch (entry.getExtraTalentIndex()) { + case 9 -> this.skillDepot.getEnergySkill(); // Ult skill + case 2 -> (this.skillDepot.getSkills().size() >= 2) + ? this.skillDepot.getSkills().get(1) + : 0; // E skill + case 1 -> (!this.skillDepot.getSkills().isEmpty()) + ? this.skillDepot.getSkills().get(0) + : 0; // Normal Attack (Liney) + default -> 0; + }; // Sanity check if (skillId == 0) { return false; @@ -846,7 +875,8 @@ public class Avatar { } private int addProudSkillLevelBonus(int proudSkillGroupId, int bonus) { - return this.proudSkillBonusMap.compute(proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); + return this.proudSkillBonusMap.compute( + proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); } public boolean upgradeSkill(int skillId) { @@ -877,7 +907,9 @@ public class Avatar { if (level < 0 || level > 15) return false; var validLevels = GameData.getAvatarSkillLevels(skillId); if (validLevels != null && !validLevels.contains(level)) return false; - int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns + int oldLevel = + this.skillLevelMap.getOrDefault( + skillId, 0); // just taking the return value of put would have null concerns this.skillLevelMap.put(skillId, level); this.save(); @@ -912,7 +944,9 @@ public class Avatar { var player = this.getPlayer(); // Pay constellation item if possible - if (!skipPayment && (player != null) && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { + if (!skipPayment + && (player != null) + && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { return false; } @@ -943,7 +977,8 @@ public class Avatar { this.save(); return; } - this.talentIdList.removeAll(this.getTalentIdList()); // Only remove constellations from active depot + this.talentIdList.removeAll( + this.getTalentIdList()); // Only remove constellations from active depot for (int i = 0; i < level; i++) this.unlockConstellation(true); this.recalcStats(); this.save(); @@ -952,7 +987,12 @@ public class Avatar { public boolean sendSkillExtraChargeMap() { val map = this.getSkillExtraChargeMap(); if (map.isEmpty()) return false; - this.getPlayer().sendPacket(new PacketAvatarSkillInfoNotify(this.guid, new Int2IntArrayMap(map))); // TODO: Remove this allocation when updating interfaces to FastUtils + this.getPlayer() + .sendPacket( + new PacketAvatarSkillInfoNotify( + this.guid, + new Int2IntArrayMap( + map))); // TODO: Remove this allocation when updating interfaces to FastUtils // later return true; } @@ -984,7 +1024,12 @@ public class Avatar { } if (this.fetters != null) { - this.fetters.forEach(fetterId -> avatarFetter.addFetterList(FetterData.newBuilder().setFetterId(fetterId).setFetterState(FetterState.FINISH.getValue()))); + this.fetters.forEach( + fetterId -> + avatarFetter.addFetterList( + FetterData.newBuilder() + .setFetterId(fetterId) + .setFetterState(FetterState.FINISH.getValue()))); } int cardId = this.getNameCardId(); @@ -993,40 +1038,100 @@ public class Avatar { avatarFetter.addRewardedFetterLevelList(10); } - AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder().setAvatarId(this.getAvatarId()).setGuid(this.getGuid()).setLifeState(1).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).putAllSkillLevelMap(this.getSkillLevelMap()).addAllInherentProudSkillList(this.getProudSkillList()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setAvatarType(this.getAvatarType()).setBornTime(this.getBornTime()).setFetterInfo(avatarFetter).setWearingFlycloakId(this.getFlyCloak()).setCostumeId(this.getCostume()); + AvatarInfo.Builder avatarInfo = + AvatarInfo.newBuilder() + .setAvatarId(this.getAvatarId()) + .setGuid(this.getGuid()) + .setLifeState(1) + .addAllTalentIdList(this.getTalentIdList()) + .putAllFightPropMap(this.getFightProperties()) + .setSkillDepotId(this.getSkillDepotId()) + .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) + .putAllSkillLevelMap(this.getSkillLevelMap()) + .addAllInherentProudSkillList(this.getProudSkillList()) + .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) + .setAvatarType(this.getAvatarType()) + .setBornTime(this.getBornTime()) + .setFetterInfo(avatarFetter) + .setWearingFlycloakId(this.getFlyCloak()) + .setCostumeId(this.getCostume()); - this.getSkillExtraChargeMap().forEach((skillId, count) -> avatarInfo.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); + this.getSkillExtraChargeMap() + .forEach( + (skillId, count) -> + avatarInfo.putSkillMap( + skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); this.getEquips().forEach((k, item) -> avatarInfo.addEquipGuidList(item.getGuid())); - avatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - avatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - avatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + avatarInfo.putPropMap( + PlayerProperty.PROP_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + avatarInfo.putPropMap( + PlayerProperty.PROP_EXP.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + avatarInfo.putPropMap( + PlayerProperty.PROP_BREAK_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + avatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_VAL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + avatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), + ProtoHelper.newPropValue( + PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); return avatarInfo.build(); } // used only in character showcase public ShowAvatarInfo toShowAvatarInfoProto() { - AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); + AvatarFetterInfo.Builder avatarFetter = + AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); - ShowAvatarInfo.Builder showAvatarInfo = ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder().setAvatarId(avatarId).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).addAllInherentProudSkillList(this.getProudSkillList()).putAllSkillLevelMap(this.getSkillLevelMap()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setFetterInfo(avatarFetter).setCostumeId(this.getCostume()); + ShowAvatarInfo.Builder showAvatarInfo = + ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder() + .setAvatarId(avatarId) + .addAllTalentIdList(this.getTalentIdList()) + .putAllFightPropMap(this.getFightProperties()) + .setSkillDepotId(this.getSkillDepotId()) + .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) + .addAllInherentProudSkillList(this.getProudSkillList()) + .putAllSkillLevelMap(this.getSkillLevelMap()) + .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) + .setFetterInfo(avatarFetter) + .setCostumeId(this.getCostume()); - showAvatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_EXP.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_BREAK_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_VAL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), + ProtoHelper.newPropValue( + PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA); - showAvatarInfo.putPropMap(PlayerProperty.PROP_MAX_STAMINA.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_MAX_STAMINA.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); for (GameItem item : this.getEquips().values()) { if (item.getItemType() == ItemType.ITEM_RELIQUARY) { - showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setReliquary(item.toReliquaryProto())); + showAvatarInfo.addEquipList( + ShowEquip.newBuilder() + .setItemId(item.getItemId()) + .setReliquary(item.toReliquaryProto())); } else if (item.getItemType() == ItemType.ITEM_WEAPON) { - showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); + showAvatarInfo.addEquipList( + ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); } } @@ -1036,12 +1141,13 @@ public class Avatar { /** * Converts this avatar into a trial avatar. * - * @param level The avatar's level. - * @param avatarId The ID of the avatar. + * @param level The avatar's level. + * @param avatarId The ID of the avatar. * @param grantReason The reason for granting the avatar. - * @param questId The ID of the quest that granted the avatar. + * @param questId The ID of the quest that granted the avatar. */ - public void setTrialAvatarInfo(int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { + public void setTrialAvatarInfo( + int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { this.setLevel(level); this.setPromoteLevel(getMinPromoteLevel(level)); this.setTrialAvatarId(avatarId); @@ -1058,7 +1164,10 @@ public class Avatar { * @return The avatar's template. */ private int getTrialTemplate() { - return this.getLevel() <= 9 ? 1 : (int) (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels + return this.getLevel() <= 9 + ? 1 + : (int) + (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels } /** @@ -1080,11 +1189,11 @@ public class Avatar { return trialData.getCoreProudSkillLevel(); // enhanced version of weapon } - /** - * Applies the correct skill level for the trial avatar. - */ + /** Applies the correct skill level for the trial avatar. */ public void applyTrialSkillLevels() { - this.getSkillLevelMap().keySet().forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); + this.getSkillLevelMap() + .keySet() + .forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); } /** @@ -1096,7 +1205,9 @@ public class Avatar { if (GameData.getTrialAvatarDataMap().get(this.getTrialAvatarId()) == null) return this.getAvatarData().getInitialWeapon(); - return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null ? getAvatarData().getInitialWeapon() : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon + return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null + ? getAvatarData().getInitialWeapon() + : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon } // Use custom data. @@ -1104,7 +1215,9 @@ public class Avatar { if (trialData == null) return 0; var trialCustomParams = trialData.getTrialAvatarParamList(); - return trialCustomParams.size() < 2 ? getAvatarData().getInitialWeapon() : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); + return trialCustomParams.size() < 2 + ? getAvatarData().getInitialWeapon() + : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); } /** @@ -1115,7 +1228,8 @@ public class Avatar { if (GameData.getTrialAvatarCustomData().isEmpty()) { int trialAvatarTemplateLevel = getTrialTemplate(); - TrialAvatarTemplateData templateData = GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); + TrialAvatarTemplateData templateData = + GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); return templateData == null ? List.of() : templateData.getTrialReliquaryList(); } @@ -1123,13 +1237,14 @@ public class Avatar { var trialData = GameData.getTrialAvatarCustomData().get(this.getTrialAvatarId()); if (trialData == null) return List.of(); - var trialCustomParams = GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); - return trialCustomParams.size() < 3 ? List.of() : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); + var trialCustomParams = + GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); + return trialCustomParams.size() < 3 + ? List.of() + : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); } - /** - * Applies the correct items for the trial avatar. - */ + /** Applies the correct items for the trial avatar. */ public void applyTrialItems() { // Use an enhanced version of the weapon if available. var weapon = new GameItem(this.getTrialWeaponId()); @@ -1139,44 +1254,55 @@ public class Avatar { this.getEquips().put(weapon.getEquipSlot(), weapon); // Add artifacts for the trial avatar. - this.getTrialReliquary().forEach(id -> { - var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); - if (reliquaryData == null) return; + this.getTrialReliquary() + .forEach( + id -> { + var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); + if (reliquaryData == null) return; - var relic = new GameItem(reliquaryData.getReliquaryId()); - relic.setLevel(reliquaryData.getLevel()); - relic.setMainPropId(reliquaryData.getMainPropId()); - relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); - this.getEquips().put(relic.getEquipSlot(), relic); - }); + var relic = new GameItem(reliquaryData.getReliquaryId()); + relic.setLevel(reliquaryData.getLevel()); + relic.setMainPropId(reliquaryData.getMainPropId()); + relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); + this.getEquips().put(relic.getEquipSlot(), relic); + }); // 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()); - }); + GameData.getAvatarCostumeDataItemIdMap() + .values() + .forEach( + costumeData -> { + if (costumeData.getCharacterId() != this.getAvatarId()) return; + this.setCostume(costumeData.getId()); + }); } } - /** - * Equips the items applied from {@link Avatar#applyTrialItems()}. - */ + /** Equips the items applied from {@link Avatar#applyTrialItems()}. */ public void equipTrialItems() { var player = this.getPlayer(); - this.getEquips().values().forEach(item -> { - item.setEquipCharacter(this.getAvatarId()); - item.setOwner(player); - if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) { - item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); - player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); - } + this.getEquips() + .values() + .forEach( + item -> { + item.setEquipCharacter(this.getAvatarId()); + item.setOwner(player); + if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == player.getScene())) { + item.setWeaponEntity( + new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); + player + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + } - player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); - } - }); + player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); + } + }); } /** @@ -1185,20 +1311,26 @@ public class Avatar { * @return The trial info protocol buffer. */ public TrialAvatarInfo toTrialInfo() { - var trialAvatar = TrialAvatarInfo.newBuilder().setTrialAvatarId(this.getTrialAvatarId()).setGrantRecord(TrialAvatarGrantRecord.newBuilder().setGrantReason(this.getGrantReason()).setFromParentQuestId(this.getFromParentQuestId())); + var trialAvatar = + TrialAvatarInfo.newBuilder() + .setTrialAvatarId(this.getTrialAvatarId()) + .setGrantRecord( + TrialAvatarGrantRecord.newBuilder() + .setGrantReason(this.getGrantReason()) + .setFromParentQuestId(this.getFromParentQuestId())); // Check if the avatar is a trial avatar. if (this.getTrialAvatarId() > 0) { // Add the artifacts and weapons for the avatar. - trialAvatar.addAllTrialEquipList(this.getEquips().values().stream().map(GameItem::toProto).toList()); + trialAvatar.addAllTrialEquipList( + this.getEquips().values().stream().map(GameItem::toProto).toList()); } return trialAvatar.build(); } @PostLoad - private void onLoad() { - } + private void onLoad() {} @PrePersist private void prePersist() { @@ -1208,7 +1340,8 @@ public class Avatar { @AllArgsConstructor @Getter enum Type { - NORMAL(1), TRIAL(2); + NORMAL(1), + TRIAL(2); final int number; } diff --git a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java index 5d30007c6..c75ebaec4 100644 --- a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java +++ b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java @@ -15,14 +15,12 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import lombok.Getter; - import java.util.Iterator; import java.util.List; +import lombok.Getter; public class AvatarStorage extends BasePlayerManager implements Iterable { - @Getter - private final Int2ObjectMap avatars; + @Getter private final Int2ObjectMap avatars; private final Long2ObjectMap avatarsGuid; public AvatarStorage(Player player) { diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java index b22bc7de0..f5b0b1097 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java @@ -9,13 +9,9 @@ import lombok.Setter; @Entity public class BattlePassMission { - @Getter - private int id; - @Setter - @Getter - private int progress; - @Setter - private BattlePassMissionStatus status; + @Getter private int id; + @Setter @Getter private int progress; + @Setter private BattlePassMissionStatus status; @Transient private BattlePassMissionData data; diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java index d37518f45..b25b4ff96 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java @@ -8,12 +8,9 @@ import lombok.Getter; @Entity public class BattlePassReward { - @Getter - private int level; - @Getter - private int rewardId; - @Getter - private boolean paid; + @Getter private int level; + @Getter private int rewardId; + @Getter private boolean paid; @Transient private BattlePassMissionData data; diff --git a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java index bd1797270..220cdad65 100644 --- a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java +++ b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java @@ -10,10 +10,9 @@ import emu.grasscutter.server.event.player.PlayerChatEvent; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; -import lombok.Getter; - import java.util.*; import java.util.regex.Pattern; +import lombok.Getter; public class ChatSystem implements ChatSystemHandler { static final String PREFIXES = "[/!]"; @@ -24,8 +23,7 @@ public class ChatSystem implements ChatSystemHandler { // user id -> chat partner id -> [messages] private final Map>> history = new HashMap<>(); - @Getter - private final GameServer server; + @Getter private final GameServer server; public ChatSystem(GameServer server) { this.server = server; diff --git a/src/main/java/emu/grasscutter/game/combine/CombineManger.java b/src/main/java/emu/grasscutter/game/combine/CombineManger.java index 9fff60cf2..61baedec0 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineManger.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineManger.java @@ -27,8 +27,7 @@ public class CombineManger extends BaseGameSystem { // Read the data we need for strongbox. try { DataLoader.loadList("ReliquaryDecompose.json", ReliquaryDecomposeEntry.class) - .forEach( - entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems())); + .forEach(entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems())); Grasscutter.getLogger() .debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size()); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/combine/CombineResult.java b/src/main/java/emu/grasscutter/game/combine/CombineResult.java index 4f372cc25..1fc4db3cc 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineResult.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineResult.java @@ -1,11 +1,10 @@ package emu.grasscutter.game.combine; import emu.grasscutter.data.common.ItemParamData; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class CombineResult { @@ -13,5 +12,4 @@ public class CombineResult { private List result; private List extra; private List back; - } diff --git a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java index cf6427752..40d576bf0 100644 --- a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java +++ b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.combine; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class ReliquaryDecomposeEntry { private int configId; private List items; - } diff --git a/src/main/java/emu/grasscutter/game/drop/DropData.java b/src/main/java/emu/grasscutter/game/drop/DropData.java index 5d2cbbef0..6c8cec4ab 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropData.java +++ b/src/main/java/emu/grasscutter/game/drop/DropData.java @@ -8,13 +8,11 @@ import lombok.Setter; public class DropData { private int minWeight; private int maxWeight; - @Setter - private int itemId; + @Setter private int itemId; private int minCount; private int maxCount; private boolean share = false; - @Setter - private boolean give = false; + @Setter private boolean give = false; public void setIsShare(boolean share) { this.share = share; diff --git a/src/main/java/emu/grasscutter/game/drop/DropInfo.java b/src/main/java/emu/grasscutter/game/drop/DropInfo.java index f46e4986d..afdca351b 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropInfo.java +++ b/src/main/java/emu/grasscutter/game/drop/DropInfo.java @@ -1,13 +1,11 @@ package emu.grasscutter.game.drop; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @SuppressWarnings("deprecation") public class DropInfo { private int monsterId; private List dropDataList; - } diff --git a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java index 2a3bea754..b65708687 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java +++ b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java @@ -11,9 +11,8 @@ import emu.grasscutter.game.world.*; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @SuppressWarnings("deprecation") diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java index 941b39405..7c9f7c1a2 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.dungeons; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class DungeonDrop { private int dungeonId; private List drops; - } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java index a509a1786..60efe56d9 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.dungeons; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class DungeonDropEntry { @@ -13,5 +12,4 @@ public class DungeonDropEntry { private List probabilities; private List itemProbabilities; private boolean mpDouble; - } diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java index 8b17ac2b2..8be466286 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java @@ -29,7 +29,8 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH Scene scene, SceneGroup group) { val realGroup = scene.getScriptManager().getGroupById(groupId); - val challengeTriggers = new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); + val challengeTriggers = + new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId); val challengeType = challengeData.getChallengeType(); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java index 33bfb7050..0bb4cfb68 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java @@ -82,7 +82,7 @@ public class EntityRegion extends GameEntity { @Override public SceneEntityInfoOuterClass.SceneEntityInfo toProto() { - /* The Region Entity would not be sent to client. */ + /* The Region Entity would not be sent to client. */ return null; } diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java index cbeecaf76..2cecac1f9 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java @@ -19,8 +19,7 @@ import emu.grasscutter.utils.Utils; import lombok.Getter; public final class GadgetGatherObject extends GadgetContent { - @Getter - private int itemId; + @Getter private int itemId; private boolean isForbidGuest; public GadgetGatherObject(EntityGadget gadget) { diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index af17ea1ac..43c924578 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -15,19 +15,12 @@ import org.bson.types.ObjectId; public class Friendship { @Id private ObjectId id; - @Setter - @Getter - @Transient private Player owner; + @Setter @Getter @Transient private Player owner; - @Getter - @Indexed private int ownerId; - @Getter - @Indexed private int friendId; - @Setter - private boolean isFriend; - @Setter - @Getter - private int askerId; + @Getter @Indexed private int ownerId; + @Getter @Indexed private int friendId; + @Setter private boolean isFriend; + @Setter @Getter private int askerId; private PlayerProfile profile; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index 3d0c2db44..3b3d2c6a3 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -96,7 +96,10 @@ public class GachaBanner { private void warnDeprecated(String name, String replacement) { Grasscutter.getLogger() - .error("Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", name, replacement); + .error( + "Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", + name, + replacement); this.deprecated = true; } diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java index d66c12f3d..779a10424 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java @@ -2,7 +2,6 @@ package emu.grasscutter.game.gacha; import dev.morphia.annotations.*; import java.util.Date; - import lombok.Getter; import lombok.Setter; import org.bson.types.ObjectId; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java index e119201eb..2657d3c02 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java @@ -26,15 +26,13 @@ import it.unimi.dsi.fastutil.ints.*; import java.nio.file.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; - import lombok.Getter; import org.greenrobot.eventbus.Subscribe; public class GachaSystem extends BaseGameSystem { private static final int starglitterId = 221; private static final int stardustId = 222; - @Getter - private final Int2ObjectMap gachaBanners; + @Getter private final Int2ObjectMap gachaBanners; private WatchService watchService; public GachaSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/game/home/GameHome.java b/src/main/java/emu/grasscutter/game/home/GameHome.java index fd6ce6368..faafe050d 100644 --- a/src/main/java/emu/grasscutter/game/home/GameHome.java +++ b/src/main/java/emu/grasscutter/game/home/GameHome.java @@ -281,10 +281,11 @@ public class GameHome { return this.finishedTalkIdMap.entrySet().stream() .map( - e -> HomeAvatarTalkFinishInfo.newBuilder() - .setAvatarId(e.getKey()) - .addAllFinishTalkIdList(e.getValue()) - .build()) + e -> + HomeAvatarTalkFinishInfo.newBuilder() + .setAvatarId(e.getKey()) + .addAllFinishTalkIdList(e.getValue()) + .build()) .toList(); } @@ -393,9 +394,7 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> e.getDeployNPCList() - .forEach( - id -> invitedAvatars.add(id.getAvatarId()))); + (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId()))); // Check as realm 5 inside is not in defaults and will be null if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { @@ -404,9 +403,7 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> e.getDeployNPCList() - .forEach( - id -> invitedAvatars.add(id.getAvatarId()))); + (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId()))); } // Add exp to all avatars diff --git a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java index 9297ce1fd..b7ac1d826 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java +++ b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java @@ -93,24 +93,25 @@ public class HomeModuleManager { .map(HomeBlockItem::getDeployNPCList) .flatMap(Collection::stream) .forEach( - avatar -> suites.forEach( - suite -> { - var data = - SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( - avatar.getAvatarId(), suite.getSuiteId()); - if (data == null || this.home.isRewardEventFinished(data.getId())) { - return; - } + avatar -> + suites.forEach( + suite -> { + var data = + SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( + avatar.getAvatarId(), suite.getSuiteId()); + if (data == null || this.home.isRewardEventFinished(data.getId())) { + return; + } - this.rewardEvents.add( - new HomeAvatarRewardEvent( - homeOwner, - data.getId(), - data.getRewardID(), - data.getAvatarID(), - data.getSuiteId(), - suite.getGuid())); - })); + this.rewardEvents.add( + new HomeAvatarRewardEvent( + homeOwner, + data.getId(), + data.getRewardID(), + data.getAvatarID(), + data.getSuiteId(), + suite.getGuid())); + })); if (this.summonEvents != null) { var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList(); diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index 1b0acee86..2953479f8 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -103,11 +103,12 @@ public class HomeSceneItem { homeAnimalItem -> GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId())) .map( - homeAnimalItem -> new EntityHomeAnimal( - scene, - GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), - homeAnimalItem.getSpawnPos(), - homeAnimalItem.getSpawnRot())) + homeAnimalItem -> + new EntityHomeAnimal( + scene, + GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), + homeAnimalItem.getSpawnPos(), + homeAnimalItem.getSpawnRot())) .toList(); } diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index edea4ad33..558dd6700 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -28,8 +28,7 @@ import org.bson.types.ObjectId; @Entity(value = "items", useDiscriminator = false) public class GameItem { @Id private ObjectId id; - @Getter - @Indexed private int ownerId; + @Getter @Indexed private int ownerId; @Getter @Setter private int itemId; @Getter @Setter private int count; diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 39a8d716c..5da8d49d3 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -21,14 +21,12 @@ import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.longs.*; import java.util.*; import javax.annotation.Nullable; - import lombok.Getter; import lombok.val; public class Inventory extends BasePlayerManager implements Iterable { private final Long2ObjectMap store; - @Getter - private final Int2ObjectMap inventoryTypes; + @Getter private final Int2ObjectMap inventoryTypes; public Inventory(Player player) { super(player); @@ -321,7 +319,9 @@ public class Inventory extends BasePlayerManager implements Iterable { case MATERIAL_COSTUME: case MATERIAL_NAMECARD: Grasscutter.getLogger() - .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); + .warn( + "Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", + item.getItemData().getMaterialType().name()); return null; default: if (tab == null) { @@ -429,22 +429,24 @@ public class Inventory extends BasePlayerManager implements Iterable { private int getVirtualItemCount(int itemId) { return switch (itemId) { case 201 -> // Primogem - this.player.getPrimogems(); + this.player.getPrimogems(); case 202 -> // Mora - this.player.getMora(); + this.player.getMora(); case 203 -> // Genesis Crystals - this.player.getCrystals(); + this.player.getCrystals(); case 106 -> // Resin - this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); + this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); case 107 -> // Legendary Key - this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); + this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); case 204 -> // Home Coin - this.player.getHomeCoin(); + this.player.getHomeCoin(); default -> { GameItem item = - getInventoryTab(ItemType.ITEM_MATERIAL) - .getItemById( - itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S + getInventoryTab(ItemType.ITEM_MATERIAL) + .getItemById( + itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield + // (item == null) ? 0 : item.getCount(); // What if we ever want to + // operate on weapons/relics/furniture? :S } }; } diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java index e09d40a97..b0b4987f5 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java @@ -13,5 +13,4 @@ public class ItemDef { this.itemId = itemId; this.count = count; } - } diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index 8558e9de2..b1276f1ba 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -11,18 +11,14 @@ import emu.grasscutter.net.proto.MailCollectStateOuterClass.MailCollectState; import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; import java.time.Instant; import java.util.*; - import lombok.Getter; import lombok.Setter; import org.bson.types.ObjectId; @Entity(value = "mail", useDiscriminator = false) public final class Mail { - @Getter - @Id private ObjectId id; - @Setter - @Getter - @Indexed private int ownerUid; + @Getter @Id private ObjectId id; + @Setter @Getter @Indexed private int ownerUid; public final MailContent mailContent; public final List itemList; public final long sendTime; @@ -36,7 +32,7 @@ public final class Mail { public Mail() { this( new MailContent(), - new ArrayList<>(), + new ArrayList<>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command } diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index a14b0cafb..b6e38fb3a 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -5,9 +5,8 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.*; import emu.grasscutter.server.event.player.PlayerReceiveMailEvent; import emu.grasscutter.server.packet.send.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class MailHandler extends BasePlayerManager { @@ -34,7 +33,10 @@ public class MailHandler extends BasePlayerManager { this.mail.add(message); Grasscutter.getLogger() - .debug("Mail sent to user [{}:{}]!", this.getPlayer().getUid(), this.getPlayer().getNickname()); + .debug( + "Mail sent to user [{}:{}]!", + this.getPlayer().getUid(), + this.getPlayer().getNickname()); if (this.getPlayer().isOnline()) { this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message)); @@ -57,7 +59,7 @@ public class MailHandler extends BasePlayerManager { } public void deleteMail(List mailList) { - List sortedMailList = new ArrayList<>(mailList); + List sortedMailList = new ArrayList<>(mailList); sortedMailList.sort(Collections.reverseOrder()); List deleted = new ArrayList<>(); diff --git a/src/main/java/emu/grasscutter/game/managers/SotSManager.java b/src/main/java/emu/grasscutter/game/managers/SotSManager.java index 2864e223e..d3f5d0430 100644 --- a/src/main/java/emu/grasscutter/game/managers/SotSManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SotSManager.java @@ -180,7 +180,10 @@ public class SotSManager extends BasePlayerManager { public void run() { refillSpringVolume(); - logger.trace("isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", getIsAutoRecoveryEnabled(), getAutoRecoveryPercentage()); + logger.trace( + "isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", + getIsAutoRecoveryEnabled(), + getAutoRecoveryPercentage()); if (getIsAutoRecoveryEnabled()) { List activeTeam = player.getTeamManager().getActiveTeam(); diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java index b8237fcea..7ff36ac7a 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java @@ -8,17 +8,14 @@ import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.data.*; import emu.grasscutter.utils.Utils; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public final class BlossomActivity { private final SceneGroup tempSceneGroup; - @Getter - private final WorldChallenge challenge; - @Getter - private final EntityGadget gadget; + @Getter private final WorldChallenge challenge; + @Getter private final EntityGadget gadget; private EntityGadget chest; private int step; private final int goal; diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java index d1f59bf99..9644553cd 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java @@ -203,7 +203,7 @@ public class BlossomManager { RewardPreviewData blossomRewards = getRewardList(type, worldLevel); if (blossomRewards == null) { Grasscutter.getLogger() - .error("Blossom could not support world level : {}", worldLevel); + .error("Blossom could not support world level : {}", worldLevel); return null; } var rewards = blossomRewards.getPreviewItems(); diff --git a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java index 793bfdcab..b24eadbfc 100644 --- a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java +++ b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java @@ -18,7 +18,6 @@ import emu.grasscutter.server.packet.send.PacketCompoundDataNotify; import emu.grasscutter.server.packet.send.PacketGetCompoundDataRsp; import emu.grasscutter.server.packet.send.PacketPlayerCompoundMaterialRsp; import emu.grasscutter.utils.Utils; - import java.util.*; public class CookingCompoundManager extends BasePlayerManager { @@ -34,24 +33,33 @@ public class CookingCompoundManager extends BasePlayerManager { public static void initialize() { defaultUnlockedCompounds = new HashSet<>(); compoundGroups = new HashMap<>(); - GameData.getCompoundDataMap().forEach((id, compound) -> { - if (compound.isDefaultUnlocked()) { - defaultUnlockedCompounds.add(id); - } - compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); - }); + GameData.getCompoundDataMap() + .forEach( + (id, compound) -> { + if (compound.isDefaultUnlocked()) { + defaultUnlockedCompounds.add(id); + } + compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); + }); // TODO:Because we haven't implemented fishing feature,unlock all compounds related to // fish.Besides,it should be bound to player rather than manager. unlocked = new HashSet<>(defaultUnlockedCompounds); if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error - unlocked.addAll(compoundGroups.get(3)); + unlocked.addAll(compoundGroups.get(3)); } private synchronized List getCompoundQueueData() { - List compoundQueueData = new ArrayList<>(player.getActiveCookCompounds().size()); + List compoundQueueData = + new ArrayList<>(player.getActiveCookCompounds().size()); int currentTime = Utils.getCurrentSeconds(); for (var item : player.getActiveCookCompounds().values()) { - var data = CompoundQueueData.newBuilder().setCompoundId(item.getCompoundId()).setOutputCount(item.getOutputCount(currentTime)).setOutputTime(item.getOutputTime(currentTime)).setWaitCount(item.getWaitCount(currentTime)).build(); + var data = + CompoundQueueData.newBuilder() + .setCompoundId(item.getCompoundId()) + .setOutputCount(item.getOutputCount(currentTime)) + .setOutputTime(item.getOutputTime(currentTime)) + .setWaitCount(item.getWaitCount(currentTime)) + .build(); compoundQueueData.add(data); } return compoundQueueData; @@ -73,14 +81,16 @@ public class CookingCompoundManager extends BasePlayerManager { return; } // check whether the queue is full - if (activeCompounds.containsKey(id) && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { + if (activeCompounds.containsKey(id) + && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_COMPOUND_QUEUE_FULL_VALUE)); return; } // try to consume raw materials if (!player.getInventory().payItems(compound.getInputVec(), count)) { // TODO:I'm not sure whether retcode is correct. - player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); + player.sendPacket( + new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); return; } ActiveCookCompoundData c; @@ -92,7 +102,13 @@ public class CookingCompoundManager extends BasePlayerManager { c = new ActiveCookCompoundData(id, compound.getCostTime(), count, currentTime); activeCompounds.put(id, c); } - var data = CompoundQueueData.newBuilder().setCompoundId(id).setOutputCount(c.getOutputCount(currentTime)).setOutputTime(c.getOutputTime(currentTime)).setWaitCount(c.getWaitCount(currentTime)).build(); + var data = + CompoundQueueData.newBuilder() + .setCompoundId(id) + .setOutputCount(c.getOutputCount(currentTime)) + .setOutputTime(c.getOutputTime(currentTime)) + .setWaitCount(c.getWaitCount(currentTime)) + .build(); player.sendPacket(new PacketPlayerCompoundMaterialRsp(data)); } @@ -124,9 +140,20 @@ public class CookingCompoundManager extends BasePlayerManager { // give player the rewards if (success) { player.getInventory().addItems(allRewards.values(), ActionReason.Compound); - player.sendPacket(new PackageTakeCompoundOutputRsp(allRewards.values().stream().map(i -> ItemParam.newBuilder().setItemId(i.getItemId()).setCount(i.getCount()).build()).toList(), Retcode.RET_SUCC_VALUE)); + player.sendPacket( + new PackageTakeCompoundOutputRsp( + allRewards.values().stream() + .map( + i -> + ItemParam.newBuilder() + .setItemId(i.getItemId()) + .setCount(i.getCount()) + .build()) + .toList(), + Retcode.RET_SUCC_VALUE)); } else { - player.sendPacket(new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); + player.sendPacket( + new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java index 45fb27507..ebda78540 100644 --- a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java +++ b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java @@ -3,12 +3,9 @@ package emu.grasscutter.game.managers.deforestation; import lombok.Getter; public class HitTreeRecord { - /** - * -- GETTER -- - * get unique id - */ - @Getter - private final int unique; + /** -- GETTER -- get unique id */ + @Getter private final int unique; + private short count; // hit this tree times private long time; // last available hitting time diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java index b42c2e6ef..451b2d8ce 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java @@ -1,12 +1,10 @@ package emu.grasscutter.game.managers.energy; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class EnergyDropEntry { private int dropId; private List dropList; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java index 72d3763b3..420400b43 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java @@ -6,5 +6,4 @@ import lombok.Getter; public class EnergyDropInfo { private int ballId; private int count; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java index 981f87881..dd177d6db 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java @@ -45,8 +45,7 @@ public class EnergyManager extends BasePlayerManager { // Read the data we need for monster energy drops. try { DataLoader.loadList("EnergyDrop.json", EnergyDropEntry.class) - .forEach( - entry -> energyDropData.put(entry.getDropId(), entry.getDropList())); + .forEach(entry -> energyDropData.put(entry.getDropId(), entry.getDropList())); Grasscutter.getLogger().debug("Energy drop data successfully loaded."); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java index 80fbcc686..2642fd665 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java @@ -1,12 +1,10 @@ package emu.grasscutter.game.managers.energy; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class SkillParticleGenerationEntry { private int avatarId; private List amountList; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java index d46ee16ef..115e5d018 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java @@ -6,5 +6,4 @@ import lombok.Getter; public class SkillParticleGenerationInfo { private int value; private int chance; - } diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java index dedb26ac8..f6854a2b9 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java @@ -6,27 +6,15 @@ import lombok.Setter; @Entity public class ActiveForgeData { - @Setter - @Getter - private int forgeId; - @Setter - @Getter - private int avatarId; - @Setter - @Getter - private int count; + @Setter @Getter private int forgeId; + @Setter @Getter private int avatarId; + @Setter @Getter private int count; - @Setter - @Getter - private int startTime; - @Setter - @Getter - private int forgeTime; + @Setter @Getter private int startTime; + @Setter @Getter private int forgeTime; private int lastUnfinishedCount; - @Setter - @Getter - private boolean changed; + @Setter @Getter private boolean changed; public int getFinishedCount(int currentTime) { int timeDelta = currentTime - this.startTime; diff --git a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java index a8f05337c..9253a6cda 100644 --- a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java +++ b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java @@ -33,5 +33,4 @@ public class MapMark { this.mapMarkFromType = mapMarkPoint.getFromType(); this.questId = mapMarkPoint.getQuestId(); } - } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java index f724d5d5e..fa8d42c0f 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java @@ -63,15 +63,15 @@ public class PlayerCodex { MATERIAL_WIDGET, MATERIAL_EXCHANGE, MATERIAL_AVATAR_MATERIAL, - MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId)) - .ifPresent( - codexData -> { - if (this.getUnlockedMaterial().add(itemId)) { - this.player.save(); - this.player.sendPacket( - new PacketCodexDataUpdateNotify(4, codexData.getId())); - } - }); + MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable( + GameData.getCodexMaterialDataIdMap().get(itemId)) + .ifPresent( + codexData -> { + if (this.getUnlockedMaterial().add(itemId)) { + this.player.save(); + this.player.sendPacket(new PacketCodexDataUpdateNotify(4, codexData.getId())); + } + }); default -> {} } } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java index 1f3f1e1c8..35eab5b85 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.player; import dev.morphia.annotations.Entity; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Entity(useDiscriminator = false) public class PlayerCollectionRecords { @@ -58,6 +57,5 @@ public class PlayerCollectionRecords { this.configId = configId; this.expiredTime = expiredTime; } - } } diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 4fffba9a4..835e82d06 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -5,16 +5,14 @@ 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 lombok.Getter; import lombok.Setter; -import java.util.*; - @Getter @Entity public final class TeamInfo { - @Setter - private String name; + @Setter private String name; private final List avatars; public TeamInfo() { diff --git a/src/main/java/emu/grasscutter/game/props/ActionReason.java b/src/main/java/emu/grasscutter/game/props/ActionReason.java index 251aa6fbc..8e8a598f2 100644 --- a/src/main/java/emu/grasscutter/game/props/ActionReason.java +++ b/src/main/java/emu/grasscutter/game/props/ActionReason.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ActionReason { @@ -208,5 +207,4 @@ public enum ActionReason { public static ActionReason getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java index d5273f4e9..8f9141143 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java @@ -14,5 +14,4 @@ public enum BattlePassMissionRefreshType { BattlePassMissionRefreshType(int value) { this.value = value; } - } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java index 1abc80f1d..5cc877515 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java @@ -17,5 +17,4 @@ public enum BattlePassMissionStatus { this.value = value; this.missionStatus = missionStatus; // In case proto enum values change later } - } diff --git a/src/main/java/emu/grasscutter/game/props/CampTargetType.java b/src/main/java/emu/grasscutter/game/props/CampTargetType.java index 955b642cc..2b9eca324 100644 --- a/src/main/java/emu/grasscutter/game/props/CampTargetType.java +++ b/src/main/java/emu/grasscutter/game/props/CampTargetType.java @@ -2,10 +2,9 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum CampTargetType implements IntValueEnum { diff --git a/src/main/java/emu/grasscutter/game/props/ClimateType.java b/src/main/java/emu/grasscutter/game/props/ClimateType.java index 39ed137b0..582d13378 100644 --- a/src/main/java/emu/grasscutter/game/props/ClimateType.java +++ b/src/main/java/emu/grasscutter/game/props/ClimateType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ClimateType { diff --git a/src/main/java/emu/grasscutter/game/props/EnterReason.java b/src/main/java/emu/grasscutter/game/props/EnterReason.java index 683c486db..07d8ddf4c 100644 --- a/src/main/java/emu/grasscutter/game/props/EnterReason.java +++ b/src/main/java/emu/grasscutter/game/props/EnterReason.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum EnterReason { @@ -66,5 +65,4 @@ public enum EnterReason { public static EnterReason getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/EntityIdType.java b/src/main/java/emu/grasscutter/game/props/EntityIdType.java index 622069146..e6e672a28 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityIdType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityIdType.java @@ -1,8 +1,7 @@ package emu.grasscutter.game.props; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public enum EntityIdType { @@ -37,5 +36,4 @@ public enum EntityIdType { public static EntityType toEntityType(int entityId) { return map.getOrDefault(entityId, EntityType.None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/EntityType.java b/src/main/java/emu/grasscutter/game/props/EntityType.java index 883258582..42eae8ed3 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityType.java @@ -2,10 +2,9 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum EntityType implements IntValueEnum { @@ -104,5 +103,4 @@ public enum EntityType implements IntValueEnum { public static EntityType getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/FetterState.java b/src/main/java/emu/grasscutter/game/props/FetterState.java index 8ee65407d..1498a60be 100644 --- a/src/main/java/emu/grasscutter/game/props/FetterState.java +++ b/src/main/java/emu/grasscutter/game/props/FetterState.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum FetterState { @@ -38,5 +37,4 @@ public enum FetterState { public static FetterState getTypeByName(String name) { return stringMap.getOrDefault(name, NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/GrowCurve.java b/src/main/java/emu/grasscutter/game/props/GrowCurve.java index 4734350f7..a04c42205 100644 --- a/src/main/java/emu/grasscutter/game/props/GrowCurve.java +++ b/src/main/java/emu/grasscutter/game/props/GrowCurve.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum GrowCurve { @@ -99,5 +98,4 @@ public enum GrowCurve { public static GrowCurve getPropByName(String name) { return stringMap.getOrDefault(name, GROW_CURVE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java index 66eff8ed6..54cc2a6d1 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseOp.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; @Getter public enum ItemUseOp { @@ -53,9 +52,7 @@ public enum ItemUseOp { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -67,5 +64,4 @@ public enum ItemUseOp { public static ItemUseOp getTypeByValue(int value) { return map.getOrDefault(value, ITEM_USE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java index 5ad8671c2..07701f36a 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.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; @Getter public enum ItemUseTarget { @@ -17,9 +16,7 @@ public enum ItemUseTarget { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -31,5 +28,4 @@ public enum ItemUseTarget { public static ItemUseTarget getTypeByValue(int value) { return map.getOrDefault(value, ITEM_USE_TARGET_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/LifeState.java b/src/main/java/emu/grasscutter/game/props/LifeState.java index 52a0622e0..e708d534a 100644 --- a/src/main/java/emu/grasscutter/game/props/LifeState.java +++ b/src/main/java/emu/grasscutter/game/props/LifeState.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum LifeState { @@ -38,5 +37,4 @@ public enum LifeState { public static LifeState getTypeByName(String name) { return stringMap.getOrDefault(name, LIFE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/MonsterType.java b/src/main/java/emu/grasscutter/game/props/MonsterType.java index adc080d4b..f2b370377 100644 --- a/src/main/java/emu/grasscutter/game/props/MonsterType.java +++ b/src/main/java/emu/grasscutter/game/props/MonsterType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum MonsterType { @@ -40,5 +39,4 @@ public enum MonsterType { public static MonsterType getTypeByName(String name) { return stringMap.getOrDefault(name, MONSTER_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/RefreshType.java b/src/main/java/emu/grasscutter/game/props/RefreshType.java index 5df028a79..bf362f2b1 100644 --- a/src/main/java/emu/grasscutter/game/props/RefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/RefreshType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum RefreshType { diff --git a/src/main/java/emu/grasscutter/game/props/SceneType.java b/src/main/java/emu/grasscutter/game/props/SceneType.java index 48015a7e8..bf66d3277 100644 --- a/src/main/java/emu/grasscutter/game/props/SceneType.java +++ b/src/main/java/emu/grasscutter/game/props/SceneType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum SceneType { @@ -41,5 +40,4 @@ public enum SceneType { public static SceneType getTypeByName(String name) { return stringMap.getOrDefault(name, SCENE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java index a55e13f3b..00ebb0e34 100644 --- a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java +++ b/src/main/java/emu/grasscutter/game/props/ServerBuffType.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; @Getter public enum ServerBuffType { @@ -15,9 +14,7 @@ public enum ServerBuffType { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -29,5 +26,4 @@ public enum ServerBuffType { public static ServerBuffType getTypeByValue(int value) { return map.getOrDefault(value, SERVER_BUFF_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java index 36c855635..432f0b61b 100644 --- a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java +++ b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum WatcherTriggerType { @@ -333,5 +332,4 @@ public enum WatcherTriggerType { public static WatcherTriggerType getTypeByName(String name) { return stringMap.getOrDefault(name, TRIGGER_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/WeaponType.java b/src/main/java/emu/grasscutter/game/props/WeaponType.java index d70af53be..b43d1c7a4 100644 --- a/src/main/java/emu/grasscutter/game/props/WeaponType.java +++ b/src/main/java/emu/grasscutter/game/props/WeaponType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum WeaponType { @@ -56,5 +55,4 @@ public enum WeaponType { public static WeaponType getTypeByName(String name) { return stringMap.getOrDefault(name, WEAPON_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index d4b9e4839..b2e0b974a 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -294,8 +294,7 @@ public class GameQuest { public boolean rewind(boolean notifyDelete) { getMainQuest().getChildQuests().values().stream() .filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()) - .forEach( - q -> q.clearProgress(notifyDelete)); + .forEach(q -> q.clearProgress(notifyDelete)); clearProgress(notifyDelete); this.start(); return true; diff --git a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java index dd2e5cd91..ebb3bb903 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java @@ -3,7 +3,6 @@ package emu.grasscutter.game.quest.enums; import emu.grasscutter.Grasscutter; import java.util.*; import java.util.function.BooleanSupplier; - import lombok.Getter; import org.jetbrains.annotations.NotNull; @@ -91,5 +90,4 @@ public enum LogicType { } } } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java index 02019c360..39ffb7638 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java @@ -14,5 +14,4 @@ public enum ParentQuestState { ParentQuestState(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java index 9cb1faa83..c5d8bcb8d 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestCond implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java index 053b559e5..2851265bf 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestContent implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java index 2b14a98b2..6a339c084 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestExec implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java index d9bbac8d4..3c872a621 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java @@ -13,5 +13,4 @@ public enum QuestGuideType { QuestGuideType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java index db76cdf7d..ef59d1a10 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java @@ -12,5 +12,4 @@ public enum QuestShowType { QuestShowType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java index 692343835..04bf4dad2 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java @@ -23,5 +23,4 @@ public enum QuestState implements IntValueEnum { QuestState(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java index 8fa4d6e75..f0fda0812 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java @@ -18,5 +18,4 @@ public enum QuestType { QuestType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java index f5c7d14d1..6ae10e778 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java @@ -13,5 +13,4 @@ public enum ShowQuestGuideType { ShowQuestGuideType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java index 376d46326..ae9a2d348 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java @@ -12,5 +12,4 @@ public class ShopLimit { private int hasBought; private int hasBoughtInPeriod = 0; private int nextRefreshTime = 0; - } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index 71c6122ab..6f0edc176 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -9,15 +9,13 @@ import emu.grasscutter.data.excels.ShopGoodsData; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class ShopSystem extends BaseGameSystem { private static final int REFRESH_HOUR = 4; // In GMT+8 server private static final String TIME_ZONE = "Asia/Shanghai"; // GMT+8 Timezone - @Getter - private final Int2ObjectMap> shopData; + @Getter private final Int2ObjectMap> shopData; private final Int2ObjectMap> shopChestData; public ShopSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/game/shop/ShopTable.java b/src/main/java/emu/grasscutter/game/shop/ShopTable.java index 1cd9831a2..459f843b7 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopTable.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopTable.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.shop; +import java.util.*; import lombok.Getter; import lombok.Setter; -import java.util.*; - @Setter @Getter public class ShopTable { private int shopId; private List items = new ArrayList<>(); - } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index cdbfc22cd..47c9affc0 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -82,7 +82,10 @@ public class InventorySystem extends BaseGameSystem { val avatarData = avatar.getSkillDepot(); if (avatarData == null) { Grasscutter.getLogger() - .error("Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", player.getUid(), avatarId); + .error( + "Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", + player.getUid(), + avatarId); return 0; } int constItemId = avatarData.getTalentCostItemId(); diff --git a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java index a63cbf0f4..997c40ded 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java @@ -1,11 +1,10 @@ package emu.grasscutter.game.tower; import dev.morphia.annotations.Entity; +import java.util.*; import lombok.Getter; import lombok.Setter; -import java.util.*; - @Setter @Getter @Entity @@ -37,5 +36,4 @@ public class TowerLevelRecord { public int getStarCount() { return passedLevelMap.values().stream().mapToInt(Integer::intValue).sum(); } - } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java index fa4e653c0..a3f539b13 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.tower; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Setter @Getter public class TowerScheduleConfig { @@ -12,5 +11,4 @@ public class TowerScheduleConfig { private Date scheduleStartTime; private Date nextScheduleChangeTime; - } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java index 5369ecb40..0d28d1a70 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java @@ -4,9 +4,8 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.data.*; import emu.grasscutter.data.excels.tower.TowerScheduleData; import emu.grasscutter.server.game.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class TowerSystem extends BaseGameSystem { diff --git a/src/main/java/emu/grasscutter/game/world/GridPosition.java b/src/main/java/emu/grasscutter/game/world/GridPosition.java index 13caa8eaa..a90cc3159 100644 --- a/src/main/java/emu/grasscutter/game/world/GridPosition.java +++ b/src/main/java/emu/grasscutter/game/world/GridPosition.java @@ -10,8 +10,7 @@ import lombok.*; @Getter @Entity public final class GridPosition implements Serializable { - @Serial - private static final long serialVersionUID = -2001232300615923575L; + @Serial private static final long serialVersionUID = -2001232300615923575L; private int x; diff --git a/src/main/java/emu/grasscutter/game/world/Location.java b/src/main/java/emu/grasscutter/game/world/Location.java index 16ed72ae4..e25fa3b10 100644 --- a/src/main/java/emu/grasscutter/game/world/Location.java +++ b/src/main/java/emu/grasscutter/game/world/Location.java @@ -7,8 +7,7 @@ import lombok.*; @Getter @Entity public class Location extends Position { - @Transient - private Scene scene; + @Transient private Scene scene; public Location(Scene scene, Position position) { this.set(position); diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 6e3348e02..b885ec4c8 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -5,7 +5,6 @@ import com.google.gson.annotations.SerializedName; import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.VectorOuterClass.Vector; import emu.grasscutter.utils.Utils; - import java.io.Serial; import java.io.Serializable; import java.util.List; @@ -17,8 +16,7 @@ import lombok.experimental.Accessors; @Entity @Accessors(chain = true) public class Position implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public static final Position ZERO = new Position(0, 0, 0); public static final Position IDENTITY = new Position(0, 0); diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 53f028746..dca0f35d0 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -392,7 +392,8 @@ public class Scene { } public void updateEntity(GameEntity entity, VisionType type) { - this.broadcastPacket(new PacketSceneEntityUpdateNotify(Collections.singletonList(entity), type)); + this.broadcastPacket( + new PacketSceneEntityUpdateNotify(Collections.singletonList(entity), type)); } private static List> chopped(List list, final int L) { diff --git a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java index 949747717..91d4b4d71 100644 --- a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java +++ b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java @@ -7,45 +7,31 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; import emu.grasscutter.scripts.data.SceneGadget; import emu.grasscutter.scripts.data.SceneGroup; -import lombok.Getter; -import lombok.Setter; -import org.bson.types.ObjectId; - import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import lombok.Getter; +import lombok.Setter; +import org.bson.types.ObjectId; @Entity(value = "group_instances", useDiscriminator = false) public final class SceneGroupInstance { - @Id - private ObjectId id; + @Id private ObjectId id; - @Indexed - private int ownerUid; // This group is owned by the host player - @Getter - private int groupId; + @Indexed private int ownerUid; // This group is owned by the host player + @Getter private int groupId; - @Getter - private transient SceneGroup luaGroup; - @Getter - @Setter - private int targetSuiteId; - @Getter - @Setter - private int activeSuiteId; - @Getter - private final Set deadEntities; // Config_ids + @Getter private transient SceneGroup luaGroup; + @Getter @Setter private int targetSuiteId; + @Getter @Setter private int activeSuiteId; + @Getter private final Set deadEntities; // Config_ids private boolean isCached; - @Getter - private final Map cachedGadgetStates; - @Getter - private final Map cachedVariables; + @Getter private final Map cachedGadgetStates; + @Getter private final Map cachedVariables; - @Getter - @Setter - private int lastTimeRefreshed; + @Getter @Setter private int lastTimeRefreshed; public SceneGroupInstance(SceneGroup group, Player owner) { this.luaGroup = group; @@ -59,11 +45,11 @@ public final class SceneGroupInstance { this.cachedVariables = new ConcurrentHashMap<>(); this.isCached = - false; // This is true when the group is not loaded on scene but caches suite data + false; // This is true when the group is not loaded on scene but caches suite data } @Deprecated - // Morphia only! + // Morphia only! SceneGroupInstance() { this.cachedVariables = new ConcurrentHashMap<>(); this.deadEntities = new HashSet<>(); @@ -86,7 +72,7 @@ public final class SceneGroupInstance { public void cacheGadgetState(SceneGadget g, int state) { if (g.persistent) // Only cache when is persistent - cachedGadgetStates.put(g.config_id, state); + cachedGadgetStates.put(g.config_id, state); } public int getCachedGadgetState(SceneGadget g) { diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index ed32b1e1a..5e5a250b2 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -52,9 +52,7 @@ public class World implements Iterable { @Getter private final EntityWorld entity; private int nextEntityId = 0; private int nextPeerId = 0; - @Setter - @Getter - private int worldLevel; + @Setter @Getter private int worldLevel; @Getter private boolean isMultiplayer = false; @Getter private boolean timeLocked; diff --git a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java index 5dd2d10bf..b9c4e0dad 100644 --- a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java +++ b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java @@ -11,13 +11,13 @@ import emu.grasscutter.scripts.data.*; import emu.grasscutter.server.game.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; - import lombok.Getter; import org.luaj.vm2.LuaError; public class WorldDataSystem extends BaseGameSystem { @Getter private final Map chestInteractHandlerMap; // chestType-Handler + private final Map sceneInvestigationGroupMap; // public WorldDataSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index 438b98f89..5620a08c7 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -2,28 +2,20 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; +import java.io.*; import lombok.Getter; import lombok.Setter; -import java.io.*; - public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; - @Setter - @Getter - private int opcode; + @Setter @Getter private int opcode; private boolean shouldBuildHeader = false; - @Setter - @Getter - private byte[] header; - @Setter - @Getter - private byte[] data; + @Setter @Getter private byte[] header; + @Setter @Getter private byte[] data; // Encryption - @Setter - private boolean useDispatchKey; + @Setter private boolean useDispatchKey; public BasePacket(int opcode) { this.opcode = opcode; diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index 1c6cbdc5b..b98b2cc52 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -45,7 +45,7 @@ public abstract class Plugin { if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) { Grasscutter.getLogger() - .warn("Failed to create plugin data folder for {}", this.identifier.name); + .warn("Failed to create plugin data folder for {}", this.identifier.name); } } diff --git a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java index 852a28246..af2a99901 100644 --- a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java +++ b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java @@ -7,21 +7,19 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.http.*; import emu.grasscutter.server.scheduler.ServerTaskScheduler; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; /** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */ public final class ServerHelper { /** - * -- GETTER -- - * Gets the server hook instance. + * -- GETTER -- Gets the server hook instance. * * @return A {@link ServerHelper} singleton. */ - @Getter - private static ServerHelper instance; + @Getter private static ServerHelper instance; + private final GameServer gameServer; private final HttpServer httpServer; diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 30bb4fe3e..82317bb3d 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -36,8 +36,7 @@ import org.luaj.vm2.*; import org.luaj.vm2.lib.jse.CoerceJavaToLua; public class SceneScriptManager { - @Getter - private final Scene scene; + @Getter private final Scene scene; private final Map variables; private SceneMeta meta; private boolean isInit; @@ -56,13 +55,10 @@ public class SceneScriptManager { private final Map sceneGroups; private final Map sceneGroupsInstances; private final Map cachedSceneGroupsInstances; - @Getter - private ScriptMonsterTideService scriptMonsterTideService; - @Getter - private final ScriptMonsterSpawnService scriptMonsterSpawnService; + @Getter private ScriptMonsterTideService scriptMonsterTideService; + @Getter private final ScriptMonsterSpawnService scriptMonsterSpawnService; /** blockid - loaded groupSet */ - @Getter - private final Map> loadedGroupSetPerBlock; + @Getter private final Map> loadedGroupSetPerBlock; private static final Int2ObjectMap> groupGridsCache = new Int2ObjectOpenHashMap<>(); public static final ExecutorService eventExecutor; @@ -845,12 +841,12 @@ public class SceneScriptManager { public Future callEvent(@Nonnull ScriptArgs params) { /* - We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for - every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib - func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could - not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> - (remove) So we use thread pool to clean the stack to avoid this new issue. - */ + We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for + every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib + func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could + not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> + (remove) So we use thread pool to clean the stack to avoid this new issue. + */ return eventExecutor.submit(() -> this.realCallEvent(params)); } @@ -884,7 +880,7 @@ public class SceneScriptManager { } } catch (Throwable throwable) { Grasscutter.getLogger() - .error("Condition Trigger {} triggered exception", params.type, throwable); + .error("Condition Trigger {} triggered exception", params.type, throwable); } finally { // make sure it is removed ScriptLoader.getScriptLib().removeSceneScriptManager(); @@ -910,7 +906,7 @@ public class SceneScriptManager { return false; } catch (Throwable ex) { Grasscutter.getLogger() - .error("Condition Trigger {} triggered exception", trigger.getName(), ex); + .error("Condition Trigger {} triggered exception", trigger.getName(), ex); return false; } finally { ScriptLoader.getScriptLib().removeCurrentGroup(); diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java index eaea56215..530c38542 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java @@ -34,7 +34,8 @@ public class ScriptLoader { private static final Map> scriptsCache = new ConcurrentHashMap<>(); /** sceneId - SceneMeta */ - private static final Map> sceneMetaCache = new ConcurrentHashMap<>(); + private static final Map> sceneMetaCache = + new ConcurrentHashMap<>(); private static final AtomicReference currentBindings = new AtomicReference<>(null); private static final AtomicReference currentContext = new AtomicReference<>(null); diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index 782ef2a8c..c7fce1d9e 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -22,9 +22,7 @@ public class SceneBlock { public Map groups; public RTree sceneGroupIndex; - @Setter - @Getter - private transient boolean loaded; // Not an actual variable in the scripts either + @Setter @Getter private transient boolean loaded; // Not an actual variable in the scripts either public boolean contains(Position pos) { int range = Grasscutter.getConfig().server.game.loadEntitiesForPlayerRange; @@ -67,7 +65,8 @@ public class SceneBlock { SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint()); } catch (ScriptException exception) { Grasscutter.getLogger() - .error("An error occurred while loading block {} in scene {}", this.id, sceneId, exception); + .error( + "An error occurred while loading block {} in scene {}", this.id, sceneId, exception); } Grasscutter.getLogger().trace("Successfully loaded block {} in scene {}.", this.id, sceneId); return this; diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java index 8cd7d6d9c..1681cd919 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java @@ -24,8 +24,7 @@ public class SceneGadget extends SceneObject { * isOneOff=false, like investigation points, it will disappear temporarily, and appear again in * next big world resource refresh routine. */ - @Setter - public boolean isOneoff; + @Setter public boolean isOneoff; public int draft_id; public int route_id; @@ -35,5 +34,4 @@ public class SceneGadget extends SceneObject { public int mark_flag; public Explore explore; public int trigger_count; - } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index ccfe70b82..a32318f81 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -3,7 +3,6 @@ package emu.grasscutter.scripts.data; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.Position; import emu.grasscutter.scripts.ScriptLoader; - import java.util.*; import java.util.stream.Collectors; import javax.script.*; @@ -37,13 +36,9 @@ public final class SceneGroup { public SceneReplaceable is_replaceable; /* These are not script variables. */ - @Setter - @Getter - private transient boolean loaded; - @Getter - private transient CompiledScript script; - @Getter - private transient Bindings bindings; + @Setter @Getter private transient boolean loaded; + @Getter private transient CompiledScript script; + @Getter private transient Bindings bindings; public String overrideScriptPath; public static SceneGroup of(int groupId) { @@ -156,7 +151,7 @@ public final class SceneGroup { this.suites.forEach(i -> i.init(this)); } catch (ScriptException e) { Grasscutter.getLogger() - .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e); + .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e); } catch (LuaError luaError) { Grasscutter.getLogger() .error( diff --git a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java index 883c66e0b..bf26d1705 100644 --- a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java +++ b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java @@ -5,12 +5,9 @@ import lombok.ToString; @ToString public class ScriptArgs { - @Getter - public int param1; - @Getter - public int param2; - @Getter - public int param3; + @Getter public int param1; + @Getter public int param2; + @Getter public int param3; public int source_eid; // Source entity public int target_eid; public int group_id; diff --git a/src/main/java/emu/grasscutter/server/event/EventHandler.java b/src/main/java/emu/grasscutter/server/event/EventHandler.java index d9b0450b3..b47c91210 100644 --- a/src/main/java/emu/grasscutter/server/event/EventHandler.java +++ b/src/main/java/emu/grasscutter/server/event/EventHandler.java @@ -59,13 +59,12 @@ public final class EventHandler { private final Class eventClass; private EventConsumer listener; /** - * -- GETTER -- - * Returns the handler's priority. + * -- GETTER -- Returns the handler's priority. * * @return The priority of the handler. */ - @Getter - private HandlerPriority priority; + @Getter private HandlerPriority priority; + private boolean handleCanceled; private Plugin plugin; diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java index c54b4750c..b386331de 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java @@ -14,5 +14,4 @@ public final class QueryAllRegionsEvent extends ServerEvent { this.regionList = regionList; } - } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java index b6c0a0cff..8054cc223 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java @@ -14,5 +14,4 @@ public final class QueryCurrentRegionEvent extends ServerEvent { this.regionInfo = regionInfo; } - } diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java index 410458818..fedda674d 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java @@ -19,5 +19,4 @@ public final class EntityMoveEvent extends EntityEvent { this.rotation = rotation; this.motionState = motionState; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java index 699105d16..e94aca6f4 100644 --- a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java @@ -9,12 +9,10 @@ import lombok.Setter; @Getter public final class PlayerCreationEvent extends GameEvent { private final GameSession session; - @Setter - private Class playerClass; + @Setter private Class playerClass; public PlayerCreationEvent(GameSession session, Class playerClass) { this.session = session; this.playerClass = playerClass; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java index fc6f247cc..7080641a1 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java @@ -3,16 +3,13 @@ package emu.grasscutter.server.event.game; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; +import javax.annotation.Nullable; import lombok.Getter; import lombok.Setter; -import javax.annotation.Nullable; - public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Cancellable { @Nullable private final Player player; - @Setter - @Getter - private String message; + @Setter @Getter private String message; public ReceiveCommandFeedbackEvent(@Nullable Player player, String message) { super(Type.GAME); diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java index 9419aef77..092dab884 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java @@ -10,8 +10,7 @@ import lombok.Setter; public final class ReceivePacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; private final int packetId; - @Setter - private byte[] packetData; + @Setter private byte[] packetData; public ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetData) { super(Type.GAME); @@ -20,5 +19,4 @@ public final class ReceivePacketEvent extends ServerEvent implements Cancellable this.packetId = packetId; this.packetData = packetData; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java index 9d6d724ca..cd194a7aa 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java @@ -10,8 +10,7 @@ import lombok.Setter; @Getter public final class SendPacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; - @Setter - private BasePacket packet; + @Setter private BasePacket packet; public SendPacketEvent(GameSession gameSession, BasePacket packet) { super(Type.GAME); @@ -19,5 +18,4 @@ public final class SendPacketEvent extends ServerEvent implements Cancellable { this.gameSession = gameSession; this.packet = packet; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java index 121271b9f..355e5f18a 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java @@ -15,5 +15,4 @@ public final class ServerLogEvent extends ServerEvent { this.loggingEvent = loggingEvent; this.consoleMessage = consoleMessage; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java index e9951098b..92c1abac0 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java @@ -1,9 +1,8 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; -import lombok.Getter; - import java.time.OffsetDateTime; +import lombok.Getter; @Getter public final class ServerStartEvent extends ServerEvent { @@ -14,5 +13,4 @@ public final class ServerStartEvent extends ServerEvent { this.startTime = startTime; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java index eff1b97c7..0f577a875 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java @@ -1,9 +1,8 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; -import lombok.Getter; - import java.time.OffsetDateTime; +import lombok.Getter; @Getter public final class ServerStopEvent extends ServerEvent { @@ -14,5 +13,4 @@ public final class ServerStopEvent extends ServerEvent { this.stopTime = stopTime; } - } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java index 05f440733..c24caccd6 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java @@ -11,8 +11,7 @@ import lombok.Setter; @Getter public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellable { private final GadgetChest chest; - @Setter - private ChestReward reward; + @Setter private ChestReward reward; public PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward) { super(player); @@ -20,5 +19,4 @@ public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellab this.chest = chest; this.reward = reward; } - } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java index 7cfe831aa..c040bfe4a 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java @@ -17,5 +17,4 @@ public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancell this.message = message; } - } diff --git a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java index 12948bdbf..51546dd96 100644 --- a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java @@ -12,5 +12,4 @@ public abstract class EntityEvent extends Event { public EntityEvent(GameEntity entity) { this.entity = entity; } - } diff --git a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java index b506f95e5..f59a18e98 100644 --- a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java @@ -12,5 +12,4 @@ public abstract class PlayerEvent extends Event { public PlayerEvent(Player player) { this.player = player; } - } diff --git a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java index 883cd2b7f..c7e9bbdb6 100644 --- a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java +++ b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java @@ -9,5 +9,4 @@ public abstract class BaseGameSystem { public BaseGameSystem(GameServer server) { this.server = server; } - } diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index d1e47b54d..13cd482be 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.game; +import static emu.grasscutter.config.Configuration.GAME_INFO; + import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.net.packet.Opcodes; @@ -11,8 +13,6 @@ import emu.grasscutter.server.game.GameSession.SessionState; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import static emu.grasscutter.config.Configuration.GAME_INFO; - public final class GameServerPacketHandler { private final Int2ObjectMap handlers; @@ -33,7 +33,7 @@ public final class GameServerPacketHandler { this.handlers.put(opcode.value(), packetHandler); } catch (Exception e) { Grasscutter.getLogger() - .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); + .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); } } @@ -45,7 +45,7 @@ public final class GameServerPacketHandler { // Debug Grasscutter.getLogger() - .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName()); + .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName()); } public void handle(GameSession session, int opcode, byte[] header, byte[] payload) { @@ -83,7 +83,7 @@ public final class GameServerPacketHandler { ReceivePacketEvent event = new ReceivePacketEvent(session, opcode, payload); event.call(); if (!event.isCanceled()) // If event is not canceled, continue. - handler.handle(session, header, event.getPacketData()); + handler.handle(session, header, event.getPacketData()); } catch (Exception ex) { // TODO Remove this when no more needed ex.printStackTrace(); @@ -93,9 +93,9 @@ public final class GameServerPacketHandler { // Log unhandled packets if (GAME_INFO.logPackets == ServerDebugMode.MISSING - || GAME_INFO.logPackets == ServerDebugMode.ALL) { + || GAME_INFO.logPackets == ServerDebugMode.ALL) { Grasscutter.getLogger() - .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); + .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); } } } diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 092bf72d3..a3ffdf8af 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -17,8 +17,7 @@ import java.nio.file.Path; import lombok.*; public class GameSession implements GameSessionManager.KcpChannel { - @Getter - private final GameServer server; + @Getter private final GameServer server; private GameSessionManager.KcpTunnel tunnel; @Getter @Setter private Account account; @@ -96,7 +95,7 @@ public class GameSession implements GameSessionManager.KcpChannel { public void logPacket(String sendOrRecv, int opcode, byte[] payload) { Grasscutter.getLogger() - .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode); + .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode); if (GAME_INFO.isShowPacketPayload) System.out.println(Utils.bytesToHex(payload)); } diff --git a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java index ed1b292ff..6d8702e62 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java +++ b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java @@ -12,6 +12,7 @@ import lombok.Getter; public class GameSessionManager { @Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop(); private static final ConcurrentHashMap sessions = new ConcurrentHashMap<>(); + @Getter private static final KcpListener listener = new KcpListener() { diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index cc29fbe28..be8d4cc8b 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -22,7 +22,6 @@ import java.time.Instant; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; - import lombok.Getter; import org.slf4j.Logger; @@ -332,7 +331,6 @@ public final class RegionHandler implements Router { this.regionQuery = prq; this.base64 = b64; } - } /** diff --git a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java index 70e3f053a..f7a37c8f2 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java +++ b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java @@ -38,11 +38,14 @@ public final class HttpJsonResponse implements Handler { && Arrays.stream(missingRoutes) .anyMatch(x -> Objects.equals(x, ctx.endpointHandlerPath()))) { Grasscutter.getLogger() - .info("{}{}", translate( - "messages.dispatch.request", - Utils.address(ctx), - ctx.method(), - ctx.endpointHandlerPath()), DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""); + .info( + "{}{}", + translate( + "messages.dispatch.request", + Utils.address(ctx), + ctx.method(), + ctx.endpointHandlerPath()), + DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""); } ctx.result(response); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java index 3e2947662..0764d4aa2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java @@ -48,8 +48,7 @@ public class HandlerBuyGoodsReq extends PacketHandler { return; } - List costs = - new ArrayList<>(sg.getCostItemList()); // Can this even be null? + List costs = new ArrayList<>(sg.getCostItemList()); // Can this even be null? costs.add(new ItemParamData(202, sg.getScoin())); costs.add(new ItemParamData(201, sg.getHcoin())); costs.add(new ItemParamData(203, sg.getMcoin())); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java index ffd1724f7..bcddf0283 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -129,7 +129,11 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { int maxDelay = 200; long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond; Grasscutter.getLogger() - .trace("MOTION_FALL_ON_GROUND received after {}/{}ms.{}", actualDelay, maxDelay, actualDelay > maxDelay ? " Discard" : ""); + .trace( + "MOTION_FALL_ON_GROUND received after {}/{}ms.{}", + actualDelay, + maxDelay, + actualDelay > maxDelay ? " Discard" : ""); if (actualDelay > maxDelay) { return; } @@ -155,7 +159,14 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { } if (damageFactor > 0) { Grasscutter.getLogger() - .debug("{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", currentHP, maxHP, cachedLandingSpeed, damageFactor, damage, newHP); + .debug( + "{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", + currentHP, + maxHP, + cachedLandingSpeed, + damageFactor, + damage, + newHP); } else { Grasscutter.getLogger().trace("{}/{}\tLandingSpeed: 0\tNo damage", currentHP, maxHP); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java index f0b084f27..607992c69 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java @@ -17,11 +17,12 @@ public class HandlerHomeKickPlayerReq extends PacketHandler { .filter(player -> player.getUid() == req.getTargetUid()) .findFirst() .ifPresent( - player -> success.set( - session - .getServer() - .getHomeWorldMPSystem() - .kickPlayerFromHome(session.getPlayer(), player.getUid()))); + player -> + success.set( + session + .getServer() + .getHomeWorldMPSystem() + .kickPlayerFromHome(session.getPlayer(), player.getUid()))); session.send( new PacketHomeKickPlayerRsp( diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java index b4752b421..55f9ed0a2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java @@ -46,6 +46,5 @@ public class HandlerSetPlayerBirthdayReq extends PacketHandler { case 2 -> day > 0 & day <= 29; default -> false; }; - } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index e2425fc36..d820ce47c 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -44,19 +44,19 @@ public class HandlerTryEnterHomeReq extends PacketHandler { } case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption .FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> session.send( - new PacketTryEnterHomeRsp( - RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, - req.getTargetUid())); + new PacketTryEnterHomeRsp( + RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, + req.getTargetUid())); case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> session - .getServer() - .getHomeWorldMPSystem() - .enterHome( - session.getPlayer(), - targetPlayer, - req.getTargetPoint(), - req.getIsTransferToSafePoint()); + .getServer() + .getHomeWorldMPSystem() + .enterHome( + session.getPlayer(), + targetPlayer, + req.getTargetPoint(), + req.getIsTransferToSafePoint()); } return; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java index f50d1b022..e27ee0fe2 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java @@ -14,14 +14,15 @@ public class PacketActivityScheduleInfoNotify extends BasePacket { var proto = ActivityScheduleInfoNotifyOuterClass.ActivityScheduleInfoNotify.newBuilder(); activityConfigItemList.forEach( - item -> proto.addActivityScheduleList( - ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() - .setActivityId(item.getActivityId()) - .setScheduleId(item.getScheduleId()) - .setIsOpen(true) - .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) - .setEndTime(DateHelper.getUnixTime(item.getEndTime())) - .build())); + item -> + proto.addActivityScheduleList( + ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() + .setActivityId(item.getActivityId()) + .setScheduleId(item.getScheduleId()) + .setIsOpen(true) + .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) + .setEndTime(DateHelper.getUnixTime(item.getEndTime())) + .build())); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java index 74a02ea09..a5679f024 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java @@ -21,8 +21,7 @@ public class PacketBattlePassMissionUpdateNotify extends BasePacket { var proto = BattlePassMissionUpdateNotify.newBuilder(); - missions.forEach( - mission -> proto.addMissionList(mission.toProto())); + missions.forEach(mission -> proto.addMissionList(mission.toProto())); this.setData(proto.build()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java index 67e464d03..4ddc149e6 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java @@ -93,9 +93,10 @@ public class PacketCodexDataFullNotify extends BasePacket { .getCodex() .getUnlockedReliquarySuitCodex() .forEach( - reliquarySuit -> reliquaryData - .addCodexIdList(reliquarySuit) - .addAllHaveViewedList(Collections.singleton(true))); + reliquarySuit -> + reliquaryData + .addCodexIdList(reliquarySuit) + .addAllHaveViewedList(Collections.singleton(true))); CodexDataFullNotify.Builder proto = CodexDataFullNotify.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java index 2d6403e42..1b8787063 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java @@ -26,25 +26,24 @@ public class PacketCreateVehicleRsp extends BasePacket { && ((EntityVehicle) entity).getOwner().equals(player)) .toList(); - previousVehicles - .forEach( - entity -> { - List vehicleMembers = - ((EntityVehicle) entity).getVehicleMembers().stream().toList(); + previousVehicles.forEach( + entity -> { + List vehicleMembers = + ((EntityVehicle) entity).getVehicleMembers().stream().toList(); - vehicleMembers - .forEach( - vehicleMember -> player - .getScene() - .broadcastPacket( - new PacketVehicleInteractRsp( - ((EntityVehicle) entity), - vehicleMember, - VehicleInteractTypeOuterClass.VehicleInteractType - .VEHICLE_INTERACT_TYPE_OUT))); + vehicleMembers.forEach( + vehicleMember -> + player + .getScene() + .broadcastPacket( + new PacketVehicleInteractRsp( + ((EntityVehicle) entity), + vehicleMember, + VehicleInteractTypeOuterClass.VehicleInteractType + .VEHICLE_INTERACT_TYPE_OUT))); - player.getScene().killEntity(entity, 0); - }); + player.getScene().killEntity(entity, 0); + }); EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java index 402e13aed..65513c620 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java @@ -15,11 +15,11 @@ public class PacketMailChangeNotify extends BasePacket { public PacketMailChangeNotify(Player player, Mail message) { this( player, - new ArrayList<>() { - { - add(message); - } - }); + new ArrayList<>() { + { + add(message); + } + }); } public PacketMailChangeNotify(Player player, List mailList) { diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java index 6d25619cd..47d4124f8 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java @@ -20,8 +20,9 @@ public class PacketPlayerDataNotify extends BasePacket { player .getProperties() .forEach( - (key, value) -> p.putPropMap( - key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build())); + (key, value) -> + p.putPropMap( + key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build())); this.setData(p.build()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java index f1df152c9..1853b681b 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java @@ -37,7 +37,9 @@ public class PacketVehicleInteractRsp extends BasePacket { QuestContent.QUEST_CONTENT_ENTER_VEHICLE, ((EntityVehicle) vehicle).getGadgetId()); } - case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember); + case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle) + .getVehicleMembers() + .remove(vehicleMember); default -> {} } } diff --git a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java index b152bdeb6..fca50cfb2 100644 --- a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java +++ b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java @@ -15,14 +15,12 @@ public final class AsyncServerTask implements Runnable { /* Has the task already been started? */ private boolean started = false; /** - * -- GETTER -- - * Returns the state of the task. + * -- GETTER -- Returns the state of the task. * * @return True if the task has finished execution, false otherwise. */ /* Has the task finished execution? */ - @Getter - private boolean finished = false; + @Getter private boolean finished = false; /* The result produced in the async task. */ @Nullable private Object result = null; diff --git a/src/main/java/emu/grasscutter/task/TaskMap.java b/src/main/java/emu/grasscutter/task/TaskMap.java index af98a46ea..22f42d616 100644 --- a/src/main/java/emu/grasscutter/task/TaskMap.java +++ b/src/main/java/emu/grasscutter/task/TaskMap.java @@ -154,12 +154,12 @@ public final class TaskMap { this.afterReset.put(taskData.taskName(), (TaskHandler) object); } } else { - Grasscutter.getLogger() - .error("Class {} is not a TaskHandler!", annotated.getName()); + Grasscutter.getLogger().error("Class {} is not a TaskHandler!", annotated.getName()); } } catch (Exception exception) { Grasscutter.getLogger() - .error("Failed to register task handler for {}", annotated.getSimpleName(), exception); + .error( + "Failed to register task handler for {}", annotated.getSimpleName(), exception); } }); try { diff --git a/src/main/java/emu/grasscutter/tools/Dumpers.java b/src/main/java/emu/grasscutter/tools/Dumpers.java index 47c0e663b..a21579830 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ public interface Dumpers { Language.getTextMapKey(item.getNameTextMapHash()).get(locale), Quality.from(item.getRankLevel()), item.getItemType(), - !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); + !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); // Create a new dump with filtered duplicates. var names = new ArrayList(); diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index a8e62ab54..5cdaaa13f 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -54,7 +54,8 @@ public final class Tools { GameData.getMainQuestDataMap().int2ObjectEntrySet().stream() .collect( Collectors.toMap( - Int2ObjectMap.Entry::getIntKey, e -> (int) e.getValue().getTitleTextMapHash()))); + Int2ObjectMap.Entry::getIntKey, + e -> (int) e.getValue().getTitleTextMapHash()))); // val questDescs = new // Int2IntRBTreeMap(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash()))); @@ -189,10 +190,11 @@ public final class Tools { achievementDataMap.values().stream() .filter(AchievementData::isUsed) .forEach( - data -> h.newTranslatedLine( - padAchievementId.formatted(data.getId()) + "{0} - {1}", - data.getTitleTextMapHash(), - data.getDescTextMapHash())); + data -> + h.newTranslatedLine( + padAchievementId.formatted(data.getId()) + "{0} - {1}", + data.getTitleTextMapHash(), + data.getDescTextMapHash())); // Write txt files for (int i = 0; i < TextStrings.NUM_LANGUAGES; i++) { @@ -350,12 +352,13 @@ public final class Tools { try { Files.newDirectoryStream(getResourcePath("TextMap"), "TextMap*.json") .forEach( - path -> availableLangList.add( - path.getFileName() - .toString() - .replace("TextMap", "") - .replace(".json", "") - .toLowerCase())); + path -> + availableLangList.add( + path.getFileName() + .toString() + .replace("TextMap", "") + .replace(".json", "") + .toLowerCase())); } catch (IOException e) { Grasscutter.getLogger().error("Failed to get available languages:", e); } diff --git a/src/main/java/emu/grasscutter/utils/FileUtils.java b/src/main/java/emu/grasscutter/utils/FileUtils.java index 21566bd75..eebacc014 100644 --- a/src/main/java/emu/grasscutter/utils/FileUtils.java +++ b/src/main/java/emu/grasscutter/utils/FileUtils.java @@ -41,7 +41,7 @@ public final class FileUtils { break; default: Grasscutter.getLogger() - .error("Invalid URI scheme for class resources: {}", uri.getScheme()); + .error("Invalid URI scheme for class resources: {}", uri.getScheme()); break; } } catch (URISyntaxException | IOException e) { @@ -82,10 +82,10 @@ public final class FileUtils { path = excelBinOutput.get().getParent(); if (path == null) path = root; Grasscutter.getLogger() - .debug("Resources will be loaded from \"" + resources + "/{}\"", path); + .debug("Resources will be loaded from \"" + resources + "/{}\"", path); } else { Grasscutter.getLogger() - .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); + .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); } } catch (IOException e) { Grasscutter.getLogger().error("Failed to scan resources zip \"" + resources + "\""); diff --git a/src/main/java/emu/grasscutter/utils/JsonAdapters.java b/src/main/java/emu/grasscutter/utils/JsonAdapters.java index d5f765bee..8f0920027 100644 --- a/src/main/java/emu/grasscutter/utils/JsonAdapters.java +++ b/src/main/java/emu/grasscutter/utils/JsonAdapters.java @@ -13,13 +13,12 @@ import emu.grasscutter.game.world.Position; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import lombok.val; - import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.Objects; +import lombok.val; public interface JsonAdapters { class DynamicFloatAdapter extends TypeAdapter { @@ -40,25 +39,24 @@ public interface JsonAdapters { val opStack = new ArrayList(); while (reader.hasNext()) { opStack.add( - switch (reader.peek()) { - case STRING -> new DynamicFloat.StackOp(reader.nextString()); - case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); - case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); - default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); - }); + switch (reader.peek()) { + case STRING -> new DynamicFloat.StackOp(reader.nextString()); + case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); + case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); + default -> throw new IOException( + "Invalid DynamicFloat definition - " + reader.peek().name()); + }); } reader.endArray(); return new DynamicFloat(opStack); } default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); + "Invalid DynamicFloat definition - " + reader.peek().name()); } } @Override - public void write(JsonWriter writer, DynamicFloat f) { - } + public void write(JsonWriter writer, DynamicFloat f) {} } class IntListAdapter extends TypeAdapter { @@ -80,7 +78,7 @@ public interface JsonAdapters { public void write(JsonWriter writer, IntList l) throws IOException { writer.beginArray(); for (val i : l) // .forEach() doesn't appreciate exceptions - writer.value(i); + writer.value(i); writer.endArray(); } } @@ -117,7 +115,7 @@ public interface JsonAdapters { throw new IOException("Invalid GridPosition definition - " + in.peek().name()); return new GridPosition( - Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); + Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); } } diff --git a/src/main/java/emu/grasscutter/utils/TsvUtils.java b/src/main/java/emu/grasscutter/utils/TsvUtils.java index 16fc75941..5381059e5 100644 --- a/src/main/java/emu/grasscutter/utils/TsvUtils.java +++ b/src/main/java/emu/grasscutter/utils/TsvUtils.java @@ -228,7 +228,9 @@ public final class TsvUtils { return tree.toClass(classType, null); } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + .warn( + "Error deserializing an instance of class {}", + classType.getCanonicalName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger().warn("Tokens are: {}", tokens); @@ -283,7 +285,9 @@ public final class TsvUtils { return obj; } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + .warn( + "Error deserializing an instance of class {}", + classType.getCanonicalName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger().warn("Tokens are: {}", tokens); @@ -294,14 +298,16 @@ public final class TsvUtils { .toList(); } catch (NoSuchFileException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", filename); + .error( + "Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", + filename); return null; } catch (IOException e) { Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } catch (NoSuchMethodException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename); + .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename); return null; } } @@ -398,20 +404,25 @@ public final class TsvUtils { return constructor.newInstance(args); } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {} : {}", classType.getCanonicalName(), constructor.getName()); + .warn( + "Error deserializing an instance of class {} : {}", + classType.getCanonicalName(), + constructor.getName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger() - .warn("Arg names are: {}", Arrays.toString(conArgNames)); + .warn("Arg names are: {}", Arrays.toString(conArgNames)); Grasscutter.getLogger() - .warn("Arg types are: {}", Arrays.toString(argTypes)); + .warn("Arg types are: {}", Arrays.toString(argTypes)); Grasscutter.getLogger() - .warn("Default Args are: {}", Arrays.toString(defaultArgs)); + .warn("Default Args are: {}", Arrays.toString(defaultArgs)); Grasscutter.getLogger().warn("Args are: {}", Arrays.toString(args)); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger() - .warn("Header types are: {}", IntStream.of(argPositions) - .mapToObj(i -> (i >= 0) ? argTypes[i] : null) - .toList()); + .warn( + "Header types are: {}", + IntStream.of(argPositions) + .mapToObj(i -> (i >= 0) ? argTypes[i] : null) + .toList()); Grasscutter.getLogger().warn("Tokens are: {}", tokens); Grasscutter.getLogger().warn("Stacktrace is: ", e); return null; @@ -420,7 +431,7 @@ public final class TsvUtils { .toList(); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - Stacktrace is: ", filename, e); + .error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } }) @@ -569,14 +580,19 @@ public final class TsvUtils { // System.out.println("Exception while setting field "+name+" for class "+objClass+" // - "+e); Grasscutter.getLogger() - .error("Exception while setting field {} ({}) for class {} - ", name, field.classType, objClass, e); + .error( + "Exception while setting field {} ({}) for class {} - ", + name, + field.classType, + objClass, + e); } }); return obj; } catch (Exception e) { // System.out.println("Exception while creating object of class "+objClass+" - "+e); Grasscutter.getLogger() - .error("Exception while creating object of class {} - ", objClass, e); + .error("Exception while creating object of class {} - ", objClass, e); return null; } } diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index e4fc8c0e7..5e7729460 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -151,7 +151,7 @@ public final class Utils { return true; } catch (Exception exception) { Grasscutter.getLogger() - .warn("Unable to copy resource {} to {}", resource, destination, exception); + .warn("Unable to copy resource {} to {}", resource, destination, exception); return false; } } diff --git a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java index 6a0f4e1dd..c7bc42a80 100644 --- a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java +++ b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java @@ -57,8 +57,7 @@ public class KahnsSort { } } - if (degreeList.values().stream().anyMatch(value -> value != 0)) - return null; // Loop found + if (degreeList.values().stream().anyMatch(value -> value != 0)) return null; // Loop found return orderedList; } diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 293ecd4be..5c3b1c968 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -29,12 +29,9 @@ public final class Language { private static boolean scannedTextmaps = false; // Ensure that we don't infinitely rescan on cache misses that don't exist private static Int2ObjectMap textMapStrings; - /** - * -- GETTER -- - * get language code - */ - @Getter - private final String languageCode; + /** -- GETTER -- get language code */ + @Getter private final String languageCode; + private final Map translations = new ConcurrentHashMap<>(); /** Reads a file and creates a language instance. */ @@ -50,7 +47,7 @@ public final class Language { .forEach(entry -> putFlattenedKey(translations, entry.getKey(), entry.getValue())); } catch (Exception exception) { Grasscutter.getLogger() - .warn("Failed to load language file: {}", description.getLanguageCode(), exception); + .warn("Failed to load language file: {}", description.getLanguageCode(), exception); } } @@ -200,7 +197,7 @@ public final class Language { if (file == null) { // Provided fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback); + .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback); actualLanguageCode = fallbackLanguageCode; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -211,7 +208,7 @@ public final class Language { if (file == null) { // Fallback the fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: {}, falling back to: en-US.json", fallback); + .warn("Failed to load language file: {}, falling back to: en-US.json", fallback); actualLanguageCode = "en-US"; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -259,30 +256,27 @@ public final class Language { TextStrings.LIST_LANGUAGES.parallelStream() .collect( Collectors.toConcurrentMap( - TextStrings.MAP_LANGUAGES::getInt, - s -> loadTextMapFile(s, nameHashes))); + TextStrings.MAP_LANGUAGES::getInt, s -> loadTextMapFile(s, nameHashes))); List> languageMaps = - IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(mapLanguageMaps::get) - .toList(); + IntStream.range(0, TextStrings.NUM_LANGUAGES).mapToObj(mapLanguageMaps::get).toList(); Map canonicalTextStrings = new HashMap<>(); return new Int2ObjectOpenHashMap<>( - nameHashes - .intStream() - .boxed() - .collect( - Collectors.toMap( - key -> key, - key -> { - TextStrings t = - new TextStrings( - IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(i -> languageMaps.get(i).get((int) key)) - .collect(Collectors.toList()), - key); - return canonicalTextStrings.computeIfAbsent(t, x -> t); - }))); + nameHashes + .intStream() + .boxed() + .collect( + Collectors.toMap( + key -> key, + key -> { + TextStrings t = + new TextStrings( + IntStream.range(0, TextStrings.NUM_LANGUAGES) + .mapToObj(i -> languageMaps.get(i).get((int) key)) + .collect(Collectors.toList()), + key); + return canonicalTextStrings.computeIfAbsent(t, x -> t); + }))); } @SuppressWarnings("unchecked") diff --git a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java index 5b6b8abc0..3ac2e49f8 100644 --- a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java +++ b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java @@ -4,11 +4,10 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.encoder.Encoder; import emu.grasscutter.server.event.internal.ServerLogEvent; +import java.nio.charset.StandardCharsets; import lombok.Getter; import lombok.Setter; -import java.nio.charset.StandardCharsets; - @Setter @Getter public final class ServerLogEventAppender extends AppenderBase { @@ -21,5 +20,4 @@ public final class ServerLogEventAppender extends AppenderBase { new ServerLogEvent((ILoggingEvent) event, new String(byteArray, StandardCharsets.UTF_8)); sle.call(); } - } From bfc2c7c0964665aff0eabf4909620615629f8794 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 11:59:03 -0300 Subject: [PATCH 47/59] refactor: fix lombok --- .../data/excels/RewardPreviewData.java | 2 +- .../data/excels/quest/QuestData.java | 1 - .../reliquary/ReliquaryMainPropData.java | 2 +- .../data/excels/scene/SceneData.java | 2 +- .../data/excels/scene/SceneTagData.java | 2 +- .../trial/TrialAvatarActivityDataData.java | 2 +- .../grasscutter/game/friends/FriendsList.java | 4 +- .../grasscutter/game/inventory/Inventory.java | 188 +++++++++--------- .../grasscutter/net/packet/BasePacket.java | 21 +- 9 files changed, 122 insertions(+), 102 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java b/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java index caba57447..ced3053b8 100644 --- a/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java +++ b/src/main/java/emu/grasscutter/data/excels/RewardPreviewData.java @@ -8,7 +8,7 @@ import lombok.Getter; @ResourceType(name = "RewardPreviewExcelConfigData.json", loadPriority = LoadPriority.HIGH) public class RewardPreviewData extends GameResource { - @Getter(onMethod_ = @Override) + @Getter(onMethod = @__(@Override)) private int id; private ItemParamStringData[] previewItems; diff --git a/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java b/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java index 7b0174136..92856756d 100644 --- a/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java +++ b/src/main/java/emu/grasscutter/data/excels/quest/QuestData.java @@ -13,7 +13,6 @@ import lombok.experimental.FieldDefaults; @Getter @ResourceType(name = "QuestExcelConfigData.json") -@Getter @ToString public class QuestData extends GameResource { private int subId; diff --git a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquaryMainPropData.java b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquaryMainPropData.java index 5806db11b..3a3c83245 100644 --- a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquaryMainPropData.java +++ b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquaryMainPropData.java @@ -8,7 +8,7 @@ import lombok.Getter; @ResourceType(name = "ReliquaryMainPropExcelConfigData.json") @Getter public class ReliquaryMainPropData extends GameResource { - @Getter(onMethod_ = @Override) + @Getter(onMethod = @__(@Override)) private int id; private int propDepotId; diff --git a/src/main/java/emu/grasscutter/data/excels/scene/SceneData.java b/src/main/java/emu/grasscutter/data/excels/scene/SceneData.java index 07c6e25c2..cd86008a2 100644 --- a/src/main/java/emu/grasscutter/data/excels/scene/SceneData.java +++ b/src/main/java/emu/grasscutter/data/excels/scene/SceneData.java @@ -9,7 +9,7 @@ import lombok.Getter; @ResourceType(name = "SceneExcelConfigData.json") @Getter public final class SceneData extends GameResource { - @Getter(onMethod_ = @Override) + @Getter(onMethod = @__(@Override)) private int id; @SerializedName("type") diff --git a/src/main/java/emu/grasscutter/data/excels/scene/SceneTagData.java b/src/main/java/emu/grasscutter/data/excels/scene/SceneTagData.java index d894c5d65..f1819fa8a 100644 --- a/src/main/java/emu/grasscutter/data/excels/scene/SceneTagData.java +++ b/src/main/java/emu/grasscutter/data/excels/scene/SceneTagData.java @@ -8,7 +8,7 @@ import lombok.Getter; @ResourceType(name = "SceneTagConfigData.json") @Getter public final class SceneTagData extends GameResource { - @Getter(onMethod_ = @Override) + @Getter(onMethod = @__(@Override)) private int id; @SerializedName("DJCOAOBDIHP") diff --git a/src/main/java/emu/grasscutter/data/excels/trial/TrialAvatarActivityDataData.java b/src/main/java/emu/grasscutter/data/excels/trial/TrialAvatarActivityDataData.java index 6a532b91f..6d5858cef 100644 --- a/src/main/java/emu/grasscutter/data/excels/trial/TrialAvatarActivityDataData.java +++ b/src/main/java/emu/grasscutter/data/excels/trial/TrialAvatarActivityDataData.java @@ -10,7 +10,7 @@ import lombok.experimental.FieldDefaults; @Data @FieldDefaults(level = AccessLevel.PRIVATE) public class TrialAvatarActivityDataData extends GameResource { - @Getter(onMethod_ = @Override) + @Getter(onMethod = @__({@Override})) private int id; private int trialAvatarIndexId; diff --git a/src/main/java/emu/grasscutter/game/friends/FriendsList.java b/src/main/java/emu/grasscutter/game/friends/FriendsList.java index a6d723a9e..2dab4da1b 100644 --- a/src/main/java/emu/grasscutter/game/friends/FriendsList.java +++ b/src/main/java/emu/grasscutter/game/friends/FriendsList.java @@ -93,8 +93,8 @@ public class FriendsList extends BasePlayerManager { // Handle if (result == DealAddFriendResultType.DEAL_ADD_FRIEND_RESULT_TYPE_ACCEPT) { // Request accepted - myFriendship.setIsFriend(true); - theirFriendship.setIsFriend(true); + myFriendship.setFriend(true); + theirFriendship.setFriend(true); this.getPendingFriends().remove(myFriendship.getOwnerId()); this.addFriend(myFriendship); diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 5da8d49d3..7f37a01ce 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -1,32 +1,43 @@ package emu.grasscutter.game.inventory; -import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS; - import emu.grasscutter.Grasscutter; import emu.grasscutter.data.GameData; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.excels.ItemData; import emu.grasscutter.database.DatabaseHelper; -import emu.grasscutter.game.avatar.*; +import emu.grasscutter.game.avatar.Avatar; +import emu.grasscutter.game.avatar.AvatarStorage; import emu.grasscutter.game.entity.EntityAvatar; -import emu.grasscutter.game.player.*; -import emu.grasscutter.game.props.*; +import emu.grasscutter.game.player.BasePlayerManager; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ItemUseAction.UseItemParams; +import emu.grasscutter.game.props.PlayerProperty; +import emu.grasscutter.game.props.WatcherTriggerType; import emu.grasscutter.game.quest.enums.QuestContent; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.server.event.player.PlayerObtainItemEvent; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; -import it.unimi.dsi.fastutil.ints.*; -import it.unimi.dsi.fastutil.longs.*; -import java.util.*; -import javax.annotation.Nullable; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import lombok.Getter; import lombok.val; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS; + public class Inventory extends BasePlayerManager implements Iterable { private final Long2ObjectMap store; - @Getter private final Int2ObjectMap inventoryTypes; + @Getter + private final Int2ObjectMap inventoryTypes; public Inventory(Player player) { super(player); @@ -36,11 +47,11 @@ public class Inventory extends BasePlayerManager implements Iterable { this.createInventoryTab(ItemType.ITEM_WEAPON, new EquipInventoryTab(INVENTORY_LIMITS.weapons)); this.createInventoryTab( - ItemType.ITEM_RELIQUARY, new EquipInventoryTab(INVENTORY_LIMITS.relics)); + ItemType.ITEM_RELIQUARY, new EquipInventoryTab(INVENTORY_LIMITS.relics)); this.createInventoryTab( - ItemType.ITEM_MATERIAL, new MaterialInventoryTab(INVENTORY_LIMITS.materials)); + ItemType.ITEM_MATERIAL, new MaterialInventoryTab(INVENTORY_LIMITS.materials)); this.createInventoryTab( - ItemType.ITEM_FURNITURE, new MaterialInventoryTab(INVENTORY_LIMITS.furniture)); + ItemType.ITEM_FURNITURE, new MaterialInventoryTab(INVENTORY_LIMITS.furniture)); } public AvatarStorage getAvatarStorage() { @@ -67,16 +78,17 @@ public class Inventory extends BasePlayerManager implements Iterable { */ public GameItem getFirstItem(int itemId) { return this.getItems().values().stream() - .filter(item -> item.getItemId() == itemId) - .findFirst() - .orElse(null); + .filter(item -> item.getItemId() == itemId) + .findFirst() + .orElse(null); } public GameItem getItemByGuid(long id) { return this.getItems().get(id); } - @Nullable public InventoryTab getInventoryTabByItemId(int itemId) { + @Nullable + public InventoryTab getInventoryTabByItemId(int itemId) { val itemData = GameData.getItemDataMap().get(itemId); if (itemData == null || itemData.getItemType() == null) { return null; @@ -84,7 +96,8 @@ public class Inventory extends BasePlayerManager implements Iterable { return getInventoryTab(itemData.getItemType()); } - @Nullable public GameItem getItemById(int itemId) { + @Nullable + public GameItem getItemById(int itemId) { val inventoryTab = this.getInventoryTabByItemId(itemId); return inventoryTab != null ? inventoryTab.getItemById(itemId) : null; } @@ -138,9 +151,9 @@ public class Inventory extends BasePlayerManager implements Iterable { if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_AVATAR) { getPlayer() - .sendPacket( - new PacketAddNoGachaAvatarCardNotify( - (item.getItemId() % 1000) + 10000000, reason, item)); + .sendPacket( + new PacketAddNoGachaAvatarCardNotify( + (item.getItemId() % 1000) + 10000000, reason, item)); } if (reason != null && (forceNotify || result)) { @@ -189,7 +202,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * Checks to see if the player has the item in their inventory. This will succeed if the player * has at least the minimum count of the item. * - * @param itemId The item id to check for. + * @param itemId The item id to check for. * @param minCount The minimum count of the item to check for. * @return True if the player has the item, false otherwise. */ @@ -200,10 +213,10 @@ public class Inventory extends BasePlayerManager implements Iterable { /** * Checks to see if the player has the item in their inventory. * - * @param itemId The item id to check for. - * @param count The count of the item to check for. + * @param itemId The item id to check for. + * @param count The count of the item to check for. * @param enforce If true, the player must have the exact amount. If false, the player must have - * at least the amount. + * at least the amount. * @return True if the player has the item, false otherwise. */ public boolean hasItem(int itemId, int count, boolean enforce) { @@ -230,15 +243,15 @@ public class Inventory extends BasePlayerManager implements Iterable { private void triggerAddItemEvents(GameItem result) { try { getPlayer() - .getBattlePassManager() - .triggerMission( - WatcherTriggerType.TRIGGER_OBTAIN_MATERIAL_NUM, - result.getItemId(), - result.getCount()); + .getBattlePassManager() + .triggerMission( + WatcherTriggerType.TRIGGER_OBTAIN_MATERIAL_NUM, + result.getItemId(), + result.getCount()); getPlayer() - .getQuestManager() - .queueEvent( - QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount()); + .getQuestManager() + .queueEvent( + QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount()); } catch (Exception e) { Grasscutter.getLogger().debug("triggerAddItemEvents failed", e); } @@ -247,11 +260,11 @@ public class Inventory extends BasePlayerManager implements Iterable { private void triggerRemItemEvents(GameItem item, int removeCount) { try { getPlayer() - .getBattlePassManager() - .triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount); + .getBattlePassManager() + .triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount); getPlayer() - .getQuestManager() - .queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount()); + .getQuestManager() + .queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount()); } catch (Exception e) { Grasscutter.getLogger().debug("triggerRemItemEvents failed", e); } @@ -259,8 +272,8 @@ public class Inventory extends BasePlayerManager implements Iterable { public void addItemParams(Collection items) { addItems( - items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), - null); + items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), + null); } public void addItemParamDatas(Collection items) { @@ -269,8 +282,8 @@ public class Inventory extends BasePlayerManager implements Iterable { public void addItemParamDatas(Collection items, ActionReason reason) { addItems( - items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), - reason); + items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), + reason); } private synchronized GameItem putItem(GameItem item) { @@ -319,9 +332,7 @@ public class Inventory extends BasePlayerManager implements Iterable { case MATERIAL_COSTUME: case MATERIAL_NAMECARD: Grasscutter.getLogger() - .warn( - "Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", - item.getItemData().getMaterialType().name()); + .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); return null; default: if (tab == null) { @@ -341,9 +352,9 @@ public class Inventory extends BasePlayerManager implements Iterable { } else { // Add count existingItem.setCount( - Math.min( - existingItem.getCount() + item.getCount(), - item.getItemData().getStackLimit())); + Math.min( + existingItem.getCount() + item.getCount(), + item.getItemData().getStackLimit())); existingItem.save(); return existingItem; } @@ -366,57 +377,57 @@ public class Inventory extends BasePlayerManager implements Iterable { private void addVirtualItem(int itemId, int count) { switch (itemId) { case 101 -> // Character exp - this.player.getTeamManager().getActiveTeam().stream() + this.player.getTeamManager().getActiveTeam().stream() .map(EntityAvatar::getAvatar) .forEach( - avatar -> - this.player - .getServer() - .getInventorySystem() - .upgradeAvatar(this.player, avatar, count)); + avatar -> + this.player + .getServer() + .getInventorySystem() + .upgradeAvatar(this.player, avatar, count)); case 102 -> // Adventure exp - this.player.addExpDirectly(count); + this.player.addExpDirectly(count); case 105 -> // Companionship exp - this.player.getTeamManager().getActiveTeam().stream() + this.player.getTeamManager().getActiveTeam().stream() .map(EntityAvatar::getAvatar) .forEach( - avatar -> - this.player - .getServer() - .getInventorySystem() - .upgradeAvatarFetterLevel( - this.player, avatar, count * (this.player.isInMultiplayer() ? 2 : 1))); + avatar -> + this.player + .getServer() + .getInventorySystem() + .upgradeAvatarFetterLevel( + this.player, avatar, count * (this.player.isInMultiplayer() ? 2 : 1))); case 106 -> // Resin - this.player.getResinManager().addResin(count); + this.player.getResinManager().addResin(count); case 107 -> // Legendary Key - this.player.addLegendaryKey(count); + this.player.addLegendaryKey(count); case 121 -> // Home exp - this.player.getHome().addExp(this.player, count); + this.player.getHome().addExp(this.player, count); case 201 -> // Primogem - this.player.setPrimogems(this.player.getPrimogems() + count); + this.player.setPrimogems(this.player.getPrimogems() + count); case 202 -> // Mora - this.player.setMora(this.player.getMora() + count); + this.player.setMora(this.player.getMora() + count); case 203 -> // Genesis Crystals - this.player.setCrystals(this.player.getCrystals() + count); + this.player.setCrystals(this.player.getCrystals() + count); case 204 -> // Home Coin - this.player.setHomeCoin(this.player.getHomeCoin() + count); + this.player.setHomeCoin(this.player.getHomeCoin() + count); } } private GameItem payVirtualItem(int itemId, int count) { switch (itemId) { case 201 -> // Primogem - player.setPrimogems(player.getPrimogems() - count); + player.setPrimogems(player.getPrimogems() - count); case 202 -> // Mora - player.setMora(player.getMora() - count); + player.setMora(player.getMora() - count); case 203 -> // Genesis Crystals - player.setCrystals(player.getCrystals() - count); + player.setCrystals(player.getCrystals() - count); case 106 -> // Resin - player.getResinManager().useResin(count); + player.getResinManager().useResin(count); case 107 -> // LegendaryKey - player.useLegendaryKey(count); + player.useLegendaryKey(count); case 204 -> // Home Coin - player.setHomeCoin(player.getHomeCoin() - count); + player.setHomeCoin(player.getHomeCoin() - count); default -> { var gameItem = getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemId); removeItem(gameItem, count); @@ -429,24 +440,23 @@ public class Inventory extends BasePlayerManager implements Iterable { private int getVirtualItemCount(int itemId) { return switch (itemId) { case 201 -> // Primogem - this.player.getPrimogems(); + this.player.getPrimogems(); case 202 -> // Mora - this.player.getMora(); + this.player.getMora(); case 203 -> // Genesis Crystals - this.player.getCrystals(); + this.player.getCrystals(); case 106 -> // Resin - this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); + this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); case 107 -> // Legendary Key - this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); + this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); case 204 -> // Home Coin - this.player.getHomeCoin(); + this.player.getHomeCoin(); default -> { GameItem item = - getInventoryTab(ItemType.ITEM_MATERIAL) - .getItemById( - itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield - // (item == null) ? 0 : item.getCount(); // What if we ever want to - // operate on weapons/relics/furniture? :S + getInventoryTab(ItemType.ITEM_MATERIAL) + .getItemById( + itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S + yield (item == null) ? 0 : item.getCount(); } }; } @@ -470,7 +480,7 @@ public class Inventory extends BasePlayerManager implements Iterable { } public synchronized boolean payItems( - ItemParamData[] costItems, int quantity, ActionReason reason) { + ItemParamData[] costItems, int quantity, ActionReason reason) { // Make sure player has requisite items for (ItemParamData cost : costItems) if (this.getVirtualItemCount(cost.getId()) < (cost.getCount() * quantity)) return false; @@ -495,7 +505,7 @@ public class Inventory extends BasePlayerManager implements Iterable { } public synchronized boolean payItems( - Iterable costItems, int quantity, ActionReason reason) { + Iterable costItems, int quantity, ActionReason reason) { // Make sure player has requisite items for (ItemParamData cost : costItems) if (getVirtualItemCount(cost.getId()) < (cost.getCount() * quantity)) return false; @@ -532,7 +542,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * the item's type. * * @param itemId The ID of the item to remove. - * @param count The amount of items to remove. + * @param count The amount of items to remove. * @return True if the item was removed, false otherwise. */ public synchronized boolean removeItem(int itemId, int count) { @@ -556,7 +566,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * Removes an item by its item ID. * * @param itemId The ID of the item to remove. - * @param count The amount of items to remove. + * @param count The amount of items to remove. * @return True if the item was removed, false otherwise. */ public synchronized boolean removeItemById(int itemId, int count) { diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index 5620a08c7..2c9502eee 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -2,20 +2,27 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; -import java.io.*; import lombok.Getter; import lombok.Setter; +import java.io.*; + public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; - @Setter @Getter private int opcode; + @Setter + @Getter + private int opcode; private boolean shouldBuildHeader = false; - @Setter @Getter private byte[] header; - @Setter @Getter private byte[] data; + @Setter + @Getter + private byte[] header; + @Getter + private byte[] data; // Encryption - @Setter private boolean useDispatchKey; + @Setter + private boolean useDispatchKey; public BasePacket(int opcode) { this.opcode = opcode; @@ -48,6 +55,10 @@ public class BasePacket { this.data = proto.build().toByteArray(); } + public void setData(byte[] packet) { + this.data = packet; + } + public BasePacket buildHeader(int clientSequence) { if (this.getHeader() != null && clientSequence == 0) { return this; From 2bb2da44bcaa5a5594905a36705ad7a22932e227 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:12:09 +0000 Subject: [PATCH 48/59] Format code [skip actions] --- .../grasscutter/game/inventory/Inventory.java | 170 +++++++++--------- .../grasscutter/net/packet/BasePacket.java | 17 +- 2 files changed, 90 insertions(+), 97 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 7f37a01ce..605be0f67 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -1,5 +1,7 @@ package emu.grasscutter.game.inventory; +import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS; + import emu.grasscutter.Grasscutter; import emu.grasscutter.data.GameData; import emu.grasscutter.data.common.ItemParamData; @@ -23,21 +25,17 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import lombok.Getter; -import lombok.val; - -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; - -import static emu.grasscutter.config.Configuration.INVENTORY_LIMITS; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.val; public class Inventory extends BasePlayerManager implements Iterable { private final Long2ObjectMap store; - @Getter - private final Int2ObjectMap inventoryTypes; + @Getter private final Int2ObjectMap inventoryTypes; public Inventory(Player player) { super(player); @@ -47,11 +45,11 @@ public class Inventory extends BasePlayerManager implements Iterable { this.createInventoryTab(ItemType.ITEM_WEAPON, new EquipInventoryTab(INVENTORY_LIMITS.weapons)); this.createInventoryTab( - ItemType.ITEM_RELIQUARY, new EquipInventoryTab(INVENTORY_LIMITS.relics)); + ItemType.ITEM_RELIQUARY, new EquipInventoryTab(INVENTORY_LIMITS.relics)); this.createInventoryTab( - ItemType.ITEM_MATERIAL, new MaterialInventoryTab(INVENTORY_LIMITS.materials)); + ItemType.ITEM_MATERIAL, new MaterialInventoryTab(INVENTORY_LIMITS.materials)); this.createInventoryTab( - ItemType.ITEM_FURNITURE, new MaterialInventoryTab(INVENTORY_LIMITS.furniture)); + ItemType.ITEM_FURNITURE, new MaterialInventoryTab(INVENTORY_LIMITS.furniture)); } public AvatarStorage getAvatarStorage() { @@ -78,17 +76,16 @@ public class Inventory extends BasePlayerManager implements Iterable { */ public GameItem getFirstItem(int itemId) { return this.getItems().values().stream() - .filter(item -> item.getItemId() == itemId) - .findFirst() - .orElse(null); + .filter(item -> item.getItemId() == itemId) + .findFirst() + .orElse(null); } public GameItem getItemByGuid(long id) { return this.getItems().get(id); } - @Nullable - public InventoryTab getInventoryTabByItemId(int itemId) { + @Nullable public InventoryTab getInventoryTabByItemId(int itemId) { val itemData = GameData.getItemDataMap().get(itemId); if (itemData == null || itemData.getItemType() == null) { return null; @@ -96,8 +93,7 @@ public class Inventory extends BasePlayerManager implements Iterable { return getInventoryTab(itemData.getItemType()); } - @Nullable - public GameItem getItemById(int itemId) { + @Nullable public GameItem getItemById(int itemId) { val inventoryTab = this.getInventoryTabByItemId(itemId); return inventoryTab != null ? inventoryTab.getItemById(itemId) : null; } @@ -151,9 +147,9 @@ public class Inventory extends BasePlayerManager implements Iterable { if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_AVATAR) { getPlayer() - .sendPacket( - new PacketAddNoGachaAvatarCardNotify( - (item.getItemId() % 1000) + 10000000, reason, item)); + .sendPacket( + new PacketAddNoGachaAvatarCardNotify( + (item.getItemId() % 1000) + 10000000, reason, item)); } if (reason != null && (forceNotify || result)) { @@ -202,7 +198,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * Checks to see if the player has the item in their inventory. This will succeed if the player * has at least the minimum count of the item. * - * @param itemId The item id to check for. + * @param itemId The item id to check for. * @param minCount The minimum count of the item to check for. * @return True if the player has the item, false otherwise. */ @@ -213,10 +209,10 @@ public class Inventory extends BasePlayerManager implements Iterable { /** * Checks to see if the player has the item in their inventory. * - * @param itemId The item id to check for. - * @param count The count of the item to check for. + * @param itemId The item id to check for. + * @param count The count of the item to check for. * @param enforce If true, the player must have the exact amount. If false, the player must have - * at least the amount. + * at least the amount. * @return True if the player has the item, false otherwise. */ public boolean hasItem(int itemId, int count, boolean enforce) { @@ -243,15 +239,15 @@ public class Inventory extends BasePlayerManager implements Iterable { private void triggerAddItemEvents(GameItem result) { try { getPlayer() - .getBattlePassManager() - .triggerMission( - WatcherTriggerType.TRIGGER_OBTAIN_MATERIAL_NUM, - result.getItemId(), - result.getCount()); + .getBattlePassManager() + .triggerMission( + WatcherTriggerType.TRIGGER_OBTAIN_MATERIAL_NUM, + result.getItemId(), + result.getCount()); getPlayer() - .getQuestManager() - .queueEvent( - QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount()); + .getQuestManager() + .queueEvent( + QuestContent.QUEST_CONTENT_OBTAIN_ITEM, result.getItemId(), result.getCount()); } catch (Exception e) { Grasscutter.getLogger().debug("triggerAddItemEvents failed", e); } @@ -260,11 +256,11 @@ public class Inventory extends BasePlayerManager implements Iterable { private void triggerRemItemEvents(GameItem item, int removeCount) { try { getPlayer() - .getBattlePassManager() - .triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount); + .getBattlePassManager() + .triggerMission(WatcherTriggerType.TRIGGER_COST_MATERIAL, item.getItemId(), removeCount); getPlayer() - .getQuestManager() - .queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount()); + .getQuestManager() + .queueEvent(QuestContent.QUEST_CONTENT_ITEM_LESS_THAN, item.getItemId(), item.getCount()); } catch (Exception e) { Grasscutter.getLogger().debug("triggerRemItemEvents failed", e); } @@ -272,8 +268,8 @@ public class Inventory extends BasePlayerManager implements Iterable { public void addItemParams(Collection items) { addItems( - items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), - null); + items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), + null); } public void addItemParamDatas(Collection items) { @@ -282,8 +278,8 @@ public class Inventory extends BasePlayerManager implements Iterable { public void addItemParamDatas(Collection items, ActionReason reason) { addItems( - items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), - reason); + items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), + reason); } private synchronized GameItem putItem(GameItem item) { @@ -332,7 +328,9 @@ public class Inventory extends BasePlayerManager implements Iterable { case MATERIAL_COSTUME: case MATERIAL_NAMECARD: Grasscutter.getLogger() - .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); + .warn( + "Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", + item.getItemData().getMaterialType().name()); return null; default: if (tab == null) { @@ -352,9 +350,9 @@ public class Inventory extends BasePlayerManager implements Iterable { } else { // Add count existingItem.setCount( - Math.min( - existingItem.getCount() + item.getCount(), - item.getItemData().getStackLimit())); + Math.min( + existingItem.getCount() + item.getCount(), + item.getItemData().getStackLimit())); existingItem.save(); return existingItem; } @@ -377,57 +375,57 @@ public class Inventory extends BasePlayerManager implements Iterable { private void addVirtualItem(int itemId, int count) { switch (itemId) { case 101 -> // Character exp - this.player.getTeamManager().getActiveTeam().stream() + this.player.getTeamManager().getActiveTeam().stream() .map(EntityAvatar::getAvatar) .forEach( - avatar -> - this.player - .getServer() - .getInventorySystem() - .upgradeAvatar(this.player, avatar, count)); + avatar -> + this.player + .getServer() + .getInventorySystem() + .upgradeAvatar(this.player, avatar, count)); case 102 -> // Adventure exp - this.player.addExpDirectly(count); + this.player.addExpDirectly(count); case 105 -> // Companionship exp - this.player.getTeamManager().getActiveTeam().stream() + this.player.getTeamManager().getActiveTeam().stream() .map(EntityAvatar::getAvatar) .forEach( - avatar -> - this.player - .getServer() - .getInventorySystem() - .upgradeAvatarFetterLevel( - this.player, avatar, count * (this.player.isInMultiplayer() ? 2 : 1))); + avatar -> + this.player + .getServer() + .getInventorySystem() + .upgradeAvatarFetterLevel( + this.player, avatar, count * (this.player.isInMultiplayer() ? 2 : 1))); case 106 -> // Resin - this.player.getResinManager().addResin(count); + this.player.getResinManager().addResin(count); case 107 -> // Legendary Key - this.player.addLegendaryKey(count); + this.player.addLegendaryKey(count); case 121 -> // Home exp - this.player.getHome().addExp(this.player, count); + this.player.getHome().addExp(this.player, count); case 201 -> // Primogem - this.player.setPrimogems(this.player.getPrimogems() + count); + this.player.setPrimogems(this.player.getPrimogems() + count); case 202 -> // Mora - this.player.setMora(this.player.getMora() + count); + this.player.setMora(this.player.getMora() + count); case 203 -> // Genesis Crystals - this.player.setCrystals(this.player.getCrystals() + count); + this.player.setCrystals(this.player.getCrystals() + count); case 204 -> // Home Coin - this.player.setHomeCoin(this.player.getHomeCoin() + count); + this.player.setHomeCoin(this.player.getHomeCoin() + count); } } private GameItem payVirtualItem(int itemId, int count) { switch (itemId) { case 201 -> // Primogem - player.setPrimogems(player.getPrimogems() - count); + player.setPrimogems(player.getPrimogems() - count); case 202 -> // Mora - player.setMora(player.getMora() - count); + player.setMora(player.getMora() - count); case 203 -> // Genesis Crystals - player.setCrystals(player.getCrystals() - count); + player.setCrystals(player.getCrystals() - count); case 106 -> // Resin - player.getResinManager().useResin(count); + player.getResinManager().useResin(count); case 107 -> // LegendaryKey - player.useLegendaryKey(count); + player.useLegendaryKey(count); case 204 -> // Home Coin - player.setHomeCoin(player.getHomeCoin() - count); + player.setHomeCoin(player.getHomeCoin() - count); default -> { var gameItem = getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemId); removeItem(gameItem, count); @@ -440,22 +438,24 @@ public class Inventory extends BasePlayerManager implements Iterable { private int getVirtualItemCount(int itemId) { return switch (itemId) { case 201 -> // Primogem - this.player.getPrimogems(); + this.player.getPrimogems(); case 202 -> // Mora - this.player.getMora(); + this.player.getMora(); case 203 -> // Genesis Crystals - this.player.getCrystals(); + this.player.getCrystals(); case 106 -> // Resin - this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); + this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); case 107 -> // Legendary Key - this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); + this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); case 204 -> // Home Coin - this.player.getHomeCoin(); + this.player.getHomeCoin(); default -> { GameItem item = - getInventoryTab(ItemType.ITEM_MATERIAL) - .getItemById( - itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S + getInventoryTab(ItemType.ITEM_MATERIAL) + .getItemById( + itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield + // (item == null) ? 0 : item.getCount(); // What if we ever want to + // operate on weapons/relics/furniture? :S yield (item == null) ? 0 : item.getCount(); } }; @@ -480,7 +480,7 @@ public class Inventory extends BasePlayerManager implements Iterable { } public synchronized boolean payItems( - ItemParamData[] costItems, int quantity, ActionReason reason) { + ItemParamData[] costItems, int quantity, ActionReason reason) { // Make sure player has requisite items for (ItemParamData cost : costItems) if (this.getVirtualItemCount(cost.getId()) < (cost.getCount() * quantity)) return false; @@ -505,7 +505,7 @@ public class Inventory extends BasePlayerManager implements Iterable { } public synchronized boolean payItems( - Iterable costItems, int quantity, ActionReason reason) { + Iterable costItems, int quantity, ActionReason reason) { // Make sure player has requisite items for (ItemParamData cost : costItems) if (getVirtualItemCount(cost.getId()) < (cost.getCount() * quantity)) return false; @@ -542,7 +542,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * the item's type. * * @param itemId The ID of the item to remove. - * @param count The amount of items to remove. + * @param count The amount of items to remove. * @return True if the item was removed, false otherwise. */ public synchronized boolean removeItem(int itemId, int count) { @@ -566,7 +566,7 @@ public class Inventory extends BasePlayerManager implements Iterable { * Removes an item by its item ID. * * @param itemId The ID of the item to remove. - * @param count The amount of items to remove. + * @param count The amount of items to remove. * @return True if the item was removed, false otherwise. */ public synchronized boolean removeItemById(int itemId, int count) { diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index 2c9502eee..1f758a4a5 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -2,27 +2,20 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; +import java.io.*; import lombok.Getter; import lombok.Setter; -import java.io.*; - public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; - @Setter - @Getter - private int opcode; + @Setter @Getter private int opcode; private boolean shouldBuildHeader = false; - @Setter - @Getter - private byte[] header; - @Getter - private byte[] data; + @Setter @Getter private byte[] header; + @Getter private byte[] data; // Encryption - @Setter - private boolean useDispatchKey; + @Setter private boolean useDispatchKey; public BasePacket(int opcode) { this.opcode = opcode; From dbb4f857efa9df5a4aaac41ea58e584bac8f286e Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 12:22:37 -0300 Subject: [PATCH 49/59] ci: bump actions --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eba9a3597..d3ea759f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,9 +20,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: temurin java-version: '17' @@ -44,7 +44,7 @@ jobs: - name: Run Gradle run: ./gradlew -PskipHandbook=1 && ./gradlew jar -PskipHandbook=1 - name: Upload build - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Grasscutter path: grasscutter-*.jar From 1234d184c8df298e80c922cc7dd458e92f13f8a6 Mon Sep 17 00:00:00 2001 From: Breno A Date: Sun, 9 Jun 2024 12:26:04 -0300 Subject: [PATCH 50/59] ci: Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..3e4a382ed --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "gradle" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From 62d53f37ea387d4b94c771054f6844c4f822123f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:26:57 +0000 Subject: [PATCH 51/59] chore(deps): bump com.google.protobuf:protoc from 3.18.1 to 4.27.1 Bumps [com.google.protobuf:protoc](https://github.com/protocolbuffers/protobuf) from 3.18.1 to 4.27.1. - [Release notes](https://github.com/protocolbuffers/protobuf/releases) - [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl) - [Commits](https://github.com/protocolbuffers/protobuf/commits) --- updated-dependencies: - dependency-name: com.google.protobuf:protoc dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1a6a216e1..cfe7e53ae 100644 --- a/build.gradle +++ b/build.gradle @@ -261,7 +261,7 @@ clean { protobuf { protoc { // The artifact spec for the Protobuf Compiler - artifact = 'com.google.protobuf:protoc:3.18.1' + artifact = 'com.google.protobuf:protoc:4.27.1' } generatedFilesBaseDir = "$projectDir/src/generated/" From 52b7ca6b094ec4b309f69513f5b43d221dfae282 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:27:00 +0000 Subject: [PATCH 52/59] chore(deps): bump com.fasterxml.jackson:jackson-bom Bumps [com.fasterxml.jackson:jackson-bom](https://github.com/FasterXML/jackson-bom) from 2.14.0 to 2.17.1. - [Commits](https://github.com/FasterXML/jackson-bom/compare/jackson-bom-2.14.0...jackson-bom-2.17.1) --- updated-dependencies: - dependency-name: com.fasterxml.jackson:jackson-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1a6a216e1..9e14e8abb 100644 --- a/build.gradle +++ b/build.gradle @@ -96,7 +96,7 @@ dependencies { implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.19.6' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2' - implementation platform('com.fasterxml.jackson:jackson-bom:2.14.0') + implementation platform('com.fasterxml.jackson:jackson-bom:2.17.1') implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.2' // Reflections libraries. From bbec09d444ae3aa11727b10b4cfb773c17f37525 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:27:04 +0000 Subject: [PATCH 53/59] chore(deps): bump org.jline:jline-terminal-jna from 3.21.0 to 3.26.1 Bumps [org.jline:jline-terminal-jna](https://github.com/jline/jline3) from 3.21.0 to 3.26.1. - [Release notes](https://github.com/jline/jline3/releases) - [Changelog](https://github.com/jline/jline3/blob/master/changelog.md) - [Commits](https://github.com/jline/jline3/compare/jline-parent-3.21.0...jline-parent-3.26.1) --- updated-dependencies: - dependency-name: org.jline:jline-terminal-jna dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1a6a216e1..d30ca6896 100644 --- a/build.gradle +++ b/build.gradle @@ -82,7 +82,7 @@ dependencies { // Line reading libraries. implementation group: 'org.jline', name: 'jline', version: '3.21.0' - implementation group: 'org.jline', name: 'jline-terminal-jna', version: '3.21.0' + implementation group: 'org.jline', name: 'jline-terminal-jna', version: '3.26.1' implementation group: 'net.java.dev.jna', name: 'jna', version: '5.10.0' // Java Netty for networking. From ff2aeac9a51278d29201c1935a2076f82398992f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 15:27:08 +0000 Subject: [PATCH 54/59] chore(deps): bump org.junit.jupiter:junit-jupiter-engine Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.8.2 to 5.10.2. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.8.2...r5.10.2) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter-engine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1a6a216e1..1efaf9bfb 100644 --- a/build.gradle +++ b/build.gradle @@ -130,7 +130,7 @@ dependencies { // Testing libraries. testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.2' - testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2' + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.2' // HTTP client library for testing. testImplementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.10.0' From 63fbe661581ccb0ff2c83277c6658aea08586aae Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 13:06:59 -0300 Subject: [PATCH 55/59] security: add secure mode and padding scheme --- src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java | 2 +- .../server/packet/recv/HandlerGetPlayerTokenReq.java | 2 +- src/main/java/emu/grasscutter/utils/Crypto.java | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java b/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java index 1892d4504..eceae40cc 100644 --- a/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java +++ b/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java @@ -103,7 +103,7 @@ public final class DefaultAuthenticators { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); RSAPrivateKey private_key = (RSAPrivateKey) keyFactory.generatePrivate(keySpec); - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); cipher.init(Cipher.DECRYPT_MODE, private_key); 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 3a54acc52..c267124d8 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerGetPlayerTokenReq.java @@ -113,7 +113,7 @@ public class HandlerGetPlayerTokenReq extends PacketHandler { if (req.getKeyId() > 0) { var encryptSeed = session.getEncryptSeed(); try { - var cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + var cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY); var clientSeedEncrypted = Utils.base64Decode(req.getClientRandKey()); diff --git a/src/main/java/emu/grasscutter/utils/Crypto.java b/src/main/java/emu/grasscutter/utils/Crypto.java index 01b515b7b..01ab0c470 100644 --- a/src/main/java/emu/grasscutter/utils/Crypto.java +++ b/src/main/java/emu/grasscutter/utils/Crypto.java @@ -10,6 +10,7 @@ import java.security.spec.*; import java.util.*; import java.util.regex.Pattern; import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; public final class Crypto { @@ -100,8 +101,8 @@ public final class Crypto { if (key_id == null) { throw new Exception("Key ID was not set"); } + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); cipher.init(Cipher.ENCRYPT_MODE, EncryptionKeys.get(Integer.valueOf(key_id))); // Encrypt regionInfo in chunks From 073695631705a47e568b762f81e348558cc61086 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:08:43 +0000 Subject: [PATCH 56/59] Format code [skip actions] --- src/main/java/emu/grasscutter/utils/Crypto.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/utils/Crypto.java b/src/main/java/emu/grasscutter/utils/Crypto.java index 01ab0c470..b8399b92a 100644 --- a/src/main/java/emu/grasscutter/utils/Crypto.java +++ b/src/main/java/emu/grasscutter/utils/Crypto.java @@ -10,7 +10,6 @@ import java.security.spec.*; import java.util.*; import java.util.regex.Pattern; import javax.crypto.Cipher; -import javax.crypto.NoSuchPaddingException; public final class Crypto { From 011549f2ce88bdca8c9d2a9b3b7ef902172b7f69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 06:31:32 +0000 Subject: [PATCH 57/59] chore(deps): bump org.java-websocket:Java-WebSocket from 1.5.2 to 1.5.6 Bumps [org.java-websocket:Java-WebSocket](https://github.com/TooTallNate/Java-WebSocket) from 1.5.2 to 1.5.6. - [Release notes](https://github.com/TooTallNate/Java-WebSocket/releases) - [Changelog](https://github.com/TooTallNate/Java-WebSocket/blob/master/CHANGELOG.md) - [Commits](https://github.com/TooTallNate/Java-WebSocket/compare/v1.5.2...v1.5.6) --- updated-dependencies: - dependency-name: org.java-websocket:Java-WebSocket dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1478d2c35..ad2d4d757 100644 --- a/build.gradle +++ b/build.gradle @@ -121,7 +121,7 @@ dependencies { // Java HTTP server library. implementation group: 'io.javalin', name: 'javalin', version: '5.5.0' // Java WebSocket server & client library. - implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.2' + implementation group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.6' // Google Protocol Buffer definitions. // These are the raw '.proto' files. From 0819435275e0077d1900d402744b1877a06165fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 06:31:38 +0000 Subject: [PATCH 58/59] chore(deps): bump ch.qos.logback:logback-core from 1.4.7 to 1.5.6 Bumps [ch.qos.logback:logback-core](https://github.com/qos-ch/logback) from 1.4.7 to 1.5.6. - [Commits](https://github.com/qos-ch/logback/compare/v_1.4.7...v_1.5.6) --- updated-dependencies: - dependency-name: ch.qos.logback:logback-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1478d2c35..726da847e 100644 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ dependencies { // Logging libraries. implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.7' - implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.7' + implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.5.6' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.7' // Line reading libraries. From ab5824bb920dbc22d1728f6a4fc3fe3a473676c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:52:31 +0000 Subject: [PATCH 59/59] chore(deps): bump org.slf4j:slf4j-api from 2.0.7 to 2.0.13 Bumps org.slf4j:slf4j-api from 2.0.7 to 2.0.13. --- updated-dependencies: - dependency-name: org.slf4j:slf4j-api dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ab14aa8e6..eca198d36 100644 --- a/build.gradle +++ b/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.5.8' // Logging libraries. - implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.7' + implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13' implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.5.6' implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.7'