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 a1ef20a8e79..1a859769417 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 b3c43bb21e3..34cfd57eeda 100644 --- a/src/main/java/emu/grasscutter/data/GameDepot.java +++ b/src/main/java/emu/grasscutter/data/GameDepot.java @@ -13,17 +13,17 @@ 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 25f8055bf26..6270eb60190 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 SkillPointModifier[] getSkillPointModifiers() { } 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 de77a4ba623..edce795e1dd 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 35632c99084..59da00fe7ec 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 51d4ae2887a..fb17b3594b6 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 3a3b7836d0d..d67cab89fae 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 d897fc4e7d3..1b08233280e 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 e9fd62ff6e8..de36bd3b1b7 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 enum TowerCondType { // 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 TowerCondTimeParams(int param1, int minimumTimeInSeconds) { @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 624556d481a..25f84559bf0 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 @@ 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 c796b998183..e1347570582 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 0c7f5337eb0..76263f87c1e 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 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 370412fe5bb..a95c4fbda25 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 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 6f3a7dae1ac..2e935e1113e 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 @@ @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 be5774ed06d..0bae0a2b4fa 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 f22eb78dc08..f204860a7d7 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 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 8296c09c917..740e46f60ac 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 f60f17c13af..37392a3e897 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 949b003ab65..a7b5418911c 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 @@ 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 88db87bfa3c..78a3df4eeb9 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 50692cd72db..da6fbd7ae32 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 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 7e78dbb100f..e3b9003ffbf 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 3fc91e587bc..6775ea4caf7 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 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 6d150df5f47..50991444637 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 b1bdaeef2b0..7d3405fab90 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 930737bda5e..6960a8595bf 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 571da1f917e..1f8c87c03e1 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 646ef22d1a2..4981d4794a3 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 f66b957ef75..43ce4855410 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 @@ @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 794f36501f6..397682cdec1 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 @@ @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 2ac3601ab15..cdd40945dec 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 98047d1fc25..65fedff48cd 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 fe443e23429..a57dc5830e4 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 27865e1ae54..8e903c46962 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 static class SpawnGroupEntry { } 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 434583f6f23..f0ca384decf 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 4e5229600e2..2a9776a1d65 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 de5e14b5c64..eaea562151b 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 82b7c2a65fe..5256ae9520a 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 @@ 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 1155b018b29..2eb711825c6 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 @@ @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 0e5768a00fc..c0ae72ba743 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 @@ @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 1f8c87c03e1..c6735d82d9e 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 ExpeditionInfo getExpeditionInfo(long avatarGuid) { } 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 85603931d0c..7510895e516 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 @@ private static void revokeAll(Player sender, Player targetPlayer, Achievements a @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 void execute(Player sender, Player targetPlayer, List args) { 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 @@ private void grant( 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 9cd76ba1347..9433a8a57dc 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 792ce1b3b11..bbfb4707845 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 void execute(Player sender, Player targetPlayer, List args) { // 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 c61923452b6..6bce736f8ae 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 d5134af3432..f7b02892bd7 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 @@ private GiveItemParameters parseArgs(Player sender, List args) 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 @@ else if ((param.id > 1000) && (param.id < 1100)) @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 ce0259e091b..a4831eed695 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 void execute(Player sender, Player targetPlayer, List args) { 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 acecf334d2b..1ea37f8b75b 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 bf4d962464d..b1ed3ad4b9f 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 void execute(Player sender, Player targetPlayer, List args) { } 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 cae221176fc..69d46e10302 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 1e0edd2648b..a8debd4e65b 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 @@ 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 d62f8b8542e..a8a0f13e2a0 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 void execute(Player sender, Player targetPlayer, List args) { 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 ff71be1bffb..6edd2dd6821 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 @@ private void setTalentLevel(Player sender, Avatar avatar, int skillId, int newLe @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 34cfd57eeda..0d871131853 100644 --- a/src/main/java/emu/grasscutter/data/GameDepot.java +++ b/src/main/java/emu/grasscutter/data/GameDepot.java @@ -50,7 +50,7 @@ public static void load() { 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 8a6c9187948..7d1b767f8ec 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -413,7 +413,7 @@ private static void loadAbilityData(AbilityData data) { 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 @@ private static void loadNpcBornData() { 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 6270eb60190..c5f9c1a404e 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 OpenConfigEntry(String name, OpenConfigData[] data) { } } - 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 ebec960cbdd..002c7514112 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 String getEntityType() { } 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 a81d3a2c894..6429728f8ed 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 int getIntervalInSeconds(World world) { 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 0f844701da8..1e055ec2e9a 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 void onLoad() { 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 4a050829fe9..7652e644b0d 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 int getId() { 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 b5bef427651..3bf06e5adfe 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 @@ private void onPossibleElementalBurst(Ability ability, AbilityModifier modifier, 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 0bae0a2b4fa..fe3b5e42473 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 void recalcStats(boolean forceSendAbilityChange) { } } // 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 void addToExtraAbilityEmbryos(String openConfig) { } public void addToExtraAbilityEmbryos(String openConfig, boolean forceAdd) { - if (openConfig == null || openConfig.length() == 0) { + if (openConfig == null || openConfig.isEmpty()) { return; } @@ -801,7 +801,7 @@ public void recalcConstellations() { .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 @@ private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { 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 0d48355a557..f72c00e6472 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 void takeMissionPoint(List missionIdList) { 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 dd86b05686c..9bd64ba3287 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 void handlePullRecentChatReq(Player player) { ********************/ 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 void sendPrivateMessageFromServer(int targetUid, int emote) { 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 void sendPrivateMessage(Player player, int targetUid, String message) { // 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 void sendPrivateMessage(Player player, int targetUid, int emote) { 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 void sendTeamMessage(Player player, int channel, String message) { // 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 @@ private void sendServerWelcomeMessages(Player player) { 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 d0167ab404a..00bdfcb4504 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 synchronized void load() { 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 ee56a873c74..fdfc9237804 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 void sendEntryInfoFor(Player player, int pointId, int sceneId) { // 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 2bff768bae6..8a4303430ba 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 AbilityControlBlock getAbilityControlBlock() { } } // 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 d58d4cf6213..b2fa5916f58 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 synchronized void load() { 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 a89f9f30f09..239ac8e9fcf 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 SceneWeaponInfo createSceneWeaponInfo() { .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 Weapon toWeaponProto() { .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 7967617c136..0a5b999997e 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 void addItems(Collection items, ActionReason reason) { 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 b6e3e4c5aab..7bebf19fe9a 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 synchronized void update(Player player) { } 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 synchronized void update(Player player) { 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 9fc66d37e26..ca7a2dbdd11 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 synchronized void onTick() { 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 86d7a0d4540..0e19dfd900b 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 AbilityControlBlockOuterClass.AbilityControlBlock getAbilityControlBlock( } // 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 synchronized void setupAvatarTeam(int teamId, List list) { 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 void setupTemporaryTeam(List> guidList) { .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 synchronized void setCurrentTeam(int teamId) { // 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 void applyAbilities(Scene scene) { 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 7888e470138..6ac1d1313be 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 void start() { 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 void setFailProgress(int index, int value) { 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 boolean clearProgress(boolean notifyDelete) { 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 f3ce4679a3c..613834f453e 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 @@ private void loadShop() { 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 16bf1b23f95..6d21eb05285 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 List getOnlinePlayers() { } 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 3072eebab19..568872e233c 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 void refineWeapon(Player player, long targetGuid, long feedGuid) { if (weapon.getRefinement() >= 4 || weapon.getAffixes() == null - || weapon.getAffixes().size() == 0) { + || weapon.getAffixes().isEmpty()) { return; } @@ -818,7 +818,7 @@ public void destroyMaterial(Player player, List list) { } // 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 505543c12f8..b81d206ab72 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 void onEnd() { 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 65fedff48cd..125188838c4 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 void checkSpawns() { } } - 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 void unloadGroup(SceneBlock block, int group_id) { .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 @@ private List loadNpcForPlayer(Player player) { 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 f0ca384decf..115a57c8001 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 synchronized void removePlayer(Player player) { 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 2a9776a1d65..ca5113167e0 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -678,7 +678,7 @@ public void unregisterGroup(SceneGroup group) { } 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 cc7c445567e..c3839f2e76e 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 Map cacheType(Class type) { } 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 37e30a6a326..94d1ba60e5c 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 @@ private void initialize() { 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 e4de100e081..5b1f406a425 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 626f8f097f3..7b794f220fe 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 a9cb1ccdb75..f8c80383bbb 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 3bfd7bd1795..6b4efa4be8a 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 2ceb236539e..107cce89afc 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex // 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 335d63b99bf..868dd81f7c5 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex // 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 8d1b9a3b12f..255c9ff03e8 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 PacketClientAbilityInitFinishNotify(List entries) { 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 2c6fc2009fa..cda3a804813 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 PacketGetAllMailResultNotify(Player player, boolean gifts) { .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 ab691f46bcc..c0ad15beb5e 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 PacketGetOnlinePlayerListRsp(Player session) { 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 609376fb158..8d0c1c57b35 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 PacketGetScenePointRsp(Player player, int sceneId) { 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 4474cc5cb78..6fd7f2f61d7 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 d3e7b35e5b4..47c0e663ba1 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ static void dumpItems(String locale) { 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 25bf8bdbd26..5cfd173c257 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 static void loadTextMaps(boolean bypassCache) { } 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 7d1b767f8ec..734d51d1a50 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -837,7 +837,6 @@ private static void loadSubfieldMappings() { 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 @@ private static void loadSubfieldMappings() { 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 @@ private static void loadSubfieldMappings() { 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 50388dec364..64947865546 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 enum Type { 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 562616bb4eb..fe08cccf5c9 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 enum Type { 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 29b0b93b48e..ae299402064 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 enum Type { 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 97359285fb6..4e44ec558a9 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 void execute(Player sender, Player targetPlayer, List args) { 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 b1ed3ad4b9f..c4c0e6a4f6c 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 void execute(Player sender, Player targetPlayer, List args) { 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 6edd2dd6821..fb071e56425 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 void execute(Player sender, Player targetPlayer, List args) { 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 4981d4794a3..f724d5d5ea3 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 void checkAddedItem(GameItem item) { 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 void checkAddedItem(GameItem item) { 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 6eaebaaa72d..e2425fc36ca 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex } } 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 d97be81c99d..f1df152c93b 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 PacketVehicleInteractRsp(Player player, int entityId, VehicleInteractType 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 PacketVehicleInteractRsp( 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 474db035f77..1338fcbc7bc 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 8923b338068..30a4ce31eae 100644 --- a/src/main/java/emu/grasscutter/GameConstants.java +++ b/src/main/java/emu/grasscutter/GameConstants.java @@ -7,8 +7,8 @@ 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 6cd5b0f141b..992899c1e54 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 @@ enum PseudoProp { } 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 f8823992636..1cc63d35c0f 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 @@ private enum Action { } 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 2b6d20978c5..1cb60fe910a 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -78,11 +78,11 @@ public static void updateConfig() { } } - 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 static void updateConfig() { /* 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 static class Game { /* 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 static class Game { 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 static class Dispatch { * (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 VisionOptions(String name, int visionRange, int gridWidth) { } 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 static class Mail { } 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 9b519ab9ce9..9087b94cc0f 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 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 99dc1243396..5a035f63275 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 float get(ProudSkillData skill, float defaultValue) { } 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 b42e041ec8c..1c87e908f58 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.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 dd20fec4947..c344d4d904a 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.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 89161b95007..9f9404091ff 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 @@ 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 MailTextContent toProto() { @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 d5f946735f3..da319d3a902 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 @@ 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 bc65ae184b9..da9a9436bf7 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 @@ 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 8ca612061aa..b085735c854 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 c229a1e195a..279f1ab37ad 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 @@ 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 0557c9c0568..87d63dafb41 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 @@ 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 57f574f1b6a..d9ac86513a5 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 @@ 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 597aa4c4066..01b515b7bd3 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 38dee3c5982..1127ef9a4a6 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 @@ 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 Node(int source, int dest) { } 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 734d51d1a50..5db5d09b811 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -169,8 +169,8 @@ public static void loadResources(boolean doReload) { } @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 @@ protected static void loadFromResource( } @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 @@ protected static void loadFromResource(Class c, Path filename, Int2Object } @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 05a89f1704b..efb5775e7e9 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 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 51581f13e1c..b379106a823 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 String getCondType() { 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 fdfc9237804..cefca5e8165 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.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 ce84e6fa3dd..5c9a93dbaae 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 @@ 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 fb0ffe46f3d..3eb03886c69 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 @@ 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 51ca53698f5..ab68b6bc63e 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 boolean deleteMail(int mailId) { 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 dad51e911d3..caba57447ad 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 void onLoad() { 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 1dae2822d48..add08558d97 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 boolean useItem(UseItemParams params) { 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 568872e233c..f84ae7078e1 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 static synchronized int checkPlayerAvatarConstellationLevel(Player player } 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 1a859769417..f6d9a48d729 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -630,15 +630,15 @@ public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) { // 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 1e055ec2e9a..474dca103bd 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 void onLoad() { 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 1778f43282e..b9e7e8c43d0 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 @@ protected boolean isMeet(String... param) { 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 f72c00e6472..6b2ca8a054b 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 Map getMissions() { // 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 0a5b999997e..67dcd32baa7 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.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 @@ private void addVirtualItem(int itemId, int count) { 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 @@ private void addVirtualItem(int itemId, int count) { 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 925e05b0d59..069e469c5d6 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 c6735d82d9e..83cd2447ddc 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 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 @@ private void applyProperties() { */ 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 void unfreezeUnlockedScenePoints(int sceneId) { } 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 0e19dfd900b..d808fbf4439 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 boolean addAvatarsToTeam(TeamInfo team, Collection avatars) { } // 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 @@ private void updateTeamResonances() { // 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 76119984e47..f2418c4c355 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 @@ private boolean evaluateVirtualCost(ItemParamData item) { } 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 1ada85f1684..b71c510a7b3 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 PacketAvatarExpeditionAllDataRsp( .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 5067094ad8d..d2718f31d46 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 PacketAvatarExpeditionDataNotify(Map expeditionInfo 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 ea88a5296d8..ab382e59a56 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -54,7 +54,7 @@ public static void createGmHandbooks(boolean message) throws Exception { 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 @@ void newTranslatedLine(String template, long... hashes) { 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 5cfd173c257..df141b7b87f 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 @@ private static Int2ObjectMap loadTextMapFiles(IntSet nameHashes) { 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 6427de18569..eeafe1a09a7 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 CityData getCityByAreaId(int areaId) { 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 83cd2447ddc..c8c65aded72 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 @@ private void applyStartingSceneTags() { 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 | 36 +++++++++--------- .../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 | 38 +++++++++---------- .../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, 121 insertions(+), 179 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index 7510895e516..c78425c904c 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 @@ private void progress( 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 fb743f0f8f0..d16c972136a 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 @@ private void unlockAllSceneTags(Player targetPlayer) { // 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 5db5d09b811..13be4c4a273 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,25 +140,23 @@ public static void loadResources(boolean doReload) { getResourceDefClassesPrioritySets() .forEach( - 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; - - try { - loadFromResource(c, type, map, doReload); - } catch (Exception e) { - errors.add(Pair.of(Arrays.toString(type.name()), e)); - } - }); - }); + 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; + + 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 929c382cb93..40b180bb069 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 @@ private static Map init() { 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 @@ private void sendUpdatePacket(List achievement) { 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 fe3b5e42473..a3070c6091c 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 void calcConstellation(OpenConfigEntry entry, boolean notifyClient) { 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 08305cae10d..9fff60cf2db 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 static void initialize() { 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 10d488aa277..fd6ce63687c 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 List toAvatarTalkFinishInfoProto() { 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 void takeHomeFetter(Player player) { .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 void takeHomeFetter(Player player) { .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 6d824d584a4..9297ce1fdfa 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 @@ private void fireAllAvatarRewardEvents() { .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; - } - - this.rewardEvents.add( - new HomeAvatarRewardEvent( - homeOwner, - data.getId(), - data.getRewardID(), - data.getAvatarID(), - data.getSuiteId(), - suite.getGuid())); - }); - }); + 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())); + })); 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 111dba9cf4f..1b0acee862a 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 List getAnimals(Scene scene) { 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 8be641b19c4..981f8788109 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 static void initialize() { 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 static void initialize() { 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 7ff42db0b5e..6fd704e6afc 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 99641d0850c..c1eda8fa3b5 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 b9a08259090..7393fbf9daa 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 6ac1d1313be..d4b9e483901 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 boolean rewind(boolean notifyDelete) { 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 e5ce947dffa..6eaac18495b 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -632,9 +632,7 @@ public int DelWorktopOption(int var1) { 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 6e80b6fb2e0..f0b084f27ea 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex .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 08908c5cbbe..f50d1b0229f 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 PacketActivityScheduleInfoNotify(Collection activityC 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 1d65c6bc549..74a02ea0938 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 PacketBattlePassMissionUpdateNotify(Collection mission 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 14e2755a228..67e464d0315 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 PacketCodexDataFullNotify(Player player) { .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 6d9537e194a..3f7a8a088b9 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 PacketCreateVehicleRsp( 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 dca56bf9b9b..6d25619cdd0 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 PacketPlayerDataNotify(Player player) { 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 ab382e59a56..35b9a4e54d0 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -189,12 +189,10 @@ void newTranslatedLine(String template, long... hashes) { 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 static List getAvailableLanguage() { 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 c4c0e6a4f6c..4c0f60907ce 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 08adc351d9e..d95fb61542c 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 float[] getParamList() { @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 be08ede9f34..5f91ca3c39d 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 float[] getParamList() { @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 f7b1cd0f8f3..a6d723a9e50 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 5da1ae1ca7b..22b79f13b6e 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 9f9404091ff..7acfd5a2223 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 c8c65aded72..e951dd307fd 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 PlayerCollectionRecords getCollectionRecordStore() { 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 f84ae7078e1..624a97fcaf3 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 void upgradeRelic( 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 void upgradeRelic( } foodRelics.add(food); } - List payList = new ArrayList(); + List payList = new ArrayList<>(); for (ItemParam itemParam : list) { int amount = itemParam @@ -347,7 +347,7 @@ public void upgradeWeapon( // 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 void upgradeWeapon( } 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 125188838c4..993b2d42a1c 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 void updateEntity(GameEntity entity, VisionType type) { } 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 ca5113167e0..106c79483b3 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -270,7 +270,7 @@ public int refreshGroup( // 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 05b0c1941d2..3e29476620d 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex } 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 105e1c7dd3a..402e13aedd2 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 df141b7b87f..8e64dc98ac0 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 @@ private static Int2ObjectMap loadTextMapFiles(IntSet nameHashes) { .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 bc9ac658e37..9d822378ff2 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.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 1127ef9a4a6..5bb4b35fc64 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 Graph(List nodes, List nodeList) { 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 c4e98647646..ef11c0e9349 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 boolean execute(GameQuest quest, QuestData.QuestExecParam condition, Stri 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 0d1af571716..8b0a92d5869 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 boolean execute(GameQuest quest, QuestData.QuestExecParam condition, Stri 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 fe1630ff982..eeb09d9db61 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 boolean execute(GameQuest quest, QuestData.QuestExecParam condition, Stri 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 67dcd32baa7..b0e8f72d988 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 @@ private GameItem payVirtualItem(int itemId, int count) { } 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 4103ca8d4d7..b4752b42165 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 e6ea19068f1..0b205181f3d 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 static InputStream load(String resourcePath) throws FileNotFoundException /** * 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 static List loadList(String resourcePath, Class classType) thro } } - 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 @@ private static void checkAndCopyData(String name) { 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 f6d9a48d729..c2ba581f970 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -713,8 +713,8 @@ public static Int2ObjectMap getSceneRoutes(int sceneId) { /** * 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 abf45b02da3..2bc47d43f73 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 37be6f3b9b4..33bfb7050b7 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 Position getRotation() { @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 725ec188014..967d20e0133 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 7dfa50d48a5..b93968f94ee 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 @@ // @Entity public final class PlayerProgressManager extends BasePlayerDataManager { /****************************************************************************************************************** - ****************************************************************************************************************** + *

* OPEN STATES ****************************************************************************************************************** *****************************************************************************************************************/ @@ -215,7 +215,7 @@ public void tryUnlockOpenStates() { } /****************************************************************************************************************** - ****************************************************************************************************************** + *

* MAP AREAS AND POINTS ****************************************************************************************************************** *****************************************************************************************************************/ @@ -313,7 +313,7 @@ public void addItemObtainedHistory(int id, int count) { } /****************************************************************************************************************** - ****************************************************************************************************************** + *

* SCENETAGS ****************************************************************************************************************** *****************************************************************************************************************/ diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 106c79483b3..34378345057 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -847,12 +847,12 @@ public Future callEvent(int groupId, int eventType) { } 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 5c7aa9a68ae..d083bba2c9e 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 6b4efa4be8a..b5fd35a16ed 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 600bd1e2f8e..dd7d0be1e0e 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 PacketPlayerWorldSceneInfoListNotify(Player player) { 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 8c3248dd7c2..7717871b131 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -312,7 +312,7 @@ public static LineReader getConsole() { 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 d452cc6ba11..1947cab8e9e 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -53,7 +53,7 @@ private static int getUidFromString(String input) { * @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 CommandMap registerCommand(String label, CommandHandler command) { * @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 void invoke(Player player, Player targetPlayer, String rawMessage) { 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 @@ private void scan() { 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 0b205181f3d..0d19c11f021 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -88,7 +88,7 @@ public static Map loadMap(String resourcePath, Class keyTyp 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 @@ private static void checkAndCopyData(String name) { 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 c2ba581f970..be1d2a25e9f 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -655,7 +655,7 @@ public static Int2ObjectMap getMapByResourceDef(Class resourceDefinition) 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 13be4c4a273..d7e7df051f0 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -63,7 +63,7 @@ public static List> getResourceDefClasses() { 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 static void loadResources(boolean doReload) { })); 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 @@ private static void loadRoutes() { } }); 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 @@ private static void loadAbilityModifiers(Path path) { .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 @@ private static void loadTalent(Path path) { 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 @@ private static void loadOpenConfig() { }); } 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 @@ private static void loadQuests() { } Grasscutter.getLogger() - .debug("Loaded " + GameData.getMainQuestDataMap().size() + " MainQuestDatas."); + .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); } public static void loadScriptSceneData() { @@ -605,7 +605,7 @@ public static void loadScriptSceneData() { } }); 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 @@ private static void loadHomeworldDefaultSaveData() { } }); 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 @@ private static void loadNpcBornData() { } }); 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 fffc6ab738d..d1b149adca2 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -550,7 +550,7 @@ public static void saveMusicGameBeatmap(MusicGameBeatmap musicGameBeatmap) { .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 3bf06e5adfe..1711c3b06b0 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 void executeMixin(Ability ability, AbilityMixinData mixinData, ByteString 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 void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { 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 7d3405fab90..3d0c2db449c 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 b0e8f72d988..841921ac2b2 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 @@ private synchronized GameItem putItem(GameItem item) { 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 ab68b6bc63e..45b3373f67b 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 void sendMail(Mail message) { 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 eeafe1a09a7..2864e223e2e 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 void autoRevive() { 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 void checkAndHealAvatar(EntityAvatar entity) { 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 void refillSpringVolume() { 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 @@ private class AutoRecoverTimerTick extends TimerTask { 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 5322c22c972..8dfcaea69a7 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 void initBlossom(EntityGadget gadget) { } } - 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 List onReward(Player player, EntityGadget chest, boolean useCon 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 8a0a86b1095..79366e79f3f 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 @@ private boolean isPlayerMoving() { 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 int updateStaminaRelative(GameSession session, Consumption consumption, b 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 int updateStaminaAbsolute(GameSession session, String reason, int newStam 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 void run() { 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 void run() { // 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 @@ private void handleDrowning() { // 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 613834f453e..b1e47d9f482 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 @@ private void loadShopChest() { } 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 624a97fcaf3..cd86e429f28 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 static synchronized int checkPlayerAvatarConstellationLevel(Player player 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 03f14a824b9..1c6cbdc5b23 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 @@ private void initializePlugin(PluginIdentifier identifier, URLClassLoader classL 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 34378345057..f37f57ebe52 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -887,7 +887,7 @@ private void realCallEvent(@Nonnull ScriptArgs params) { } } 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 @@ private boolean handleEventForTrigger(ScriptArgs params, SceneTrigger trigger) { 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 68e1467d0e2..16bc5ac1408 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 SceneBlock load(int sceneId, Bindings bindings) { 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 5c9a93dbaae..0c2c253d8c4 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 synchronized SceneGroup load(int sceneId) { 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 93038eec21c..abe23d78f3f 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 SceneMeta load(int sceneId) { 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 6d747797bea..0cdeb63cd08 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 void registerHandlers(Class handlerClass) { // 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 void handle(GameSession session, int opcode, byte[] header, byte[] payloa 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 fa0d1a35799..16064440776 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 void replayPacket(int opcode, String name) { 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 e52e389d4b8..721c811bf03 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 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 65b00364de5..fee90c4bdc2 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 @@ public RootRequestHandler() { 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 edee6909a03..c35703bb1eb 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 @@ private static void getAnnouncement(Context ctx) { 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 @@ private static void getAnnouncement(Context ctx) { 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 @@ private static void getPageResources(Context ctx) { 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 2edc529e1c3..70e3f053a67 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 void handle(@NotNull Context ctx) throws Exception { && 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 7e65e0b48ee..5061c001bb1 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 @@ private static void getPageResources(String path, Context ctx) { 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 6489b140abe..ffd1724f7ed 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 @@ private void handleFallOnGround(GameSession session, GameEntity entity, MotionSt 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 @@ private void handleFallOnGround(GameSession session, GameEntity entity, MotionSt } 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 f9da26241d6..af98a46ea96 100644 --- a/src/main/java/emu/grasscutter/task/TaskMap.java +++ b/src/main/java/emu/grasscutter/task/TaskMap.java @@ -155,12 +155,11 @@ private void scan() { } } 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 35b9a4e54d0..5c89cd733bd 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -314,10 +314,10 @@ public static void generateGachaMappings() { 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 static void createGachaMappings(Path location) throws IOException { 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 0b1ab4fd116..21566bd7586 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 static void write(String dest, byte[] bytes) { 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 static byte[] read(Path path) { 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 static byte[] readResource(String resourcePath) { 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 static void copyResource(String resourcePath, String destination) { 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 a61d755482f..16fc75941e8 100644 --- a/src/main/java/emu/grasscutter/utils/TsvUtils.java +++ b/src/main/java/emu/grasscutter/utils/TsvUtils.java @@ -228,12 +228,10 @@ public static List loadTsvToListSetField(Path filename, Class classTyp 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 static List loadTsvToListSetField(Path filename, Class classTyp }) .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 static List loadTsjToListSetField(Path filename, Class classTyp 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 static List loadTsjToListSetField(Path filename, Class classTyp .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 static List> loadTsjsToListsConstructor(Class classType, P 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 static List> loadTsjsToListsConstructor(Class classType, P 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 static List> loadTsjsToListsConstructor(Class classType, P .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 @@ private T toObj(Class objClass, Type objType) { // 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 435d6d0f16d..e4fc8c0e728 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -69,7 +69,7 @@ public static String toString(InputStream inputStream) throws IOException { 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 static boolean createFolder(String path) { 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 static boolean copyFromResources(String resource, String destination) { 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 8e64dc98ac0..e079dfa606d 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 @@ private Language(LanguageStreamDescription description) { .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 static String translate(String key, Object... args) { 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 static String translate(Locale locale, String key, Object... args) { 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 @@ private static LanguageStreamDescription getLanguageFileDescription( 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 @@ private static LanguageStreamDescription getLanguageFileDescription( 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 @@ private static Int2ObjectMap loadTextMapFile(String language, IntSet nam 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 static void loadTextMaps(boolean bypassCache) { } 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 29e99286397..71d1fea2115 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 synchronized void reduceSatiation() { * 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 79366e79f3f..037aab174ae 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 void run() { 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 @@ private Consumption getClimbConsumption() { 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 @@ private Consumption getSwimConsumptions() { 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 @@ private Consumption getDashConsumption() { 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 @@ private Consumption getFlyConsumption() { } 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 780a6c2138f..249f6733e0b 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 Position subtract(Position sub) { /** 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 Position nearby2d(float range) { 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 64947865546..6b4eb450f8a 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 List getModifierNames() { 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 993b2d42a1c..53f02874646 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 void updateEntity(GameEntity entity) { } 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 cd86e429f28..cdbfc22cd23 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 @@ 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 5bb4b35fc64..6a0f4e1dd53 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 static List doSort(Graph graph) { } } - 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 d808fbf4439..f79cb422df5 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 AbilityControlBlockOuterClass.AbilityControlBlock getAbilityControlBlock( 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 f2d4c63ae98..8b17ac2b23c 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 WorldChallenge build( 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 45b3373f67b..2862f6ebe5a 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 boolean deleteMail(int mailId) { } 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 5c89cd733bd..a8e62ab54cb 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -73,7 +73,7 @@ public static void createGmHandbooks(boolean message) throws Exception { 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 @@ void newTranslatedLine(String template, TextStrings... textstrings) { j--; // Retry the action. Language.loadTextMaps(true); } - handbookBuilders.get(i).append(s + "\n"); + handbookBuilders.get(i).append(s).append("\n"); } } @@ -127,7 +127,7 @@ void newTranslatedLine(String template, long... hashes) { 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 static void createGachaMappings(Path location) throws IOException { 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 0c2c253d8c4..de1a0ef8cb1 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 synchronized SceneGroup load(int sceneId) { 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 ecd6b142540..7c09a303702 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 GameServer(InetSocketAddress address) { 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 6b4eb450f8a..9fa16b9caff 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 @@ 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 fe08cccf5c9..099bb49cea7 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 @@ 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 b4a47b43c2a..bd0e2e2ed46 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 @@ @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 249f6733e0b..0c8483a1367 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 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 @@ @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 | 45 ++++++------- .../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, 712 insertions(+), 1405 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java index 43d5471c5f8..a7b1ee98a7f 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 AbilityEmbryoEntry(String avatarName, String[] array) { 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 9087b94cc0f..8787b530443 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 AbilityModifierEntry(String name) { 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 da7b589c703..72e427294a2 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.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 c5f9c1a404e..21a30120752 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 OpenConfigEntry(String name, OpenConfigData[] data) { } } - 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 SkillPointModifier(int skillId, int delta) { 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 3ca40f32e01..4b9d805b0da 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 @@ 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 9afe5a5d148..fc63f002b2f 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 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 cd8287a72d8..4116be5c8f3 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 @@ // 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 55b4cd04bc0..558b23e0d4e 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 @@ // 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 d9f8147233e..ffb6ae2be9f 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 cdc634a39c6..9bc31f78171 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 c7723597626..e1d768ae31c 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 ItemParamData(int id, int count) { 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 7f864fc9efc..dbb3cc2daf6 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 e1af1a0b267..bd09ca4d8a9 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 ItemUseOp getUseOp() { 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 b379106a823..8627c681f4d 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 d7951917dba..8c60834b2fa 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 b4430558926..d15de8ff23c 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 @@ 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 void onLoad() { 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 1a2de3884cd..b02cb79458e 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 @@ 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 int getId() { 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 002c7514112..9612eb3eda9 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 @@ 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 int getId() { 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 d95fb61542c..194ef810f11 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 @@ 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 int getMainId() { 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 bdd7fa4414a..7097e7c7cab 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 @@ 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 int getId() { 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 08eea561c36..94c42c217d8 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 @@ 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 @@ }, loadPriority = LoadPriority.HIGHEST) public class FetterData extends GameResource { + @Getter private int avatarId; private int fetterId; private List openCond; @@ -24,10 +27,6 @@ public int getId() { 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 a9129be6646..716974af943 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 int getGatherId() { 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 9d8d187c386..6c4dc0cdba8 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 enum OpenStateCondType { 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 6429728f8ed..6c48ec1b27f 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 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 1b817aec2c8..ecf799e05b2 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 @@ 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 int getId() { 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 5c1482f4d71..697ea74a35f 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 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 int getId() { 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 fd3afc8eb06..32d3f205db0 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.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 ebb1d3c4f03..afe41f20e15 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 0f8d2ceb2b4..56af01206fa 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 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 9468a4c5743..47b4db7566c 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 @@ 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 int getId() { 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 6b58a711b3a..5b201156fcf 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 @@ 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 int getId() { 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 dda483808b7..8799c1ba610 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 int getId() { 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 1eae299e372..a2d30b13d96 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 int getId() { 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 8972de6e9f0..b871929fcfb 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 @@ 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 int getId() { 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 5f91ca3c39d..291f7587717 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 @@ 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 int PrevTalent() { 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 ee14db8e2d0..fa28411dcd0 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 1b373bfbe65..547d89f8b61 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 7d585839e37..a7124bda173 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 12f81f30394..fd9722f1ffe 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 @@ @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 4c92c341b63..6d1c3d7f9bc 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 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 a0463f6d1a0..7b017413639 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 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; - - @Getter private boolean finishParent; - @Getter private boolean isRewind; - - @Getter private LogicType acceptCondComb; - @Getter private LogicType finishCondComb; - @Getter 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; - - @Getter private List trialAvatarList; - @Getter private List gainItems; + private int subId; + private int mainId; + private int order; + private long descTextMapHash; + + private boolean finishParent; + private boolean isRewind; + + private LogicType acceptCondComb; + private LogicType finishCondComb; + private LogicType failCondComb; + + private List acceptCond; + private List finishCond; + private List failCond; + private List beginExec; + private List finishExec; + private List failExec; + private Guide guide; + + 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 022d2997e14..153c0777e53 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 @@ 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 int getId() { 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 7652e644b0d..321d04e6258 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 void onLoad() { 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 a35b9b9c2e4..3d326ea6be0 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 int getId() { 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 775737e1123..228716f8faf 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 @@ 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 int getId() { 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 631134257e2..9db8809e4bf 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.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 0967c987153..00cc9b87aca 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 int getId() { 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 25f84559bf0..c42431c3035 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 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 @@ private void optimize() { } } - /** - * @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 7331bccb725..52fc274f7bf 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -11,15 +11,13 @@ 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 e1347570582..bbdab85c471 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.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 static boolean permissionMatchesWildcard(String wildcard, String[] permis 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 void setEmail(String email) { 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 void setBanned(boolean isBanned) { 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 f1caf0f8b0f..ca4c0c6aaa0 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 CoopRequest(Player requester) { 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 a95c4fbda25..d5f8d760f71 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 @@ 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 c177f803574..942eb52caa8 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 static AchievementControlReturns notYetAchieved() { 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 71960772142..20835fe8192 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.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 1d2002e7bef..5d30007c688 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.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 AvatarStorage(Player player) { 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 afd895224ee..27286ad004a 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 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 BattlePassMission(int id) { 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 BattlePassMissionData getData() { 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 6433563d736..d37518f4561 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 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 BattlePassReward(int level, int rewardId, boolean paid) { 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 9bd64ba3287..bd179727006 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.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 5c8bde72fd0..6cff2315897 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 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 df8ace74b3b..e5099e75590 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 856278535c2..ae2697af518 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 e82681f5913..9cc033b020a 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 0484d777a4e..f46e4986dc1 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 00bdfcb4504..2a3bea754c6 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.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 DropSystemLegacy(GameServer server) { 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 f329eab9ced..23807a49839 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 80e7b80af7e..a44592b54b9 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 f204860a7d7..8c6d1a28861 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 @@ 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 86a27021b75..ab218b57f49 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.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 DungeonChallenge(Scene scene, SceneGroup group, 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 367c6baa1c9..08c271ff608 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.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 cfd1a47eea9..a28e445e61a 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 @@ 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 a5b5993fa37..78c5de72fda 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 @@ 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 1a591408c3d..6bf6d1b4fc0 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 @@ 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 8a4303430ba..764f7e42626 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 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 3946ab3f30f..5da3705033a 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 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 9d3e13cdb6c..981bd1fa6a1 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.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 da6fbd7ae32..586e6b386f9 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 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 0919578328e..01208e30175 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.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 GadgetContent(EntityGadget gadget) { 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 03aab7d2757..cbeecaf7696 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.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 GadgetGatherObject(EntityGadget gadget) { } } - 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 0575e2ad920..221cfbd9030 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.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 a70a8e769a1..26ff78b2946 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 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 cd0c67efe49..3174ba9e74b 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 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 8d322794da7..37299e27c9f 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.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 2712bfd27f2..0851abfc8fb 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 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 b39475b836b..8685ceddceb 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 @@ 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 21d483a29a4..41d80133a22 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.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 Friendship(Player owner, Player friend, Player asker) { this.askerId = asker.getUid(); } - public Player getOwner() { - return owner; - } - public void setOwner(Player owner) { this.owner = owner; } @@ -49,18 +50,6 @@ public void setIsFriend(boolean b) { 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 b1bbc7172dd..3122e81b29e 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 @@ 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 GachaRecord(int itemId, int ownerId, int gachaType) { 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 649aa597275..3ef45bd39be 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 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 GachaSystem(GameServer server) { 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 697374b75fe..30fba692c67 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.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 00bf4e078dd..5efd255f12a 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.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 239ac8e9fcf..edea4ad3394 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 @@ @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 GameItem(ItemData data, int count) { } } - 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 841921ac2b2..39a8d716c05 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.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 Long2ObjectMap getItems() { 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 0dde8fd053b..c1dd29797cf 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 ItemDef(int itemId, int count) { 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 954230d622b..6595277610b 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.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 c6ab80e3350..237d2231809 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.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 e53764744e2..ba34eb632fc 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.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 7acfd5a2223..be585a000a3 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.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 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 2862f6ebe5a..a14b0cafbe4 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.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 MailHandler(Player player) { 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 d73778cca78..b8237fceaa2 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.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 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 void onTick() { } } - 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 a8652e8fe74..f151aad4887 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 @@ 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 069e469c5d6..b8707434691 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 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 f29467eaeeb..45fb2750743 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 boolean record() { } } - /** 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 6832294a016..b42c2e6ef84 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 2ba4d584277..72d3763b39e 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 b7047a93098..80fbcc68628 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 c9ce4067ad6..d46ee16ef5b 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 fd240864507..f27d5cc9a88 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 int getTotalFinishTimestamp() { 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 6960a8595bf..a8f05337cc6 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.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 MapMark(MapMarkPoint mapMarkPoint) { 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 a8f70bfb41b..8e29adee67c 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 BasePlayerDataManager(@NonNull Player player) { 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 1a42840b5e4..c2447cefbde 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 @@ 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 BasePlayerManager(@NonNull Player player) { 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 e951dd307fd..684f1c1eb40 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 String toString() { .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 85301daa626..7fa3f5f6e01 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 @@ 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 PlayerBirthday set(int d, int m) { 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 1d1488bd4ec..1f3f1e1c87e 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 boolean findRecord(int configId) { } } + @Getter @Entity public static class CollectionRecord { private int configId; @@ -56,12 +59,5 @@ public CollectionRecord(int configId, long expiredTime) { 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 43ce4855410..dffaea0e84b 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 int resetCurrentProgress(String progressId) { 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 397682cdec1..86c76fef585 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 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 TeamInfo(List avatars) { 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 57867ed35f6..251aa6fbcd8 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 static ActionReason getTypeByName(String name) { 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 d95a858a1c5..d5273f4e9e8 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 385f0775fc1..1abc80f1dea 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 a1076a0aeb5..955b642cc7f 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 @@ 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 @@ private CampTargetType(int value) { 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 71a7c28e4da..39ed137b092 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 static ClimateType getTypeByShortName(String shortName) { 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 9ef59130c59..5a8c49725e3 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.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 7ef342e86d2..683c486db14 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 static EnterReason getTypeByName(String name) { 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 cee0a298198..6220691467b 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 static EntityType toEntityType(int entityId) { 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 7d074b841d5..8832585826f 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 @@ 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 static EntityType getTypeByName(String name) { 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 aac46461df5..8ee65407ddd 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 static FetterState getTypeByName(String name) { 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 f94bc78a544..bd49904951b 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.stream.Stream; import lombok.Getter; +@Getter public enum FightProperty { FIGHT_PROP_NONE(0), FIGHT_PROP_BASE_HP(1), @@ -240,10 +241,6 @@ public static boolean isPercentage(FightProperty prop) { 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 2ec0db35da2..4734350f7dd 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 static GrowCurve getPropByName(String name) { 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 34ec476d880..dd0eec6818e 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 @@ 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 6fd704e6afc..66eff8ed688 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 static ItemUseOp getTypeByValue(int value) { 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 c1eda8fa3b5..5ad8671c2f1 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 static ItemUseTarget getTypeByValue(int value) { 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 1785b2fafec..52a0622e0c3 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 static LifeState getTypeByName(String name) { 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 69558ee83a9..adc080d4bca 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 static MonsterType getTypeByName(String name) { 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 4c5995873df..9c4d40b5963 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 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 8f1baa132c0..5df028a7912 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 @@ private RefreshType(int value) { 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 09bd084b3fe..48015a7e8a0 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 static SceneType getTypeByName(String name) { 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 7393fbf9daa..a55e13f3bf6 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 static ServerBuffType getTypeByValue(int value) { 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 98ae0a3c378..36c8556355e 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 static WatcherTriggerType getTypeByName(String name) { 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 5d1b9640d20..d70af53bea2 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 static WeaponType getTypeByName(String name) { 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 d17ee1876f6..8255932978c 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 17d7aac83cb..dd2e5cd91a8 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 @@ 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 static boolean calculate(@NotNull LogicType logicType, List 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 a7e66b874b7..053b559e57c 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 31924ca12e1..2b14a98b203 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 90cd6ea2d04..d9bbac8d4ff 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 2ea9c61f44e..db76cdf7d80 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 0bccccb3496..692343835fa 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 be1e31fe71f..8fa4d6e7568 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 d59d1737bd1..f5c7d14d16f 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 827826803cc..e75e7ef246e 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 b1e47d9f482..71c6122abec 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.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 static int getShopNextRefreshTime(ShopInfo shopInfo) { }; } - 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 a2990d7ff0c..78a8c201e2e 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 f6a7aefde74..0e92462cc12 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.stream.Stream; import lombok.*; +@Getter @AllArgsConstructor public enum TalkExec { TALK_EXEC_NONE(0), @@ -56,5 +57,5 @@ public static TalkExec getExecByName(String name) { 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 245ec327df0..12afe9f5852 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 int getStarCount() { 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 ae6f86b00b4..c82ca6e231b 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 18c1036cdeb..5369ecb4032 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.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 synchronized void load() { } } - 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 bd0e2e2ed46..e7e02d5baf2 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.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 e6f5ca4fb76..a1c720ee52f 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 @@ 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 0c8483a1367..854c57aaa89 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 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 8e903c46962..0c9d3e2cea5 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 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 GridBlockId getBlockId() { (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 115a57c8001..bc7c6b8b798 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 int getNextPeerId() { 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 39bc9371734..5dd2d10bff5 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.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 synchronized void loadChestConfig() { } } - 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 da9a9436bf7..e6bf489f642 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 @@ 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 BasePacket(int opcode, boolean buildHeader) { this.shouldBuildHeader = buildHeader; } - public int getOpcode() { - return opcode; - } - public void setOpcode(int opcode) { this.opcode = opcode; } @@ -45,10 +46,6 @@ public void setUseDispatchKey(boolean useDispatchKey) { this.useDispatchKey = useDispatchKey; } - public byte[] getHeader() { - return header; - } - public void setHeader(byte[] header) { this.header = header; } @@ -57,10 +54,6 @@ public boolean shouldBuildHeader() { 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 67bc2f02320..852a2824690 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.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 ServerHelper(GameServer gameServer, HttpServer httpServer) { 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 f37f57ebe52..30bb4fe3e09 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.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 SceneScriptManager(Scene scene) { 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 synchronized void deregisterRegion(SceneRegion region) { .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 LuaValue safetyCall(String name, LuaValue func, LuaValue args, SceneGroup } } - 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 16bc5ac1408..58138fa27ae 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 de1a0ef8cb1..9728ca900c8 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 static SceneGroup of(int groupId) { return group; } - public boolean isLoaded() { - return this.loaded; - } - public void setLoaded(boolean loaded) { this.loaded = loaded; } @@ -64,10 +63,6 @@ public List getGarbageGadgets() { 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 SceneSuite getSuiteByIndex(int index) { 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 9e607861c7f..883c66e0b56 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 ScriptArgs(int groupId, int eventType, int param1, int param2) { 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 80d943ee8e3..e663d289237 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.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 0427ede8089..e58309a1df2 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.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 c43cfc1a3c8..d9b0450b3b8 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 @@ 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 static void newHandler( 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 EventConsumer getCallback() { 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 937f9f8f7c9..e2f4c34391f 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 QueryAllRegionsEvent(String regionList) { 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 6ae59362d12..c0a8e4743ac 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 QueryCurrentRegionEvent(String regionInfo) { 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 c59408fdd55..e6dc26fe938 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 lombok.*; /** Invoked when an entity is created. */ +@Getter @AllArgsConstructor public final class EntityCreationEvent extends Event { /** @@ -21,9 +22,9 @@ public static T call(Class type, Class[] argTypes, 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 34527941a4a..8995fe15e04 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 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 2f6c3c1dfa1..4a8d4021534 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 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 7c0bcc54fba..410458818ee 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.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 EntityMoveEvent( 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 24cf09235d7..b234c8e1c3b 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 @@ 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 PlayerCreationEvent(GameSession session, Class playerCl 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 b0c14e2f07b..5709deb30ab 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 @@ 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 ReceiveCommandFeedbackEvent(@Nullable Player player, String message) { 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 4f21297cf20..8eab8e2c939 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 @@ 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 ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetDa 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 7a6125ba7c2..b37722bd4c5 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.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 SendPacketEvent(GameSession gameSession, BasePacket packet) { 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 911e6d0fced..121271b9f59 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 @@ 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 ServerLogEvent(ILoggingEvent loggingEvent, String consoleMessage) { 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 a5e60d7e480..e9951098bd3 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 ServerStartEvent(Type type, OffsetDateTime startTime) { 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 2fc6bc6a4b5..eff1b97c750 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 ServerStopEvent(Type type, OffsetDateTime stopTime) { 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 255d1b28105..54beed1427e 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.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 88c48c25e01..ef040cdaf34 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.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 b976e99b1de..4e49272d7c5 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.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 d669762a4d7..42681438fbc 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.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 e397ff33b3e..9d60592269f 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.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 PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward 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 c008a9783f8..c71ef50f88c 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.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 PlayerReceiveMailEvent(Player player, Mail message) { 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 524d2707849..84f7771d209 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 @@ * 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 d5482e93f25..e04a14766ff 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 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 e009612ad2f..12948bdbf5d 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 @@ 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 EntityEvent(GameEntity entity) { 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 2d1a7749220..b506f95e598 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 @@ 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 PlayerEvent(Player player) { 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 3fd3db05ce5..883cd2b7fff 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 BaseGameSystem(GameServer server) { 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 16064440776..092bf72d34a 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 lombok.*; public class GameSession implements GameSessionManager.KcpChannel { + @Getter private final GameServer server; private GameSessionManager.KcpTunnel tunnel; @@ -44,10 +45,6 @@ public GameSession(GameServer server) { } } - 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 5c6ef77704d..ed1b292ff08 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 @@ 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 void handleClose(Ukcp ukcp) { } }; - 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 94d1ba60e5c..cc29fbe2856 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.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 @@ private static void queryCurrentRegion(Context ctx) { } /** Region data container. */ + @Getter public static class RegionData { private final QueryCurrRegionHttpRsp regionQuery; private final String base64; @@ -330,13 +333,6 @@ public RegionData(QueryCurrRegionHttpRsp prq, String b64) { 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 38e4c2a022c..b152bdeb639 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 boolean hasStarted() { 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 e079dfa606d..fe172270e8c 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.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 static void loadTextMaps(boolean bypassCache) { } } - /** 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 efb5775e7e9..5bcfbda1357 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.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 @@ protected void append(E event) { 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 bbfb4707845..ff2cf4c2c32 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 void execute(Player sender, Player targetPlayer, List args) { } } + @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 32d3f205db0..0ddb6c4393b 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.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 bbdab85c471..35f54dafd6f 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.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 static boolean permissionMatchesWildcard(String wildcard, String[] permis 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 String getEmail() { } } - 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 20835fe8192..76f358a0585 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.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 27286ad004a..b22bc7de04c 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.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 BattlePassMissionData getData() { 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 BattlePassMissionStatus getStatus() { 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 6cff2315897..e9fa10657a1 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 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 e5099e75590..4f372cc2527 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 @@ 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 ae2697af518..cf642775265 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 9cc033b020a..5d2cbbef00b 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 23807a49839..941b39405c5 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 a44592b54b9..a509a17862a 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 ab218b57f49..adeef9d21b0 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.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 DungeonChallenge(Scene scene, SceneGroup group, 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 221cfbd9030..5786cb38437 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.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 26ff78b2946..b79f10ca468 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 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 3174ba9e74b..b3455e739f5 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 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 41d80133a22..af17ea1ac04 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.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 Friendship(Player owner, Player friend, Player asker) { 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 3122e81b29e..d66c12f3def 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 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 GachaRecord(int itemId, int ownerId, int gachaType) { 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 c1dd29797cf..e09d40a9761 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 ItemDef(int itemId, int count) { 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 be585a000a3..8558e9de209 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.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 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 f27d5cc9a88..dedb26ac87d 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 @@ 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 int getTotalFinishTimestamp() { 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 86c76fef585..4fffba9a42d 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 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 TeamInfo(List avatars) { 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 e75e7ef246e..376d4632642 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 @@ 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 78a8c201e2e..1cd9831a208 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 12afe9f5852..a63cbf0f42e 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 @@ 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 int getStarCount() { 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 c82ca6e231b..fa4e653c0cc 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 e7e02d5baf2..13caa8eaaa2 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.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 a1c720ee52f..16ed72ae4eb 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 @@ 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 854c57aaa89..6e3348e02bc 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 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 bc7c6b8b798..ed32b1e1a66 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.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 int getNextPeerId() { 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 e6bf489f642..438b98f8994 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 @@ 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 BasePacket(int opcode, boolean buildHeader) { 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 58138fa27ae..782ef2a8c4a 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 8c8821ca75d..8cd7d6d9cad 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 9728ca900c8..ccfe70b82d7 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 static SceneGroup of(int groupId) { 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 e2f4c34391f..c54b4750c0d 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 @@ 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 QueryAllRegionsEvent(String regionList) { 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 c0a8e4743ac..b6c0a0cffb3 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 @@ 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 QueryCurrentRegionEvent(String regionInfo) { 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 e6dc26fe938..9019d1ca42b 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 lombok.*; /** Invoked when an entity is created. */ +@Setter @Getter @AllArgsConstructor public final class EntityCreationEvent extends Event { @@ -22,9 +23,9 @@ public static T call(Class type, Class[] argTypes, 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 b234c8e1c3b..699105d16cd 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.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 PlayerCreationEvent(GameSession session, Class playerCl 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 5709deb30ab..fc6f247cccc 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.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 ReceiveCommandFeedbackEvent(@Nullable Player player, String message) { 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 8eab8e2c939..9419aef778e 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.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 ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetDa 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 b37722bd4c5..9d6d724ca78 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.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 SendPacketEvent(GameSession gameSession, BasePacket packet) { 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 42681438fbc..b62394331c8 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.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 9d60592269f..05f44073331 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.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 PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward 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 c71ef50f88c..7cfe831aa28 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.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 PlayerReceiveMailEvent(Player player, Mail message) { 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 5bcfbda1357..5b6b8abc037 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.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 @@ protected void append(E event) { 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 3ef45bd39be..e119201eba4 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 @@ private synchronized int drawRoulette(int[] weights, int cutoff) { } 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 8dfcaea69a7..d1f59bf99d2 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 void initBlossom(EntityGadget gadget) { 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 deca11dda8f..e8edc63b77d 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 synchronized void sendPlayerForgingUpdate() { // 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 f79cb422df5..a29d4f0828d 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 void updateTeamProperties() { 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 6eaac18495b..2118ea8616f 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -1997,7 +1997,7 @@ public int DropSubfield(LuaTable table) { 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 dd7d0be1e0e..a6138669199 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 PacketPlayerWorldSceneInfoListNotify(Player player) { /* 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 1aae558bba9..d538c729a88 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 d375f490dff..46382bf9d7d 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 void execute(Player sender, Player targetPlayer, List args) { 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 e8edc63b77d..07a9685a6a3 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 synchronized void sendPlayerForgingUpdate() { 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 3f7a8a088b9..2d6403e42c8 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 PacketCreateVehicleRsp( && ((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 aa1ea7bed6a..c1183a935e9 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 PacketStoreItemDelNotify(Collection items) { 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 fe172270e8c..0ef2207c4cf 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 @@ private static Int2ObjectMap loadTextMapFiles(IntSet nameHashes) { 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 bfeaafd9ab8..133c06cfc2e 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 | 151 ++++++------------ .../cooking/CookingCompoundManager.java | 65 +++----- .../game/world/SceneGroupInstance.java | 57 ++++--- .../server/game/GameServerPacketHandler.java | 18 ++- .../emu/grasscutter/utils/JsonAdapters.java | 44 +++-- 5 files changed, 150 insertions(+), 185 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index f7b02892bd7..b196e09a277 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 static emu.grasscutter.GameConstants.*; -import static emu.grasscutter.command.CommandHelpers.*; - -import emu.grasscutter.command.*; -import emu.grasscutter.data.*; +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.*; +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.*; +import emu.grasscutter.game.inventory.GameItem; +import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.player.Player; -import emu.grasscutter.game.props.*; -import java.util.*; +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; -@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) +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) 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 @@ private static Avatar makeAvatar( 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 @@ private static List makeArtifacts(GiveItemParameters param) { 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 @@ private static List makeArtifacts(GiveItemParameters param) { 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 @@ private static List getArtifactAffixes(ItemData itemData, FightProperty 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 @@ private static int getAppendPropId(String substatText, ItemData itemData) 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 @@ private static int getAppendPropId(String substatText, ItemData itemData) } } - 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 @@ private static void parseRelicArgs(GiveItemParameters param, List args) 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 @@ private static void giveAll(Player player, GiveItemParameters param) { 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 @@ else if ((param.id > 1000) && (param.id < 1100)) 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 void execute(Player sender, Player targetPlayer, List args) { 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 void execute(Player sender, Player targetPlayer, List args) { 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 0f1b1453fb3..793bfdcab3b 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.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.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 CookingCompoundManager(Player player) { 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 synchronized void handlePlayerCompoundMaterialReq(PlayerCompoundMaterialR 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 synchronized void handlePlayerCompoundMaterialReq(PlayerCompoundMaterialR 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 synchronized void handleTakeCompoundOutputReq(TakeCompoundOutputReq req) // 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 a57dc5830e4..94974771704 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 SceneGroupInstance(SceneGroup group, Player owner) { 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 void setCached(boolean value) { 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 0cdeb63cd08..d1e47b54d68 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 void registerPacketHandler(Class handlerClass) { 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 void handle(GameSession session, int opcode, byte[] header, byte[] payloa 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 void handle(GameSession session, int opcode, byte[] header, byte[] payloa // 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 a44e46bace4..d5f765beecf 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 DynamicFloat read(JsonReader reader) throws IOException { 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 IntList read(JsonReader reader) throws IOException { 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 GridPosition read(JsonReader in) throws IOException { 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 6c48ec1b27f..580eeeb75a7 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 int getIntervalInSeconds(World world) { 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 int getIntervalInSeconds(World world) { 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 | 675 ++++++++---------- .../emu/grasscutter/utils/lang/Language.java | 2 +- 4 files changed, 289 insertions(+), 394 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index 40b180bb069..d6acf9e11fa 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 void takeReward(List ids) { }); 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 ea7a4b30ed0..d13cefb4515 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 static Map buildActivit 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 a3070c6091c..c939c772786 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.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 Avatar(AvatarData data) { 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)); - - 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(); - }); + 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(); + }); // Set stats this.recalcStats(); @@ -166,8 +235,7 @@ public static int getMinPromoteLevel(int level) { * @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 @@ private GameItem getEquipBySlot(int slotId) { /** * @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 void setSkillDepotData(AvatarSkillDepotData skillDepot) { * 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 boolean changeElement(@Nonnull ElementType newElement) { * 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 void setCurrentEnergy(float currentEnergy) { 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 float getFightProperty(FightProperty prop) { 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 float getFightProperty(FightProperty prop) { // 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 boolean equipItem(GameItem item, boolean shouldRecalc) { 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 boolean equipItem(GameItem item, boolean shouldRecalc) { 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 void recalcStats() { 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 void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { } // Set stuff - 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; - - 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 any skill strings from this affix - this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); - } - }); + 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; + + 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 any skill strings from this affix + this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); + } + }); // Weapon GameItem weapon = this.getWeapon(); @@ -618,15 +653,11 @@ public void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { } // 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 void recalcStats(boolean forceSendAbilityChange) { } // 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 void recalcStats(boolean forceSendAbilityChange) { 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 void calcConstellation(OpenConfigEntry entry, boolean notifyClient) { // 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 void recalcConstellations() { 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 @@ private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { } 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 @@ private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { } 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 boolean setSkillLevel(int skillId, int level) { 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 boolean unlockConstellation() { 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 boolean unlockConstellation(int talentId, boolean skipPayment) { 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 void forceConstellationLevel(int level) { 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 void forceConstellationLevel(int level) { 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 AvatarInfo toProto() { } 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 AvatarInfo toProto() { 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()); - - this.getSkillExtraChargeMap() - .forEach( - (skillId, count) -> - avatarInfo.putSkillMap( - skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); + 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.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()); - - 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())); + 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.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 ShowAvatarInfo toShowAvatarInfoProto() { /** * 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 void setTrialAvatarInfo( * @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 int getTrialSkillLevel() { 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 int getTrialWeaponId() { 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 int getTrialWeaponId() { 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 List getTrialReliquary() { 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 List getTrialReliquary() { 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 void applyTrialItems() { 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; - - 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); - }); + 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); + }); // 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()); - } - - player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); - } - }); + 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)); + } + }); } /** @@ -1287,26 +1185,20 @@ public void equipTrialItems() { * @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 @@ private void prePersist() { @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 0ef2207c4cf..293ecd4be36 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 static void loadTextMaps(boolean bypassCache) { 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 | 59 +- .../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 | 645 +++++++++++------- .../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 | 37 +- .../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 | 26 +- .../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 | 37 +- .../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, 1154 insertions(+), 1201 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index 1947cab8e9e..ffa66fa7b14 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -230,7 +230,11 @@ public void invoke(Player player, Player targetPlayer, String rawMessage) { 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 @@ private void scan() { 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 c78425c904c..90b202982b1 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 @@ private void progress( 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 b196e09a277..67c06a4b3f0 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.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 @@ private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLe 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 @@ private static List makeArtifacts(GiveItemParameters param) { 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 @@ private static List makeArtifacts(GiveItemParameters param) { 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 @@ private static List getArtifactAffixes(ItemData itemData, FightProperty 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 @@ private static int getAppendPropId(String substatText, ItemData itemData) throws 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 @@ private static int getAppendPropId(String substatText, ItemData itemData) throws } } - 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 @@ private static void parseRelicArgs(GiveItemParameters param, List args) 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 @@ private static void giveAll(Player player, GiveItemParameters param) { 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 @@ else if ((param.id > 1000) && (param.id < 1100)) 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 void execute(Player sender, Player targetPlayer, List args) { 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 void execute(Player sender, Player targetPlayer, List args) { 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 4c0f60907ce..5f21dae4a58 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 d16c972136a..70e7fc6c224 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 @@ private void unlockAllSceneTags(Player targetPlayer) { // 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 0d19c11f021..8a91fac9db3 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.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.Path; import java.util.List; import java.util.Map; +import lombok.val; public class DataLoader { @@ -36,7 +35,7 @@ public static InputStream load(String resourcePath) throws FileNotFoundException * * @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 static InputStreamReader loadReader(String resourcePath) throws IOExcepti * 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 static List loadList(String resourcePath, Class classType) thro } } - 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 be1d2a25e9f..96735f346ce 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -630,15 +630,21 @@ public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) { // 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 static Int2ObjectMap getMapByResourceDef(Class resourceDefinition) 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 d7e7df051f0..3d14cc4d299 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,27 +140,28 @@ public static void loadResources(boolean doReload) { getResourceDefClassesPrioritySets() .forEach( - 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; - - try { - loadFromResource(c, type, map, doReload); - } catch (Exception e) { - errors.add(Pair.of(Arrays.toString(type.name()), e)); - } - })); + 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; + + 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 static void loadResources(boolean doReload) { @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 @@ private static void loadRoutes() { } }); 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 @@ private static void loadAbilityModifiers(Path path) { .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 @@ private static void loadTalent(Path path) { 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 @@ private static void loadOpenConfig() { }); } 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 @@ private static void loadQuests() { } Grasscutter.getLogger() - .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); + .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); } public static void loadScriptSceneData() { @@ -605,7 +606,7 @@ public static void loadScriptSceneData() { } }); 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 @@ private static void loadHomeworldDefaultSaveData() { } }); 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 @@ private static void loadNpcBornData() { } }); 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 a7b1ee98a7f..c191368e762 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 AbilityEmbryoEntry(String avatarName, String[] array) { 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 9fa16b9caff..72030788b60 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 @@ 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 099bb49cea7..93794481239 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 @@ 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 8787b530443..c829c09366d 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 AbilityModifierEntry(String name) { 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 72e427294a2..6ec95006c3d 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.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 21a30120752..54735a1297c 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 SkillPointModifier(int skillId, int delta) { 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 ffb6ae2be9f..bcc6fd8f5d2 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 bd09ca4d8a9..92341b3257a 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 @@ 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 ItemUseOp getUseOp() { } 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 8627c681f4d..e3658a75ee5 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 8c60834b2fa..a0e6c1bbeff 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 @@ 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 d15de8ff23c..430eaefda8d 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 @@ 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 void onLoad() { 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 9612eb3eda9..8c51cfde285 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 @@ 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 194ef810f11..d566c422d3a 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 @@ 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 7097e7c7cab..7b4dce10736 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 @@ @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 94c42c217d8..24401a9001e 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 @@ 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 @@ }, 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 716974af943..2eca6b64c91 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 @@ 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 fb17b3594b6..671e712a872 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 ecf799e05b2..6a076a49a7f 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 @@ 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 697ea74a35f..4a95ea2ca15 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 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 int getId() { 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 47b4db7566c..dc611d29ce2 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 5b201156fcf..9ede549994a 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 @@ 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 8799c1ba610..105e55d295e 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 @@ @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 a2d30b13d96..a26fe6c3af6 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 b871929fcfb..acf0d826cf4 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 @@ 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 291f7587717..d317edf433d 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 @@ 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 547d89f8b61..4969e350ab5 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 @@ @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 a7124bda173..30e7e4a62d5 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 @@ @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 fd9722f1ffe..cdd5aab139b 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 @@ @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 153c0777e53..05eb34e1edb 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 @@ @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 321d04e6258..77712523df4 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 void onLoad() { @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 3d326ea6be0..a89b36287eb 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 228716f8faf..84751156a5b 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 @@ 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 00cc9b87aca..0ffc0155683 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 @@ @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 c42431c3035..126e247689f 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 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 d1b149adca2..4847a19cb17 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -550,7 +550,7 @@ public static void saveMusicGameBeatmap(MusicGameBeatmap musicGameBeatmap) { .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 52fc274f7bf..0330d64a33c 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -14,8 +14,7 @@ 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 35f54dafd6f..4c66ebedf41 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.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 76263f87c1e..92ee5c08064 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 1711c3b06b0..c23dc5fc130 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 @@ private void onPossibleElementalBurst(Ability ability, AbilityModifier modifier, 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 void executeMixin(Ability ability, AbilityMixinData mixinData, ByteString 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 void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { 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 d6acf9e11fa..acc55006e5d 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 @@ private static Map init() { 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 @@ private void sendUpdatePacket(List achievement) { 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 void takeReward(List ids) { }); 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 d13cefb4515..222971c3b16 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 static Map buildActivit 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 c939c772786..932930b5984 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.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 Avatar(AvatarData data) { 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)); - - 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(); - }); + 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(); + }); // Set stats this.recalcStats(); @@ -235,7 +184,8 @@ public static int getMinPromoteLevel(int level) { * @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 @@ private GameItem getEquipBySlot(int slotId) { /** * @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 void setSkillDepotData(AvatarSkillDepotData skillDepot) { * 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 boolean changeElement(@Nonnull ElementType newElement) { * 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 void setCurrentEnergy(float currentEnergy) { 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 float getFightProperty(FightProperty prop) { 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 Map getSkillLevelMap() { // Returns a copy of the skill 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 boolean equipItem(GameItem item, boolean shouldRecalc) { 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 boolean equipItem(GameItem item, boolean shouldRecalc) { 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 void recalcStats() { 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 void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { } // Set stuff - 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; - - 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 any skill strings from this affix - this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); - } - }); + 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; + + 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 any skill strings from this affix + this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); + } + }); // Weapon GameItem weapon = this.getWeapon(); @@ -653,11 +638,15 @@ public void recalcStats(boolean forceSendAbilityChange) { 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 void recalcStats(boolean forceSendAbilityChange) { } // 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 void recalcStats(boolean forceSendAbilityChange) { } // 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 void recalcStats(boolean forceSendAbilityChange) { 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 void calcConstellation(OpenConfigEntry entry, boolean notifyClient) { // 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 void recalcConstellations() { 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 @@ private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { } 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 @@ private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { } 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 boolean setSkillLevel(int skillId, int level) { 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 boolean unlockConstellation(int talentId, boolean skipPayment) { 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 void forceConstellationLevel(int level) { 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 void forceConstellationLevel(int level) { 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 AvatarInfo toProto() { } 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 AvatarInfo toProto() { 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()); - - this.getSkillExtraChargeMap().forEach((skillId, count) -> avatarInfo.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); + 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.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()); - - 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())); + 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.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 ShowAvatarInfo toShowAvatarInfoProto() { /** * 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 void setTrialAvatarInfo(int level, int avatarId, TrialAvatarGrantRecord.G * @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 int getTrialSkillLevel() { 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 int getTrialWeaponId() { 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 int getTrialWeaponId() { 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 List getTrialReliquary() { 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 List getTrialReliquary() { 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 void applyTrialItems() { 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; - - 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); - }); + 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); + }); // 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()); - } - - player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); - } - }); + 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)); + } + }); } /** @@ -1185,20 +1311,26 @@ public void equipTrialItems() { * @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 @@ private void prePersist() { @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 5d30007c688..c75ebaec4ad 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.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 b22bc7de04c..f5b0b109701 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 @@ @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 d37518f4561..b25b4ff9652 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 @@ @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 bd179727006..220cdad6554 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.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 9fff60cf2db..61baedec076 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 static void initialize() { // 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 4f372cc2527..1fc4db3cc35 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 cf642775265..40d576bf01e 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 5d2cbbef00b..6c8cec4ab6b 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 @@ 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 f46e4986dc1..afdca351b38 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 2a3bea754c6..b65708687bc 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.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 941b39405c5..7c9f7c1a22c 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 a509a17862a..60efe56d94a 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 8b17ac2b23c..8be4662864f 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 WorldChallenge build( 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 33bfb7050b7..0bb4cfb6898 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 Position getRotation() { @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 cbeecaf7696..2cecac1f9de 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 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 af17ea1ac04..43c924578eb 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 @@ 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 3d0c2db449c..3b3d2c6a382 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 d66c12f3def..779a1042444 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 @@ 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 e119201eba4..2657d3c0235 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 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 fd6ce63687c..faafe050d62 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 List toAvatarTalkFinishInfoProto() { 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 void takeHomeFetter(Player player) { .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 void takeHomeFetter(Player player) { .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 9297ce1fdfa..b7ac1d826d4 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 @@ private void fireAllAvatarRewardEvents() { .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; - } - - this.rewardEvents.add( - new HomeAvatarRewardEvent( - homeOwner, - data.getId(), - data.getRewardID(), - data.getAvatarID(), - data.getSuiteId(), - suite.getGuid())); - })); + 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())); + })); 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 1b0acee862a..2953479f83f 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 List getAnimals(Scene scene) { 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 edea4ad3394..558dd67002d 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 @@ @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 39a8d716c05..5da8d49d3a3 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.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 @@ private synchronized GameItem putItem(GameItem item) { 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 @@ private GameItem payVirtualItem(int itemId, int count) { 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 e09d40a9761..b0b4987f54b 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 ItemDef(int itemId, int count) { 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 8558e9de209..b1276f1ba07 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.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 a14b0cafbe4..b6e38fb3a4c 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.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 void sendMail(Mail message) { 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 boolean deleteMail(int mailId) { } 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 2864e223e2e..d3f5d043046 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 @@ private class AutoRecoverTimerTick extends TimerTask { 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 b8237fceaa2..7ff36ac7afd 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.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 d1f59bf99d2..9644553cd64 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 List onReward(Player player, EntityGadget chest, boolean useCon 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 793bfdcab3b..b24eadbfc50 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.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 CookingCompoundManager(Player player) { 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 synchronized void handlePlayerCompoundMaterialReq(PlayerCompoundMaterialR 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 synchronized void handlePlayerCompoundMaterialReq(PlayerCompoundMaterialR 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 synchronized void handleTakeCompoundOutputReq(TakeCompoundOutputReq req) // 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 45fb2750743..ebda78540e1 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 @@ 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 b42c2e6ef84..451b2d8cea8 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 72d3763b39e..420400b437f 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 @@ 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 981f8788109..dd177d6dba5 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 static void initialize() { // 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 80fbcc68628..2642fd66509 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 d46ee16ef5b..115e5d0185a 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 @@ 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 dedb26ac87d..f6854a2b993 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 @@ @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; + @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; + @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 a8f05337cc6..9253a6cda82 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 MapMark(MapMarkPoint mapMarkPoint) { 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 f724d5d5ea3..fa8d42c0ff4 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 void checkAddedItem(GameItem item) { 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 1f3f1e1c87e..35eab5b85e3 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 CollectionRecord(int configId, long expiredTime) { 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 4fffba9a42d..835e82d063b 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 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 251aa6fbcd8..8e8a598f283 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 static ActionReason getTypeByValue(int value) { 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 d5273f4e9e8..8f914114335 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 1abc80f1dea..5cc8775153c 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 955b642cc7f..2b9eca32461 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 @@ 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 39ed137b092..582d13378a2 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 683c486db14..07d8ddf4c50 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 static EnterReason getTypeByValue(int value) { 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 6220691467b..e6e672a285e 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 8832585826f..42eae8ed348 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 @@ 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 static EntityType getTypeByValue(int value) { 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 8ee65407ddd..1498a60be79 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 static FetterState getTypeByValue(int value) { 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 4734350f7dd..a04c42205e4 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 static GrowCurve getPropById(int value) { 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 66eff8ed688..54cc2a6d1e3 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 5ad8671c2f1..07701f36ac6 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 52a0622e0c3..e708d534a56 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 static LifeState getTypeByValue(int value) { 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 adc080d4bca..f2b3703771c 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 static MonsterType getTypeByValue(int value) { 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 5df028a7912..bf362f2b11e 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 48015a7e8a0..bf66d3277ff 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 static SceneType getTypeByValue(int value) { 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 a55e13f3bf6..00ebb0e34b3 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 36c8556355e..432f0b61bd7 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 static WatcherTriggerType getTypeByValue(int value) { 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 d70af53bea2..b43d1c7a487 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 static WeaponType getTypeByValue(int value) { 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 d4b9e483901..b2e0b974a47 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 void fail() { 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 dd2e5cd91a8..ebb3bb903db 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 @@ 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 static boolean calculate(@NotNull LogicType logicType, List> 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 1cd9831a208..459f843b7c8 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 cdbfc22cd23..47c9affc015 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 static synchronized int checkPlayerAvatarConstellationLevel(Player player 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 a63cbf0f42e..997c40ded05 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 int getLevelStars(int levelId) { 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 fa4e653c0cc..a3f539b1356 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 5369ecb4032..0d28d1a703f 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.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 13caa8eaaa2..a90cc315954 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 @@ @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 16ed72ae4eb..e25fa3b1096 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 @@ @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 6e3348e02bc..b885ec4c88d 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 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 @@ @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 53f02874646..dca0f35d09d 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 void updateEntity(GameEntity entity) { } 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 94974771704..91d4b4d7101 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.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 SceneGroupInstance(SceneGroup group, Player owner) { 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 void setCached(boolean value) { 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 ed32b1e1a66..5e5a250b223 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 5dd2d10bff5..b9c4e0dadd0 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.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 438b98f8994..5620a08c73b 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 @@ 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 1c6cbdc5b23..b98b2cc523c 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -45,7 +45,7 @@ private void initializePlugin(PluginIdentifier identifier, URLClassLoader classL 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 852a2824690..af2a9990170 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.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 30bb4fe3e09..82317bb3db9 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.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 Future callEvent(int groupId, int eventType) { 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 @@ private void realCallEvent(@Nonnull ScriptArgs params) { } } 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 @@ private boolean handleEventForTrigger(ScriptArgs params, SceneTrigger trigger) { 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 eaea562151b..530c38542e4 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 782ef2a8c4a..c7fce1d9e71 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 SceneBlock load(int sceneId, Bindings bindings) { 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 8cd7d6d9cad..1681cd919fa 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 ccfe70b82d7..a32318f813d 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 @@ 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 synchronized SceneGroup load(int sceneId) { 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 883c66e0b56..bf26d170525 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 @@ @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 d9b0450b3b8..b47c9121002 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 static void newHandler( 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 c54b4750c0d..b386331dee5 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 QueryAllRegionsEvent(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 b6c0a0cffb3..8054cc22382 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 QueryCurrentRegionEvent(String regionInfo) { 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 410458818ee..fedda674d2e 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 EntityMoveEvent( 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 699105d16cd..e94aca6f4ba 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 @@ @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 fc6f247cccc..7080641a1e7 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 @@ 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 9419aef778e..092dab88457 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 @@ 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 ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetDa 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 9d6d724ca78..cd194a7aaa3 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 @@ @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 SendPacketEvent(GameSession gameSession, BasePacket packet) { 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 121271b9f59..355e5f18ad2 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 ServerLogEvent(ILoggingEvent loggingEvent, String consoleMessage) { 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 e9951098bd3..92c1abac00f 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 ServerStartEvent(Type type, OffsetDateTime startTime) { 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 eff1b97c750..0f577a87516 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 ServerStopEvent(Type type, OffsetDateTime stopTime) { 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 05f44073331..c24caccd636 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 @@ @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 PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward 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 7cfe831aa28..c040bfe4a71 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 PlayerReceiveMailEvent(Player player, Mail message) { 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 12948bdbf5d..51546dd9602 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 b506f95e598..f59a18e98cd 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 883cd2b7fff..c7e9bbdb61d 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 d1e47b54d68..13cd482be7b 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 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 void registerPacketHandler(Class handlerClass) { 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 void registerHandlers(Class handlerClass) { // 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 void handle(GameSession session, int opcode, byte[] header, byte[] payloa 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 void handle(GameSession session, int opcode, byte[] header, byte[] payloa // 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 092bf72d34a..a3ffdf8af17 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 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 void replayPacket(int opcode, String name) { 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 ed1b292ff08..6d8702e6299 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 @@ 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 cc29fbe2856..be8d4cc8b64 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.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; - import lombok.Getter; import org.slf4j.Logger; @@ -332,7 +331,6 @@ public RegionData(QueryCurrRegionHttpRsp prq, String b64) { 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 70e3f053a67..f7a37c8f2e1 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 void handle(@NotNull Context ctx) throws Exception { && 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 3e29476620d..0764d4aa2b1 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 ffd1724f7ed..bcddf02831c 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 @@ private void handleFallOnGround(GameSession session, GameEntity entity, MotionSt 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 @@ private void handleFallOnGround(GameSession session, GameEntity entity, MotionSt } 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 f0b084f27ea..607992c6911 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex .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 b4752b42165..55f9ed0a232 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 @@ private boolean isValidBirthday(int month, int day) { 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 e2425fc36ca..d820ce47cd6 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex } 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 f50d1b0229f..e27ee0fe2c1 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 PacketActivityScheduleInfoNotify(Collection activityC 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 74a02ea0938..a5679f024d0 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 PacketBattlePassMissionUpdateNotify(Collection mission 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 67e464d0315..4ddc149e6a4 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 PacketCodexDataFullNotify(Player player) { .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 2d6403e42c8..1b878706347 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 PacketCreateVehicleRsp( && ((EntityVehicle) entity).getOwner().equals(player)) .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))); - - player.getScene().killEntity(entity, 0); - }); + 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))); + + 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 402e13aedd2..65513c62054 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 6d25619cdd0..47d4124f8c6 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 PacketPlayerDataNotify(Player player) { 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 f1df152c93b..1853b681bbd 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 PacketVehicleInteractRsp(Player player, int entityId, VehicleInteractType 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 b152bdeb639..fca50cfb28e 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 af98a46ea96..22f42d616e1 100644 --- a/src/main/java/emu/grasscutter/task/TaskMap.java +++ b/src/main/java/emu/grasscutter/task/TaskMap.java @@ -154,12 +154,12 @@ private void scan() { 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 47c0e663ba1..a2157983012 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ static void dumpItems(String locale) { 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 a8e62ab54cb..5cdaaa13fa4 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -54,7 +54,8 @@ public static void createGmHandbooks(boolean message) throws Exception { 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 @@ void newTranslatedLine(String template, long... hashes) { 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 static List getAvailableLanguage() { 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 21566bd7586..eebacc0143a 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 d5f765beecf..8f0920027a2 100644 --- a/src/main/java/emu/grasscutter/utils/JsonAdapters.java +++ b/src/main/java/emu/grasscutter/utils/JsonAdapters.java @@ -13,13 +13,12 @@ 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 DynamicFloat read(JsonReader reader) throws IOException { 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 IntList read(JsonReader reader) throws IOException { 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 GridPosition read(JsonReader in) throws IOException { 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 16fc75941e8..5381059e5a4 100644 --- a/src/main/java/emu/grasscutter/utils/TsvUtils.java +++ b/src/main/java/emu/grasscutter/utils/TsvUtils.java @@ -228,7 +228,9 @@ public static List loadTsvToListSetField(Path filename, Class classTyp 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 static List loadTsjToListSetField(Path filename, Class classTyp 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 static List loadTsjToListSetField(Path filename, Class classTyp .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 static List> loadTsjsToListsConstructor(Class classType, P 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 static List> loadTsjsToListsConstructor(Class classType, P .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 @@ private T toObj(Class objClass, Type objType) { // 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 e4fc8c0e728..5e77294607a 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -151,7 +151,7 @@ public static boolean copyFromResources(String resource, String destination) { 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 6a0f4e1dd53..c7bc42a80eb 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 static List doSort(Graph graph) { } } - 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 293ecd4be36..5c3b1c968a1 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 @@ private Language(LanguageStreamDescription description) { .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 @@ private static LanguageStreamDescription getLanguageFileDescription( 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 @@ private static LanguageStreamDescription getLanguageFileDescription( 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 @@ private static Int2ObjectMap loadTextMapFiles(IntSet nameHashes) { 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 5b6b8abc037..3ac2e49f825 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.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 @@ protected void append(E event) { 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 caba57447ad..ced3053b882 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 @@ @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 7b017413639..92856756d22 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 @@ @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 5806db11b8f..3a3c8324513 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 @@ @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 07c6e25c224..cd86008a2c6 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 @@ @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 d894c5d6541..f1819fa8a3b 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 @@ @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 6a532b91fb8..6d5858cefb1 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 @@ @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 a6d723a9e50..2dab4da1b07 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 synchronized void handleFriendRequest(int targetUid, DealAddFriendResultT // 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 5da8d49d3a3..7f37a01ce10 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 Inventory(Player player) { 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 void createInventoryTab(ItemType type, InventoryTab tab) { */ 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 GameItem getItemByGuid(long id) { 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 boolean addItem(GameItem item, ActionReason reason, boolean forceNotify) 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 void addItems(Collection items, ActionReason reason) { * 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 boolean hasItem(int itemId, int minCount) { /** * 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 boolean hasAllItems(Collection items) { 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 @@ private void triggerAddItemEvents(GameItem result) { 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 @@ private void triggerRemItemEvents(GameItem item, int removeCount) { 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 void addItemParamDatas(Collection items) { 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 @@ private synchronized GameItem putItem(GameItem item) { 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 @@ private synchronized GameItem putItem(GameItem item) { } 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 @@ private synchronized void putItem(GameItem item, InventoryTab tab) { 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 @@ private GameItem payVirtualItem(int itemId, int count) { 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 boolean payItems(ItemParamData[] costItems, int quantity) { } 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 boolean payItems(Iterable costItems, int quantity) { } 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 boolean removeItem(long guid) { * 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 synchronized boolean removeItem(long guid, int count) { * 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 5620a08c73b..2c9502eeefe 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 @@ 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 void setData(GeneratedMessageV3.Builder proto) { 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 7f37a01ce10..605be0f6744 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.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 Inventory(Player player) { 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 void createInventoryTab(ItemType type, InventoryTab tab) { */ 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 InventoryTab getInventoryTabByItemId(int itemId) { 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 boolean addItem(GameItem item, ActionReason reason, boolean forceNotify) 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 void addItems(Collection items, ActionReason reason) { * 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 boolean hasItem(int itemId, int minCount) { /** * 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 boolean hasAllItems(Collection items) { 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 @@ private void triggerAddItemEvents(GameItem result) { 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 @@ private void triggerRemItemEvents(GameItem item, int removeCount) { 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 void addItemParamDatas(Collection items) { 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 @@ private synchronized GameItem putItem(GameItem item) { 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 @@ private synchronized GameItem putItem(GameItem item) { } 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 @@ private synchronized void putItem(GameItem item, InventoryTab tab) { 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 @@ private GameItem payVirtualItem(int itemId, int count) { 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 boolean payItems(ItemParamData[] costItems, int quantity) { } 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 boolean payItems(Iterable costItems, int quantity) { } 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 boolean removeItem(long guid) { * 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 synchronized boolean removeItem(long guid, int count) { * 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 2c9502eeefe..1f758a4a5ef 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 @@ 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 eba9a359735..d3ea759f3db 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 00000000000..3e4a382ed45 --- /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 1a6a216e1c0..cfe7e53ae67 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 1a6a216e1c0..9e14e8abb0f 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 1a6a216e1c0..d30ca68965d 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 1a6a216e1c0..1efaf9bfbf0 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 1892d45046e..eceae40ccc8 100644 --- a/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java +++ b/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java @@ -103,7 +103,7 @@ public LoginResultJson authenticate(AuthenticationRequest request) { 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 3a54acc52eb..c267124d8f6 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 void handle(GameSession session, byte[] header, byte[] payload) throws Ex 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 01b515b7bd3..01ab0c4702a 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.util.*; import java.util.regex.Pattern; import javax.crypto.Cipher; +import javax.crypto.NoSuchPaddingException; public final class Crypto { @@ -100,8 +101,8 @@ public static QueryCurRegionRspJson encryptAndSignRegionData(byte[] regionInfo, 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 01ab0c4702a..b8399b92aee 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.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 1478d2c3538..ad2d4d7570b 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 1478d2c3538..726da847e29 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 ab14aa8e6e4..eca198d36d5 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'