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] Format code [skip actions] --- .../emu/grasscutter/command/CommandMap.java | 13 +- .../command/commands/AchievementCommand.java | 25 +- .../command/commands/GiveCommand.java | 132 ++-- .../command/commands/SendMailCommand.java | 3 +- .../command/commands/SetSceneTagCommand.java | 3 +- .../java/emu/grasscutter/data/DataLoader.java | 24 +- .../java/emu/grasscutter/data/GameData.java | 14 +- .../emu/grasscutter/data/ResourceLoader.java | 55 +- .../data/binout/AbilityEmbryoEntry.java | 1 - .../data/binout/AbilityMixinData.java | 4 +- .../data/binout/AbilityModifier.java | 4 +- .../data/binout/AbilityModifierEntry.java | 13 +- .../data/binout/MainQuestData.java | 24 +- .../data/binout/OpenConfigEntry.java | 4 +- .../grasscutter/data/common/CurveInfo.java | 1 - .../grasscutter/data/common/ItemUseData.java | 4 +- .../grasscutter/data/common/OpenCondData.java | 3 +- .../data/common/PropGrowCurve.java | 1 - .../grasscutter/data/excels/CombineData.java | 34 +- .../excels/EnvAnimalGatherConfigData.java | 9 +- .../data/excels/EquipAffixData.java | 18 +- .../data/excels/FetterCharacterCardData.java | 3 +- .../grasscutter/data/excels/FetterData.java | 6 +- .../grasscutter/data/excels/GatherData.java | 9 +- .../data/excels/ProudSkillData.java | 3 +- .../grasscutter/data/excels/RewardData.java | 6 +- .../data/excels/ShopGoodsData.java | 40 +- .../data/excels/avatar/AvatarCostumeData.java | 9 +- .../data/excels/avatar/AvatarCurveData.java | 6 +- .../excels/avatar/AvatarFlycloakData.java | 3 +- .../data/excels/avatar/AvatarLevelData.java | 1 - .../data/excels/avatar/AvatarPromoteData.java | 21 +- .../data/excels/avatar/AvatarTalentData.java | 24 +- .../data/excels/codex/CodexQuestData.java | 12 +- .../data/excels/codex/CodexWeaponData.java | 9 +- .../dungeon/DungeonChallengeConfigData.java | 5 +- .../excels/reliquary/ReliquarySetData.java | 3 +- .../data/excels/tower/TowerScheduleData.java | 4 +- .../data/excels/weapon/WeaponLevelData.java | 1 - .../data/excels/weapon/WeaponPromoteData.java | 3 +- .../data/excels/world/WorldLevelData.java | 3 +- .../emu/grasscutter/data/server/Grid.java | 6 +- .../grasscutter/database/DatabaseHelper.java | 2 +- .../grasscutter/database/DatabaseManager.java | 3 +- .../java/emu/grasscutter/game/Account.java | 44 +- .../emu/grasscutter/game/ability/Ability.java | 3 +- .../game/ability/AbilityManager.java | 23 +- .../game/achievement/Achievements.java | 22 +- .../AllActivityConditionBuilder.java | 3 +- .../emu/grasscutter/game/avatar/Avatar.java | 625 +++++++++++------- .../game/avatar/AvatarStorage.java | 6 +- .../game/battlepass/BattlePassMission.java | 10 +- .../game/battlepass/BattlePassReward.java | 9 +- .../emu/grasscutter/game/chat/ChatSystem.java | 6 +- .../game/combine/CombineManger.java | 3 +- .../game/combine/CombineResult.java | 4 +- .../game/combine/ReliquaryDecomposeEntry.java | 4 +- .../emu/grasscutter/game/drop/DropData.java | 6 +- .../emu/grasscutter/game/drop/DropInfo.java | 4 +- .../game/drop/DropSystemLegacy.java | 3 +- .../game/dungeons/DungeonDrop.java | 4 +- .../game/dungeons/DungeonDropEntry.java | 4 +- ...illMonsterTimeChallengeFactoryHandler.java | 3 +- .../grasscutter/game/entity/EntityRegion.java | 2 +- .../entity/gadget/GadgetGatherObject.java | 3 +- .../grasscutter/game/friends/Friendship.java | 17 +- .../grasscutter/game/gacha/GachaBanner.java | 5 +- .../grasscutter/game/gacha/GachaRecord.java | 1 - .../grasscutter/game/gacha/GachaSystem.java | 4 +- .../emu/grasscutter/game/home/GameHome.java | 17 +- .../game/home/HomeModuleManager.java | 35 +- .../grasscutter/game/home/HomeSceneItem.java | 11 +- .../grasscutter/game/inventory/GameItem.java | 3 +- .../grasscutter/game/inventory/Inventory.java | 28 +- .../grasscutter/game/inventory/ItemDef.java | 1 - .../java/emu/grasscutter/game/mail/Mail.java | 10 +- .../grasscutter/game/mail/MailHandler.java | 10 +- .../game/managers/SotSManager.java | 5 +- .../managers/blossom/BlossomActivity.java | 9 +- .../game/managers/blossom/BlossomManager.java | 2 +- .../cooking/CookingCompoundManager.java | 57 +- .../managers/deforestation/HitTreeRecord.java | 9 +- .../game/managers/energy/EnergyDropEntry.java | 4 +- .../game/managers/energy/EnergyDropInfo.java | 1 - .../game/managers/energy/EnergyManager.java | 3 +- .../energy/SkillParticleGenerationEntry.java | 4 +- .../energy/SkillParticleGenerationInfo.java | 1 - .../managers/forging/ActiveForgeData.java | 24 +- .../game/managers/mapmark/MapMark.java | 1 - .../grasscutter/game/player/PlayerCodex.java | 18 +- .../game/player/PlayerCollectionRecords.java | 4 +- .../emu/grasscutter/game/player/TeamInfo.java | 6 +- .../grasscutter/game/props/ActionReason.java | 4 +- .../props/BattlePassMissionRefreshType.java | 1 - .../game/props/BattlePassMissionStatus.java | 1 - .../game/props/CampTargetType.java | 3 +- .../grasscutter/game/props/ClimateType.java | 3 +- .../grasscutter/game/props/EnterReason.java | 4 +- .../grasscutter/game/props/EntityIdType.java | 4 +- .../grasscutter/game/props/EntityType.java | 4 +- .../grasscutter/game/props/FetterState.java | 4 +- .../emu/grasscutter/game/props/GrowCurve.java | 4 +- .../emu/grasscutter/game/props/ItemUseOp.java | 8 +- .../grasscutter/game/props/ItemUseTarget.java | 8 +- .../emu/grasscutter/game/props/LifeState.java | 4 +- .../grasscutter/game/props/MonsterType.java | 4 +- .../grasscutter/game/props/RefreshType.java | 3 +- .../emu/grasscutter/game/props/SceneType.java | 4 +- .../game/props/ServerBuffType.java | 8 +- .../game/props/WatcherTriggerType.java | 4 +- .../grasscutter/game/props/WeaponType.java | 4 +- .../emu/grasscutter/game/quest/GameQuest.java | 3 +- .../game/quest/enums/LogicType.java | 2 - .../game/quest/enums/ParentQuestState.java | 1 - .../game/quest/enums/QuestCond.java | 3 +- .../game/quest/enums/QuestContent.java | 3 +- .../game/quest/enums/QuestExec.java | 3 +- .../game/quest/enums/QuestGuideType.java | 1 - .../game/quest/enums/QuestShowType.java | 1 - .../game/quest/enums/QuestState.java | 1 - .../game/quest/enums/QuestType.java | 1 - .../game/quest/enums/ShowQuestGuideType.java | 1 - .../emu/grasscutter/game/shop/ShopLimit.java | 1 - .../emu/grasscutter/game/shop/ShopSystem.java | 6 +- .../emu/grasscutter/game/shop/ShopTable.java | 4 +- .../game/systems/InventorySystem.java | 5 +- .../game/tower/TowerLevelRecord.java | 4 +- .../game/tower/TowerScheduleConfig.java | 4 +- .../grasscutter/game/tower/TowerSystem.java | 3 +- .../grasscutter/game/world/GridPosition.java | 3 +- .../emu/grasscutter/game/world/Location.java | 3 +- .../emu/grasscutter/game/world/Position.java | 4 +- .../emu/grasscutter/game/world/Scene.java | 3 +- .../game/world/SceneGroupInstance.java | 46 +- .../emu/grasscutter/game/world/World.java | 4 +- .../game/world/WorldDataSystem.java | 2 +- .../grasscutter/net/packet/BasePacket.java | 18 +- .../java/emu/grasscutter/plugin/Plugin.java | 2 +- .../grasscutter/plugin/api/ServerHelper.java | 10 +- .../scripts/SceneScriptManager.java | 28 +- .../emu/grasscutter/scripts/ScriptLoader.java | 3 +- .../grasscutter/scripts/data/SceneBlock.java | 7 +- .../grasscutter/scripts/data/SceneGadget.java | 4 +- .../grasscutter/scripts/data/SceneGroup.java | 13 +- .../grasscutter/scripts/data/ScriptArgs.java | 9 +- .../server/event/EventHandler.java | 7 +- .../event/dispatch/QueryAllRegionsEvent.java | 1 - .../dispatch/QueryCurrentRegionEvent.java | 1 - .../server/event/entity/EntityMoveEvent.java | 1 - .../event/game/PlayerCreationEvent.java | 4 +- .../game/ReceiveCommandFeedbackEvent.java | 7 +- .../server/event/game/ReceivePacketEvent.java | 4 +- .../server/event/game/SendPacketEvent.java | 4 +- .../server/event/internal/ServerLogEvent.java | 1 - .../event/internal/ServerStartEvent.java | 4 +- .../event/internal/ServerStopEvent.java | 4 +- .../event/player/PlayerOpenChestEvent.java | 4 +- .../event/player/PlayerReceiveMailEvent.java | 1 - .../server/event/types/EntityEvent.java | 1 - .../server/event/types/PlayerEvent.java | 1 - .../server/game/BaseGameSystem.java | 1 - .../server/game/GameServerPacketHandler.java | 14 +- .../grasscutter/server/game/GameSession.java | 5 +- .../server/game/GameSessionManager.java | 1 + .../server/http/dispatch/RegionHandler.java | 2 - .../server/http/objects/HttpJsonResponse.java | 13 +- .../packet/recv/HandlerBuyGoodsReq.java | 3 +- .../recv/HandlerCombatInvocationsNotify.java | 15 +- .../packet/recv/HandlerHomeKickPlayerReq.java | 11 +- .../recv/HandlerSetPlayerBirthdayReq.java | 1 - .../packet/recv/HandlerTryEnterHomeReq.java | 20 +- .../PacketActivityScheduleInfoNotify.java | 17 +- .../PacketBattlePassMissionUpdateNotify.java | 3 +- .../send/PacketCodexDataFullNotify.java | 7 +- .../packet/send/PacketCreateVehicleRsp.java | 33 +- .../packet/send/PacketMailChangeNotify.java | 10 +- .../packet/send/PacketPlayerDataNotify.java | 5 +- .../packet/send/PacketVehicleInteractRsp.java | 4 +- .../server/scheduler/AsyncServerTask.java | 6 +- .../java/emu/grasscutter/task/TaskMap.java | 6 +- .../java/emu/grasscutter/tools/Dumpers.java | 2 +- .../java/emu/grasscutter/tools/Tools.java | 25 +- .../java/emu/grasscutter/utils/FileUtils.java | 6 +- .../emu/grasscutter/utils/JsonAdapters.java | 26 +- .../java/emu/grasscutter/utils/TsvUtils.java | 44 +- .../java/emu/grasscutter/utils/Utils.java | 2 +- .../utils/algorithms/KahnsSort.java | 3 +- .../emu/grasscutter/utils/lang/Language.java | 52 +- .../utils/objects/ServerLogEventAppender.java | 4 +- 189 files changed, 1138 insertions(+), 1185 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/CommandMap.java b/src/main/java/emu/grasscutter/command/CommandMap.java index 1947cab8e..ffa66fa7b 100644 --- a/src/main/java/emu/grasscutter/command/CommandMap.java +++ b/src/main/java/emu/grasscutter/command/CommandMap.java @@ -230,7 +230,11 @@ public final class CommandMap { if (SERVER.logCommands) { if (player != null) { Grasscutter.getLogger() - .info("Command used by [{} (Player UID: {})]: {}", player.getAccount().getUsername(), player.getUid(), rawMessage); + .info( + "Command used by [{} (Player UID: {})]: {}", + player.getAccount().getUsername(), + player.getUid(), + rawMessage); } else { Grasscutter.getLogger().info("Command used by server console: {}", rawMessage); } @@ -344,10 +348,13 @@ public final class CommandMap { this.registerCommand(cmdData.label(), (CommandHandler) object); else Grasscutter.getLogger() - .error("Class {} is not a CommandHandler!", annotated.getName()); + .error("Class {} is not a CommandHandler!", annotated.getName()); } catch (Exception exception) { Grasscutter.getLogger() - .error("Failed to register command handler for {}", annotated.getSimpleName(), exception); + .error( + "Failed to register command handler for {}", + annotated.getSimpleName(), + exception); } }); } diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index c78425c90..90b202982 100644 --- a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java @@ -136,18 +136,19 @@ public final class AchievementCommand implements CommandHandler { parseInt(args.remove(0)) .ifPresentOrElse( - integer -> parseInt(args.remove(0)) - .ifPresentOrElse( - progress -> { - var ret = achievements.progress(integer, progress); - switch (ret.getRet()) { - case SUCCESS -> sendSuccessMessage( - sender, "progress", targetPlayer.getNickname(), integer, progress); - case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( - sender, ret.getRet().getKey()); - } - }, - () -> this.sendUsageMessage(sender)), + integer -> + parseInt(args.remove(0)) + .ifPresentOrElse( + progress -> { + var ret = achievements.progress(integer, progress); + switch (ret.getRet()) { + case SUCCESS -> sendSuccessMessage( + sender, "progress", targetPlayer.getNickname(), integer, progress); + case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( + sender, ret.getRet().getKey()); + } + }, + () -> this.sendUsageMessage(sender)), () -> this.sendUsageMessage(sender)); } } diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index b196e09a2..67c06a4b3 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java @@ -1,5 +1,8 @@ package emu.grasscutter.command.commands; +import static emu.grasscutter.GameConstants.*; +import static emu.grasscutter.command.CommandHelpers.*; + import emu.grasscutter.command.Command; import emu.grasscutter.command.CommandHandler; import emu.grasscutter.data.GameData; @@ -14,30 +17,50 @@ import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.FightProperty; -import lombok.Setter; - import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import java.util.regex.Pattern; +import lombok.Setter; -import static emu.grasscutter.GameConstants.*; -import static emu.grasscutter.command.CommandHelpers.*; - -@Command(label = "give", aliases = {"g", "item", "giveitem"}, usage = {"(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", " [lv] [x] [] [[,]]..."}, permission = "player.give", permissionTargeted = "player.give.others", threading = true) +@Command( + label = "give", + aliases = {"g", "item", "giveitem"}, + usage = { + "(||all|weapons|mats|avatars) [lv] [r] [x] [c] [sl]", + " [lv] [x] [] [[,]]..." + }, + permission = "player.give", + permissionTargeted = "player.give.others", + threading = true) public final class GiveCommand implements CommandHandler { - private static final Map> intCommandHandlers = Map.ofEntries(Map.entry(lvlRegex, GiveItemParameters::setLvl), Map.entry(refineRegex, GiveItemParameters::setRefinement), Map.entry(amountRegex, GiveItemParameters::setAmount), Map.entry(constellationRegex, GiveItemParameters::setConstellation), Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); + private static final Map> intCommandHandlers = + Map.ofEntries( + Map.entry(lvlRegex, GiveItemParameters::setLvl), + Map.entry(refineRegex, GiveItemParameters::setRefinement), + Map.entry(amountRegex, GiveItemParameters::setAmount), + Map.entry(constellationRegex, GiveItemParameters::setConstellation), + Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); private static Avatar makeAvatar(GiveItemParameters param) { - return makeAvatar(param.avatarData, param.lvl, Avatar.getMinPromoteLevel(param.lvl), param.constellation, param.skillLevel); + return makeAvatar( + param.avatarData, + param.lvl, + Avatar.getMinPromoteLevel(param.lvl), + param.constellation, + param.skillLevel); } - private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { + private static Avatar makeAvatar( + AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { Avatar avatar = new Avatar(avatarData); avatar.setLevel(level); avatar.setPromoteLevel(promoteLevel); - avatar.getSkillDepot().getSkillsAndEnergySkill().forEach(id -> avatar.setSkillLevel(id, skillLevel)); + avatar + .getSkillDepot() + .getSkillsAndEnergySkill() + .forEach(id -> avatar.setSkillLevel(id, skillLevel)); avatar.forceConstellationLevel(constellation); avatar.recalcStats(true); avatar.save(); @@ -47,13 +70,16 @@ public final class GiveCommand implements CommandHandler { private static void giveAllAvatars(Player player, GiveItemParameters param) { int promoteLevel = Avatar.getMinPromoteLevel(param.lvl); if (param.constellation < 0 || param.constellation > 6) - param.constellation = 6; // constellation's default is -1 so if no parameters set for constellations it'll + param.constellation = + 6; // constellation's default is -1 so if no parameters set for constellations it'll // automatically be 6 for (AvatarData avatarData : GameData.getAvatarDataMap().values()) { int id = avatarData.getId(); if (id < 10000002 || id >= 11000000) continue; // Exclude test avatars // Don't try to add each avatar to the current team - player.addAvatar(makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), false); + player.addAvatar( + makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), + false); } } @@ -93,7 +119,7 @@ public final class GiveCommand implements CommandHandler { item.setTotalExp(totalExp); int numAffixes = param.data.getAppendPropNum() + (param.lvl - 1) / 4; if (param.mainPropId > 0) // Keep random mainProp if we didn't specify one - item.setMainPropId(param.mainPropId); + item.setMainPropId(param.mainPropId); if (param.appendPropIdList != null) { item.getAppendPropIdList().clear(); item.getAppendPropIdList().addAll(param.appendPropIdList); @@ -105,14 +131,17 @@ public final class GiveCommand implements CommandHandler { return items; } - private static int getArtifactMainProp(ItemData itemData, FightProperty prop) throws IllegalArgumentException { + private static int getArtifactMainProp(ItemData itemData, FightProperty prop) + throws IllegalArgumentException { if (prop != FightProperty.FIGHT_PROP_NONE) - for (ReliquaryMainPropData data : GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) + for (ReliquaryMainPropData data : + GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) if (data.getWeight() > 0 && data.getFightProp() == prop) return data.getId(); throw new IllegalArgumentException(); } - private static List getArtifactAffixes(ItemData itemData, FightProperty prop) throws IllegalArgumentException { + private static List getArtifactAffixes(ItemData itemData, FightProperty prop) + throws IllegalArgumentException { if (prop == FightProperty.FIGHT_PROP_NONE) { throw new IllegalArgumentException(); } @@ -125,7 +154,8 @@ public final class GiveCommand implements CommandHandler { return affixes; } - private static int getAppendPropId(String substatText, ItemData itemData) throws IllegalArgumentException { + private static int getAppendPropId(String substatText, ItemData itemData) + throws IllegalArgumentException { // If the given substat text is an integer, we just use that as the append prop ID. try { return Integer.parseInt(substatText); @@ -142,7 +172,8 @@ public final class GiveCommand implements CommandHandler { substatTier = Integer.parseInt(substatArgs[1]); } - List substats = getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); + List substats = + getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); if (substats.isEmpty()) { throw new IllegalArgumentException(); @@ -154,7 +185,8 @@ public final class GiveCommand implements CommandHandler { } } - private static void parseRelicArgs(GiveItemParameters param, List args) throws IllegalArgumentException { + private static void parseRelicArgs(GiveItemParameters param, List args) + throws IllegalArgumentException { // Get the main stat from the arguments. // If the given argument is an integer, we use that. // If not, we check if the argument string is in the main prop map. @@ -164,7 +196,8 @@ public final class GiveCommand implements CommandHandler { param.mainPropId = Integer.parseInt(mainPropIdString); } catch (NumberFormatException ignored) { // This can in turn throw an exception which we don't want to catch here. - param.mainPropId = getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); + param.mainPropId = + getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); } // Get substats. @@ -245,7 +278,8 @@ public final class GiveCommand implements CommandHandler { giveAllWeapons(player, param); } - private GiveItemParameters parseArgs(Player sender, List args) throws IllegalArgumentException { + private GiveItemParameters parseArgs(Player sender, List args) + throws IllegalArgumentException { GiveItemParameters param = new GiveItemParameters(); // Extract any tagged arguments (e.g. "lv90", "x100", "r5") @@ -287,7 +321,9 @@ public final class GiveCommand implements CommandHandler { param.avatarData = GameData.getAvatarDataMap().get(param.id - 1000 + 10_000_000); isRelic = ((param.data != null) && (param.data.getItemType() == ItemType.ITEM_RELIQUARY)); - if (!isRelic && !args.isEmpty() && (param.amount == 1)) { // A concession for the people that truly hate [x]. + if (!isRelic + && !args.isEmpty() + && (param.amount == 1)) { // A concession for the people that truly hate [x]. try { param.amount = Integer.parseInt(args.remove(0)); } catch (NumberFormatException e) { @@ -365,7 +401,8 @@ public final class GiveCommand implements CommandHandler { if (param.avatarData != null) { Avatar avatar = makeAvatar(param); targetPlayer.addAvatar(avatar); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage( + sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); return; } // If it's not an avatar, it needs to be a valid item @@ -376,37 +413,54 @@ public final class GiveCommand implements CommandHandler { switch (param.data.getItemType()) { case ITEM_WEAPON: - targetPlayer.getInventory().addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_with_level_and_refinement", param.id, param.lvl, param.refinement, param.amount, targetPlayer.getUid()); + targetPlayer + .getInventory() + .addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage( + sender, + "commands.give.given_with_level_and_refinement", + param.id, + param.lvl, + param.refinement, + param.amount, + targetPlayer.getUid()); return; case ITEM_RELIQUARY: targetPlayer.getInventory().addItems(makeArtifacts(param), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given_level", param.id, param.lvl, param.amount, targetPlayer.getUid()); + CommandHandler.sendTranslatedMessage( + sender, + "commands.give.given_level", + param.id, + param.lvl, + param.amount, + targetPlayer.getUid()); return; default: - targetPlayer.getInventory().addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); - CommandHandler.sendTranslatedMessage(sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); + targetPlayer + .getInventory() + .addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); + CommandHandler.sendTranslatedMessage( + sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); } } catch (IllegalArgumentException ignored) { } } private enum GiveAllType { - NONE, ALL, WEAPONS, MATS, AVATARS + NONE, + ALL, + WEAPONS, + MATS, + AVATARS } private static class GiveItemParameters { public int id; - @Setter - public int lvl = 0; - @Setter - public int amount = 1; - @Setter - public int refinement = 1; - @Setter - public int constellation = -1; - @Setter - public int skillLevel = 1; + @Setter public int lvl = 0; + @Setter public int amount = 1; + @Setter public int refinement = 1; + @Setter public int constellation = -1; + @Setter public int skillLevel = 1; public int mainPropId = -1; public List appendPropIdList; public ItemData data; diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index 4c0f60907..5f21dae4a 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -24,8 +24,7 @@ public final class SendMailCommand implements CommandHandler { // the command system (again). For now this will do // Key = User that is constructing the mail. - private static final HashMap mailBeingConstructed = - new HashMap<>(); + private static final HashMap mailBeingConstructed = new HashMap<>(); // Yes this is awful and I hate it. @Override diff --git a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java index d16c97213..70e7fc6c2 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java @@ -95,7 +95,8 @@ public final class SetSceneTagCommand implements CommandHandler { // Only remove for big world as some other scenes only have defaults .filter(sceneTag -> sceneTag.getSceneId() == 3) .forEach( - sceneTag -> targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); + sceneTag -> + targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); this.setSceneTags(targetPlayer); } diff --git a/src/main/java/emu/grasscutter/data/DataLoader.java b/src/main/java/emu/grasscutter/data/DataLoader.java index 0d19c11f0..8a91fac9d 100644 --- a/src/main/java/emu/grasscutter/data/DataLoader.java +++ b/src/main/java/emu/grasscutter/data/DataLoader.java @@ -4,8 +4,6 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.JsonUtils; import emu.grasscutter.utils.TsvUtils; -import lombok.val; - import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -14,6 +12,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import java.util.Map; +import lombok.val; public class DataLoader { @@ -36,7 +35,7 @@ public class DataLoader { * * @param resourcePath The path to the data file to be loaded. * @return InputStreamReader of the data file. - * @throws IOException If the file is not found. + * @throws IOException If the file is not found. * @throws FileNotFoundException If the file is not found. * @see #load(String, boolean) */ @@ -50,19 +49,22 @@ public class DataLoader { * Load a data file by its name. * * @param resourcePath The path to the data file to be loaded. - * @param useFallback If the file does not exist in the /data directory, should it use the default - * file in the jar? + * @param useFallback If the file does not exist in the /data directory, should it use the default + * file in the jar? * @return InputStream of the data file. * @throws FileNotFoundException If the file is not found. */ - public static InputStream load(String resourcePath, boolean useFallback) throws FileNotFoundException { - Path path = useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); + public static InputStream load(String resourcePath, boolean useFallback) + throws FileNotFoundException { + Path path = + useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); if (Files.exists(path)) { // Data is in the resource directory try { return Files.newInputStream(path); } catch (IOException e) { - throw new FileNotFoundException(e.getMessage()); // This is evil but so is changing the function signature at this point + throw new FileNotFoundException( + e.getMessage()); // This is evil but so is changing the function signature at this point } } return null; @@ -80,13 +82,15 @@ public class DataLoader { } } - public static Map loadMap(String resourcePath, Class keyType, Class valueType) throws IOException { + public static Map loadMap( + String resourcePath, Class keyType, Class valueType) throws IOException { try (InputStreamReader reader = loadReader(resourcePath)) { return JsonUtils.loadToMap(reader, keyType, valueType); } } - public static List loadTableToList(String resourcePath, Class classType) throws IOException { + public static List loadTableToList(String resourcePath, Class classType) + throws IOException { val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); Grasscutter.getLogger().trace("Loading data table from: {}", path); return switch (FileUtils.getFileExtension(path)) { diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index be1d2a25e..96735f346 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -630,15 +630,21 @@ public final class GameData { // Non-nullable value getters public static int getAvatarLevelExpRequired(int level) { - return Optional.ofNullable(avatarLevelDataMap.get(level)).map(AvatarLevelData::getExp).orElse(0); + return Optional.ofNullable(avatarLevelDataMap.get(level)) + .map(AvatarLevelData::getExp) + .orElse(0); } public static int getAvatarFetterLevelExpRequired(int level) { - return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(AvatarFetterLevelData::getExp).orElse(0); + return Optional.ofNullable(avatarFetterLevelDataMap.get(level)) + .map(AvatarFetterLevelData::getExp) + .orElse(0); } public static int getRelicExpRequired(int rankLevel, int level) { - return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(ReliquaryLevelData::getExp).orElse(0); + return Optional.ofNullable(getRelicLevelData(rankLevel, level)) + .map(ReliquaryLevelData::getExp) + .orElse(0); } // Generic getter @@ -655,7 +661,7 @@ public final class GameData { field.setAccessible(false); } catch (Exception e) { Grasscutter.getLogger() - .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); + .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); } return map; diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index d7e7df051..3d14cc4d2 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -140,27 +140,28 @@ public final class ResourceLoader { getResourceDefClassesPrioritySets() .forEach( - classes -> classes.stream() - .parallel() - .unordered() - .forEach( - c -> { - val type = c.getAnnotation(ResourceType.class); - if (type == null) return; + classes -> + classes.stream() + .parallel() + .unordered() + .forEach( + c -> { + val type = c.getAnnotation(ResourceType.class); + if (type == null) return; - val map = GameData.getMapByResourceDef(c); - if (map == null) return; + val map = GameData.getMapByResourceDef(c); + if (map == null) return; - try { - loadFromResource(c, type, map, doReload); - } catch (Exception e) { - errors.add(Pair.of(Arrays.toString(type.name()), e)); - } - })); + try { + loadFromResource(c, type, map, doReload); + } catch (Exception e) { + errors.add(Pair.of(Arrays.toString(type.name()), e)); + } + })); errors.forEach( pair -> - Grasscutter.getLogger() - .error("Error loading resource file: {}", pair.left(), pair.right())); + Grasscutter.getLogger() + .error("Error loading resource file: {}", pair.left(), pair.right())); long endTime = System.nanoTime(); long ns = (endTime - startTime); // divide by 1000000 to get milliseconds. Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000); @@ -168,7 +169,7 @@ public final class ResourceLoader { @SuppressWarnings("rawtypes") private static void loadFromResource( - Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { + Class c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { val simpleName = c.getSimpleName(); if (doReload || !loadedResources.contains(simpleName)) { for (String name : type.name()) { @@ -281,7 +282,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); + .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneRouteData folder."); } @@ -402,7 +403,7 @@ public final class ResourceLoader { .forEach(data -> loadAbilityData(data.Default)); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path {}: ", path.toString(), e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -464,7 +465,7 @@ public final class ResourceLoader { path, String.class, new TypeToken>() {}.getType())); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading ability modifiers from path {}: ", path.toString(), e); + .error("Error loading ability modifiers from path {}: ", path.toString(), e); } } @@ -531,7 +532,7 @@ public final class ResourceLoader { }); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading open config: no files found in {}", folderName); + .error("Error loading open config: no files found in {}", folderName); return; } } @@ -587,7 +588,7 @@ public final class ResourceLoader { } Grasscutter.getLogger() - .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); + .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); } public static void loadScriptSceneData() { @@ -605,7 +606,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); + .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); } catch (IOException e) { Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty."); } @@ -629,7 +630,9 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} HomeworldDefaultSaveDatas.", GameData.getHomeworldDefaultSaveData().size()); + .debug( + "Loaded {} HomeworldDefaultSaveDatas.", + GameData.getHomeworldDefaultSaveData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder."); } @@ -654,7 +657,7 @@ public final class ResourceLoader { } }); Grasscutter.getLogger() - .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); + .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); } catch (IOException e) { Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder."); } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java index a7b1ee98a..c191368e7 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityEmbryoEntry.java @@ -13,5 +13,4 @@ public class AbilityEmbryoEntry { this.name = avatarName; this.abilities = array; } - } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java index 9fa16b9ca..72030788b 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityMixinData.java @@ -3,14 +3,12 @@ package emu.grasscutter.data.binout; import com.google.gson.*; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; - import java.io.Serial; import java.io.Serializable; import java.util.*; public class AbilityMixinData implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public enum Type { AttachToGadgetStateMixin, diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 099bb49ce..937944812 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -3,14 +3,12 @@ package emu.grasscutter.data.binout; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.game.props.ElementType; - import java.io.Serial; import java.io.Serializable; import lombok.ToString; public class AbilityModifier implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public State state; diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java index 8787b5304..c829c0936 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifierEntry.java @@ -1,18 +1,14 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class AbilityModifierEntry { public final List onModifierAdded; - @Getter - public final List onThinkInterval; - @Getter - public final List onRemoved; - @Getter - private final String name; // Custom value + @Getter public final List onThinkInterval; + @Getter public final List onRemoved; + @Getter private final String name; // Custom value public AbilityModifierEntry(String name) { this.name = name; @@ -24,5 +20,4 @@ public class AbilityModifierEntry { public List getOnAdded() { return onModifierAdded; } - } diff --git a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java index 72e427294..6ec95006c 100644 --- a/src/main/java/emu/grasscutter/data/binout/MainQuestData.java +++ b/src/main/java/emu/grasscutter/data/binout/MainQuestData.java @@ -8,25 +8,17 @@ import lombok.Data; import lombok.Getter; public class MainQuestData { - @Getter - private int id; + @Getter private int id; private int ICLLDPJFIMA; - @Getter - private int series; - @Getter - private QuestType type; + @Getter private int series; + @Getter private QuestType type; - @Getter - private long titleTextMapHash; - @Getter - private int[] suggestTrackMainQuestList; - @Getter - private int[] rewardIdList; + @Getter private long titleTextMapHash; + @Getter private int[] suggestTrackMainQuestList; + @Getter private int[] rewardIdList; - @Getter - private SubQuestData[] subQuests; - @Getter - private List talks; + @Getter private SubQuestData[] subQuests; + @Getter private List talks; private long[] preloadLuaList; public void onLoad() { diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index 21a301207..54735a129 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -1,9 +1,8 @@ package emu.grasscutter.data.binout; import emu.grasscutter.data.ResourceLoader.OpenConfigData; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class OpenConfigEntry { @@ -46,6 +45,5 @@ public class OpenConfigEntry { this.skillId = skillId; this.delta = delta; } - } } diff --git a/src/main/java/emu/grasscutter/data/common/CurveInfo.java b/src/main/java/emu/grasscutter/data/common/CurveInfo.java index ffb6ae2be..bcc6fd8f5 100644 --- a/src/main/java/emu/grasscutter/data/common/CurveInfo.java +++ b/src/main/java/emu/grasscutter/data/common/CurveInfo.java @@ -7,5 +7,4 @@ public class CurveInfo { private String type; private String arith; private float value; - } diff --git a/src/main/java/emu/grasscutter/data/common/ItemUseData.java b/src/main/java/emu/grasscutter/data/common/ItemUseData.java index bd09ca4d8..92341b325 100644 --- a/src/main/java/emu/grasscutter/data/common/ItemUseData.java +++ b/src/main/java/emu/grasscutter/data/common/ItemUseData.java @@ -5,8 +5,7 @@ import lombok.Getter; public class ItemUseData { private ItemUseOp useOp; - @Getter - private String[] useParam; + @Getter private String[] useParam; public ItemUseOp getUseOp() { if (useOp == null) { @@ -14,5 +13,4 @@ public class ItemUseData { } return useOp; } - } diff --git a/src/main/java/emu/grasscutter/data/common/OpenCondData.java b/src/main/java/emu/grasscutter/data/common/OpenCondData.java index 8627c681f..e3658a75e 100644 --- a/src/main/java/emu/grasscutter/data/common/OpenCondData.java +++ b/src/main/java/emu/grasscutter/data/common/OpenCondData.java @@ -1,8 +1,7 @@ package emu.grasscutter.data.common; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class OpenCondData { diff --git a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java index 8c60834b2..a0e6c1bbe 100644 --- a/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java +++ b/src/main/java/emu/grasscutter/data/common/PropGrowCurve.java @@ -6,5 +6,4 @@ import lombok.Getter; public class PropGrowCurve { private String type; private String growCurve; - } diff --git a/src/main/java/emu/grasscutter/data/excels/CombineData.java b/src/main/java/emu/grasscutter/data/excels/CombineData.java index d15de8ff2..430eaefda 100644 --- a/src/main/java/emu/grasscutter/data/excels/CombineData.java +++ b/src/main/java/emu/grasscutter/data/excels/CombineData.java @@ -2,35 +2,24 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; import java.util.stream.Collectors; +import lombok.Getter; @ResourceType(name = "CombineExcelConfigData.json") public class CombineData extends GameResource { - @Getter - private int combineId; - @Getter - private int playerLevel; + @Getter private int combineId; + @Getter private int playerLevel; private boolean isDefaultShow; - @Getter - private int combineType; - @Getter - private int subCombineType; - @Getter - private int resultItemId; - @Getter - private int resultItemCount; - @Getter - private int scoinCost; - @Getter - private List randomItems; - @Getter - private List materialItems; - @Getter - private String recipeType; + @Getter private int combineType; + @Getter private int subCombineType; + @Getter private int resultItemId; + @Getter private int resultItemCount; + @Getter private int scoinCost; + @Getter private List randomItems; + @Getter private List materialItems; + @Getter private String recipeType; @Override public int getId() { @@ -50,5 +39,4 @@ public class CombineData extends GameResource { public boolean isDefaultShow() { return isDefaultShow; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java index 9612eb3ed..8c51cfde2 100644 --- a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java @@ -2,18 +2,15 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType( name = "EnvAnimalGatherExcelConfigData.json", loadPriority = ResourceType.LoadPriority.LOW) public class EnvAnimalGatherConfigData extends GameResource { - @Getter - private int animalId; - @Getter - private String entityType; + @Getter private int animalId; + @Getter private String entityType; private List gatherItemId; private String excludeWeathers; private int aliveTime; diff --git a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java index 194ef810f..d566c422d 100644 --- a/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java +++ b/src/main/java/emu/grasscutter/data/excels/EquipAffixData.java @@ -2,25 +2,19 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.FightPropData; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "EquipAffixExcelConfigData.json") public class EquipAffixData extends GameResource { private int affixId; private int id; - @Getter - private int level; - @Getter - private long nameTextMapHash; - @Getter - private String openConfig; - @Getter - private FightPropData[] addProps; - @Getter - private float[] paramList; + @Getter private int level; + @Getter private long nameTextMapHash; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java index 7097e7c7c..7b4dce107 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterCharacterCardData.java @@ -7,8 +7,7 @@ import lombok.Getter; @ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class FetterCharacterCardData extends GameResource { private int avatarId; - @Getter - private int rewardId; + @Getter private int rewardId; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/FetterData.java b/src/main/java/emu/grasscutter/data/excels/FetterData.java index 94c42c217..24401a900 100644 --- a/src/main/java/emu/grasscutter/data/excels/FetterData.java +++ b/src/main/java/emu/grasscutter/data/excels/FetterData.java @@ -3,9 +3,8 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.OpenCondData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType( name = { @@ -17,8 +16,7 @@ import java.util.List; }, loadPriority = LoadPriority.HIGHEST) public class FetterData extends GameResource { - @Getter - private int avatarId; + @Getter private int avatarId; private int fetterId; private List openCond; diff --git a/src/main/java/emu/grasscutter/data/excels/GatherData.java b/src/main/java/emu/grasscutter/data/excels/GatherData.java index 716974af9..2eca6b64c 100644 --- a/src/main/java/emu/grasscutter/data/excels/GatherData.java +++ b/src/main/java/emu/grasscutter/data/excels/GatherData.java @@ -7,12 +7,9 @@ import lombok.Getter; public class GatherData extends GameResource { private int pointType; private int id; - @Getter - private int gadgetId; - @Getter - private int itemId; - @Getter - private int cd; // Probably hours + @Getter private int gadgetId; + @Getter private int itemId; + @Getter private int cd; // Probably hours private boolean isForbidGuest; private boolean initDisableInteract; diff --git a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java index fb17b3594..671e712a8 100644 --- a/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java +++ b/src/main/java/emu/grasscutter/data/excels/ProudSkillData.java @@ -25,7 +25,8 @@ public class ProudSkillData extends GameResource { @Getter private long nameTextMapHash; @Transient private Iterable totalCostItems; - @Transient @Getter private final Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); + @Transient @Getter + private final Object2FloatMap paramListMap = new Object2FloatOpenHashMap<>(); @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/RewardData.java b/src/main/java/emu/grasscutter/data/excels/RewardData.java index ecf799e05..6a076a49a 100644 --- a/src/main/java/emu/grasscutter/data/excels/RewardData.java +++ b/src/main/java/emu/grasscutter/data/excels/RewardData.java @@ -2,15 +2,13 @@ package emu.grasscutter.data.excels; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType(name = "RewardExcelConfigData.json") public class RewardData extends GameResource { public int rewardId; - @Getter - public List rewardItemList; + @Getter public List rewardItemList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java index 697ea74a3..4a95ea2ca 100644 --- a/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java +++ b/src/main/java/emu/grasscutter/data/excels/ShopGoodsData.java @@ -4,38 +4,26 @@ import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.*; import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.game.shop.ShopInfo; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @ResourceType(name = "ShopGoodsExcelConfigData.json") public class ShopGoodsData extends GameResource { - @Getter - private int goodsId; - @Getter - private int shopType; - @Getter - private int itemId; + @Getter private int goodsId; + @Getter private int shopType; + @Getter private int itemId; - @Getter - private int itemCount; + @Getter private int itemCount; - @Getter - private int costScoin; - @Getter - private int costHcoin; - @Getter - private int costMcoin; + @Getter private int costScoin; + @Getter private int costHcoin; + @Getter private int costMcoin; - @Getter - private List costItems; - @Getter - private int minPlayerLevel; - @Getter - private int maxPlayerLevel; + @Getter private List costItems; + @Getter private int minPlayerLevel; + @Getter private int maxPlayerLevel; - @Getter - private int buyLimit; + @Getter private int buyLimit; @Getter @SerializedName( @@ -46,8 +34,7 @@ public class ShopGoodsData extends GameResource { private String refreshType; private transient ShopInfo.ShopRefreshType refreshTypeEnum; - @Getter - private int refreshParam; + @Getter private int refreshParam; @Override public void onLoad() { @@ -71,5 +58,4 @@ public class ShopGoodsData extends GameResource { public ShopInfo.ShopRefreshType getRefreshType() { return refreshTypeEnum; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java index 47b4db756..dc611d29c 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCostumeData.java @@ -9,12 +9,9 @@ public class AvatarCostumeData extends GameResource { @SerializedName(value = "skinId", alternate = "costumeId") private int skinId; - @Getter - private int itemId; - @Getter - private int characterId; - @Getter - private int quality; + @Getter private int itemId; + @Getter private int characterId; + @Getter private int quality; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java index 5b201156f..9ede54999 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarCurveData.java @@ -2,15 +2,13 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.CurveInfo; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @ResourceType(name = "AvatarCurveExcelConfigData.json") public class AvatarCurveData extends GameResource { - @Getter - private int level; + @Getter private int level; private CurveInfo[] curveInfos; private Map curveInfoMap; diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java index 8799c1ba6..105e55d29 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarFlycloakData.java @@ -6,8 +6,7 @@ import lombok.Getter; @ResourceType(name = "AvatarFlycloakExcelConfigData.json") public class AvatarFlycloakData extends GameResource { private int flycloakId; - @Getter - private long nameTextMapHash; + @Getter private long nameTextMapHash; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java index a2d30b13d..a26fe6c3a 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarLevelData.java @@ -13,5 +13,4 @@ public class AvatarLevelData extends GameResource { public int getId() { return this.level; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java index b871929fc..acf0d826c 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarPromoteData.java @@ -2,26 +2,19 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "AvatarPromoteExcelConfigData.json") public class AvatarPromoteData extends GameResource { - @Getter - private int avatarPromoteId; - @Getter - private int promoteLevel; + @Getter private int avatarPromoteId; + @Getter private int promoteLevel; private int scoinCost; - @Getter - private ItemParamData[] costItems; - @Getter - private int unlockMaxLevel; - @Getter - private FightPropData[] addProps; - @Getter - private int requiredPlayerLevel; + @Getter private ItemParamData[] costItems; + @Getter private int unlockMaxLevel; + @Getter private FightPropData[] addProps; + @Getter private int requiredPlayerLevel; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java index 291f75877..d317edf43 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarTalentData.java @@ -3,28 +3,20 @@ package emu.grasscutter.data.excels.avatar; import emu.grasscutter.data.*; import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.common.FightPropData; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) public class AvatarTalentData extends GameResource { private int talentId; private int prevTalent; - @Getter - private long nameTextMapHash; - @Getter - private String icon; - @Getter - private int mainCostItemId; - @Getter - private int mainCostItemCount; - @Getter - private String openConfig; - @Getter - private FightPropData[] addProps; - @Getter - private float[] paramList; + @Getter private long nameTextMapHash; + @Getter private String icon; + @Getter private int mainCostItemId; + @Getter private int mainCostItemCount; + @Getter private String openConfig; + @Getter private FightPropData[] addProps; + @Getter private float[] paramList; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java index 547d89f8b..4969e350a 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexQuestData.java @@ -5,14 +5,10 @@ import lombok.Getter; @ResourceType(name = {"QuestCodexExcelConfigData.json"}) public class CodexQuestData extends GameResource { - @Getter - private int Id; - @Getter - private int parentQuestId; - @Getter - private int chapterId; - @Getter - private int sortOrder; + @Getter private int Id; + @Getter private int parentQuestId; + @Getter private int chapterId; + @Getter private int sortOrder; private boolean isDisuse; public boolean getIsDisuse() { diff --git a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java index a7124bda1..30e7e4a62 100644 --- a/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java +++ b/src/main/java/emu/grasscutter/data/excels/codex/CodexWeaponData.java @@ -5,13 +5,10 @@ import lombok.Getter; @ResourceType(name = {"WeaponCodexExcelConfigData.json"}) public class CodexWeaponData extends GameResource { - @Getter - private int Id; - @Getter - private int weaponId; + @Getter private int Id; + @Getter private int weaponId; private int gadgetId; - @Getter - private int sortOrder; + @Getter private int sortOrder; public int getGadgetId() { return weaponId; diff --git a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java index fd9722f1f..cdd5aab13 100644 --- a/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/dungeon/DungeonChallengeConfigData.java @@ -9,8 +9,7 @@ import lombok.Getter; @Getter @ResourceType(name = "DungeonChallengeConfigData.json") public class DungeonChallengeConfigData extends GameResource { - @Getter - private int id; + @Getter private int id; private ChallengeType challengeType; private boolean noSuccessHint; private boolean noFailHint; @@ -43,7 +42,7 @@ public class DungeonChallengeConfigData extends GameResource { alternate = {"NJBJIKAIENN"}) private AllowAnimationType animationOnSubFail; - public enum InterruptButtonType { + public enum InterruptButtonType { INTERRUPT_BUTTON_TYPE_NONE, INTERRUPT_BUTTON_TYPE_HOST, INTERRUPT_BUTTON_TYPE_ALL diff --git a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java index 153c0777e..05eb34e1e 100644 --- a/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java +++ b/src/main/java/emu/grasscutter/data/excels/reliquary/ReliquarySetData.java @@ -7,8 +7,7 @@ import lombok.Getter; @ResourceType(name = "ReliquarySetExcelConfigData.json") public class ReliquarySetData extends GameResource { private int setId; - @Getter - private int[] setNeedNum; + @Getter private int[] setNeedNum; @Getter @SerializedName( diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java index 321d04e62..77712523d 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java @@ -1,9 +1,8 @@ package emu.grasscutter.data.excels.tower; import emu.grasscutter.data.*; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @ResourceType(name = "TowerScheduleExcelConfigData.json") @@ -28,6 +27,5 @@ public class TowerScheduleData extends GameResource { @Getter public static class ScheduleDetail { private List floorList; - } } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java index 3d326ea6b..a89b36287 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponLevelData.java @@ -13,5 +13,4 @@ public class WeaponLevelData extends GameResource { public int getId() { return this.level; } - } diff --git a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java index 228716f8f..84751156a 100644 --- a/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java +++ b/src/main/java/emu/grasscutter/data/excels/weapon/WeaponPromoteData.java @@ -2,9 +2,8 @@ package emu.grasscutter.data.excels.weapon; import emu.grasscutter.data.*; import emu.grasscutter.data.common.*; -import lombok.Getter; - import java.util.ArrayList; +import lombok.Getter; @Getter @ResourceType(name = "WeaponPromoteExcelConfigData.json") diff --git a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java index 00cc9b87a..0ffc01556 100644 --- a/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java +++ b/src/main/java/emu/grasscutter/data/excels/world/WorldLevelData.java @@ -6,8 +6,7 @@ import lombok.Getter; @ResourceType(name = "WorldLevelExcelConfigData.json") public class WorldLevelData extends GameResource { private int level; - @Getter - private int monsterLevel; + @Getter private int monsterLevel; @Override public int getId() { diff --git a/src/main/java/emu/grasscutter/data/server/Grid.java b/src/main/java/emu/grasscutter/data/server/Grid.java index c42431c30..126e24768 100644 --- a/src/main/java/emu/grasscutter/data/server/Grid.java +++ b/src/main/java/emu/grasscutter/data/server/Grid.java @@ -5,9 +5,8 @@ import com.github.davidmoten.rtreemulti.geometry.Geometry; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.SceneIndexManager; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class Grid { public transient RTree>, Geometry> gridOptimized = null; @@ -18,8 +17,7 @@ public class Grid { * * @return The correctly loaded grid map. */ - @Getter - public Map> grid = new LinkedHashMap<>(); + @Getter public Map> grid = new LinkedHashMap<>(); /** Creates an optimized cache of the grid. */ private void optimize() { diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index d1b149adc..4847a19cb 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -550,7 +550,7 @@ public final class DatabaseHelper { .first(); } catch (IllegalArgumentException e) { Grasscutter.getLogger() - .debug("Error occurred while getting uid {}'s achievement data", uid, e); + .debug("Error occurred while getting uid {}'s achievement data", uid, e); DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid)); return null; } diff --git a/src/main/java/emu/grasscutter/database/DatabaseManager.java b/src/main/java/emu/grasscutter/database/DatabaseManager.java index 52fc274f7..0330d64a3 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseManager.java +++ b/src/main/java/emu/grasscutter/database/DatabaseManager.java @@ -14,8 +14,7 @@ import emu.grasscutter.game.Account; import lombok.Getter; public final class DatabaseManager { - @Getter - private static Datastore gameDatastore; + @Getter private static Datastore gameDatastore; private static Datastore dispatchDatastore; public static Datastore getAccountDatastore() { diff --git a/src/main/java/emu/grasscutter/game/Account.java b/src/main/java/emu/grasscutter/game/Account.java index 35f54dafd..4c66ebedf 100644 --- a/src/main/java/emu/grasscutter/game/Account.java +++ b/src/main/java/emu/grasscutter/game/Account.java @@ -7,16 +7,13 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.utils.*; import java.util.*; import java.util.stream.Stream; - import lombok.Getter; import lombok.Setter; import org.bson.Document; @Entity(value = "accounts", useDiscriminator = false) public class Account { - @Setter - @Getter - @Id private String id; + @Setter @Getter @Id private String id; @Setter @Getter @@ -24,38 +21,21 @@ public class Account { @Collation(locale = "simple", caseLevel = true) private String username; - @Setter - @Getter - private String password; // Unused for now + @Setter @Getter private String password; // Unused for now private int reservedPlayerId; - @Setter - private String email; + @Setter private String email; - @Setter - @Getter - private String token; - @Getter - private String sessionKey; // Session token for dispatch server - /** - * -- GETTER -- - * The collection of a player's permissions. - */ - @Getter - private final List permissions; - @Setter - @Getter - private Locale locale; + @Setter @Getter private String token; + @Getter private String sessionKey; // Session token for dispatch server + /** -- GETTER -- The collection of a player's permissions. */ + @Getter private final List permissions; - @Setter - @Getter - private String banReason; - @Setter - @Getter - private int banEndTime; - @Setter - @Getter - private int banStartTime; + @Setter @Getter private Locale locale; + + @Setter @Getter private String banReason; + @Setter @Getter private int banEndTime; + @Setter @Getter private int banStartTime; private boolean isBanned; @Deprecated diff --git a/src/main/java/emu/grasscutter/game/ability/Ability.java b/src/main/java/emu/grasscutter/game/ability/Ability.java index 76263f87c..92ee5c080 100644 --- a/src/main/java/emu/grasscutter/game/ability/Ability.java +++ b/src/main/java/emu/grasscutter/game/ability/Ability.java @@ -22,7 +22,8 @@ public class Ability { @Getter private final Object2FloatMap abilitySpecials = new Object2FloatOpenHashMap<>(); @Getter - private static final Map> abilitySpecialsModified = new HashMap<>(); + private static final Map> abilitySpecialsModified = + new HashMap<>(); @Getter private final int hash; @Getter private final Set avatarSkillStartIds; diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 1711c3b06..c23dc5fc1 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -83,12 +83,13 @@ public final class AbilityManager extends BasePlayerManager { boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; if (modifier.onAdded != null) { skillInvincibility |= - !Arrays.stream(modifier.onAdded) - .filter( - action -> - action.type == AbilityModifierAction.Type.AttachAbilityStateResistance - && action.resistanceListID == 11002) - .toList().isEmpty(); + !Arrays.stream(modifier.onAdded) + .filter( + action -> + action.type == AbilityModifierAction.Type.AttachAbilityStateResistance + && action.resistanceListID == 11002) + .toList() + .isEmpty(); } if (this.burstCasterId == entityId @@ -177,7 +178,12 @@ public final class AbilityManager extends BasePlayerManager { public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { Grasscutter.getLogger() - .trace("Ability invoke: {} {} ({}): {}", invoke, invoke.getArgumentType(), invoke.getArgumentTypeValue(), this.player.getScene().getEntityById(invoke.getEntityId())); + .trace( + "Ability invoke: {} {} ({}): {}", + invoke, + invoke.getArgumentType(), + invoke.getArgumentTypeValue(), + this.player.getScene().getEntityById(invoke.getEntityId())); var entity = this.player.getScene().getEntityById(invoke.getEntityId()); if (entity != null) { Grasscutter.getLogger() @@ -204,7 +210,8 @@ public final class AbilityManager extends BasePlayerManager { if (invoke.getHead().getTargetId() != 0) { Grasscutter.getLogger() - .trace("Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); + .trace( + "Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); } if (invoke.getHead().getLocalId() != 0) { this.handleServerInvoke(invoke); diff --git a/src/main/java/emu/grasscutter/game/achievement/Achievements.java b/src/main/java/emu/grasscutter/game/achievement/Achievements.java index d6acf9e11..acc55006e 100644 --- a/src/main/java/emu/grasscutter/game/achievement/Achievements.java +++ b/src/main/java/emu/grasscutter/game/achievement/Achievements.java @@ -61,9 +61,10 @@ public class Achievements { GameData.getAchievementDataMap().values().stream() .filter(AchievementData::isUsed) .forEach( - a -> map.put( - a.getId(), - new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); + a -> + map.put( + a.getId(), + new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); return map; } @@ -175,12 +176,13 @@ public class Achievements { return this.getAchievementList() .computeIfAbsent( achievementId, - id -> new Achievement( - Status.STATUS_UNFINISHED, - id, - GameData.getAchievementDataMap().get(id.intValue()).getProgress(), - 0, - 0)); + id -> + new Achievement( + Status.STATUS_UNFINISHED, + id, + GameData.getAchievementDataMap().get(id.intValue()).getProgress(), + 0, + 0)); } public boolean isInvalid(int achievementId) { @@ -231,7 +233,7 @@ public class Achievements { }); var a = this.getAchievement(i); - if(a == null) { + if (a == null) { Grasscutter.getLogger().warn("null returned while getting achievement!"); return; } diff --git a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java index d13cefb45..222971c3b 100644 --- a/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java +++ b/src/main/java/emu/grasscutter/game/activity/condition/AllActivityConditionBuilder.java @@ -25,7 +25,8 @@ public class AllActivityConditionBuilder { private Map initActivityConditions() { Reflections reflector = Grasscutter.reflector; return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream() - .map(this::newInstance).filter(Objects::nonNull) + .map(this::newInstance) + .filter(Objects::nonNull) .map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h)) .collect( Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index c939c7727..932930b59 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -1,5 +1,7 @@ package emu.grasscutter.game.avatar; +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; + import dev.morphia.annotations.*; import emu.grasscutter.GameConstants; import emu.grasscutter.data.GameData; @@ -44,130 +46,72 @@ import emu.grasscutter.net.proto.TrialAvatarInfoOuterClass.TrialAvatarInfo; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.helpers.ProtoHelper; import it.unimi.dsi.fastutil.ints.*; +import java.util.*; +import java.util.stream.Stream; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; import lombok.val; import org.bson.types.ObjectId; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.*; -import java.util.stream.Stream; - -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; - @Entity(value = "avatars", useDiscriminator = false) public class Avatar { - @Transient - @Getter - private final Int2ObjectMap equips; - @Transient - @Getter - private final Int2FloatOpenHashMap fightProperties; - @Transient - @Getter - private final Int2FloatOpenHashMap fightPropOverrides; - @Id - private ObjectId id; - @Indexed - @Getter - private int ownerId; // Id of player that this avatar belongs to - @Transient - private Player owner; - @Transient - @Getter - private AvatarData avatarData; - @Nullable - @Transient - @Getter - private AvatarSkillDepotData skillDepot; - @Transient - @Getter - private long guid; // Player unique id - @Getter - private int avatarId; // Id of avatar - @Getter - @Setter - private int level = 1; - @Getter - @Setter - private int exp; - @Getter - @Setter - private int promoteLevel; - @Getter - @Setter - private int satiation; // Fullness - @Getter - @Setter - private int satiationPenalty; // When eating too much - @Getter - @Setter - private float currentHp; + @Transient @Getter private final Int2ObjectMap equips; + @Transient @Getter private final Int2FloatOpenHashMap fightProperties; + @Transient @Getter private final Int2FloatOpenHashMap fightPropOverrides; + @Id private ObjectId id; + @Indexed @Getter private int ownerId; // Id of player that this avatar belongs to + @Transient private Player owner; + @Transient @Getter private AvatarData avatarData; + @Nullable @Transient @Getter private AvatarSkillDepotData skillDepot; + @Transient @Getter private long guid; // Player unique id + @Getter private int avatarId; // Id of avatar + @Getter @Setter private int level = 1; + @Getter @Setter private int exp; + @Getter @Setter private int promoteLevel; + @Getter @Setter private int satiation; // Fullness + @Getter @Setter private int satiationPenalty; // When eating too much + @Getter @Setter private float currentHp; private float currentEnergy; - @Transient - @Getter - private Set extraAbilityEmbryos; + @Transient @Getter private Set extraAbilityEmbryos; private List fetters; private final Map skillLevelMap = new Int2IntArrayMap(7); // Talent levels - @Transient - @Getter + @Transient @Getter private final Map skillExtraChargeMap = new Int2IntArrayMap(2); // Charges @Transient - private final Map proudSkillBonusMap = new Int2IntArrayMap(2); // Talent bonus levels (from const) + private final Map proudSkillBonusMap = + new Int2IntArrayMap(2); // Talent bonus levels (from const) - @Getter - private int skillDepotId; + @Getter private int skillDepotId; private Set talentIdList; // Constellation id list - @Getter - private Set proudSkillList; // Character passives + @Getter private Set proudSkillList; // Character passives - @Getter - @Setter - private int flyCloak; - @Getter - @Setter - private int costume; - @Getter - private int bornTime; + @Getter @Setter private int flyCloak; + @Getter @Setter private int costume; + @Getter private int bornTime; - @Getter - @Setter - private int fetterLevel = 1; - @Getter - @Setter - private int fetterExp; + @Getter @Setter private int fetterLevel = 1; + @Getter @Setter private int fetterExp; - @Getter - @Setter - private int nameCardRewardId; - @Getter - @Setter - private int nameCardId; + @Getter @Setter private int nameCardRewardId; + @Getter @Setter private int nameCardId; // trial avatar property - @Getter - @Setter - private int trialAvatarId = 0; + @Getter @Setter private int trialAvatarId = 0; // cannot store to db if grant reason is not integer - @Getter - @Setter + @Getter @Setter private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber(); - @Getter - @Setter - private int fromParentQuestId = 0; + @Getter @Setter private int fromParentQuestId = 0; // so far no outer class or prop value has information of this, but from packet: // 1 = normal, 2 = trial avatar - @Transient - @Getter - @Setter - private int avatarType = Type.NORMAL.getNumber(); + @Transient @Getter @Setter private int avatarType = Type.NORMAL.getNumber(); @Deprecated // Do not use. Morhpia only! public Avatar() { @@ -197,13 +141,18 @@ public class Avatar { this.proudSkillList = new HashSet<>(); // Combat properties - Stream.of(FightProperty.values()).map(FightProperty::getId).filter(id -> (id > 0) && (id < 3000)).forEach(id -> this.setFightProperty(id, 0f)); + Stream.of(FightProperty.values()) + .map(FightProperty::getId) + .filter(id -> (id > 0) && (id < 3000)) + .forEach(id -> this.setFightProperty(id, 0f)); - this.setSkillDepotData(switch (this.getAvatarId()) { - case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); - case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap().get(701); - default -> data.getSkillDepot(); - }); + this.setSkillDepotData( + switch (this.getAvatarId()) { + case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); + case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap() + .get(701); + default -> data.getSkillDepot(); + }); // Set stats this.recalcStats(); @@ -235,7 +184,8 @@ public class Avatar { * @return True if the avatar is a main character. */ public boolean isMainCharacter() { - return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE).contains(this.getAvatarId()); + return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE) + .contains(this.getAvatarId()); } public Player getPlayer() { @@ -297,8 +247,7 @@ public class Avatar { /** * @return The avatar's equipped weapon. */ - @Nullable - public GameItem getWeapon() { + @Nullable public GameItem getWeapon() { return this.getEquipBySlot(EquipType.EQUIP_WEAPON); } @@ -328,17 +277,24 @@ public class Avatar { * Changes this avatar's skill depot. * * @param skillDepot The new skill depot. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. */ public void setSkillDepotData(AvatarSkillDepotData skillDepot, boolean notify) { // Set id and depot this.skillDepotId = skillDepot.getId(); this.skillDepot = skillDepot; // Add any missing skills - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); // Add proud skills this.proudSkillList.clear(); - skillDepot.getInherentProudSkillOpens().stream().filter(openData -> openData.getProudSkillGroupId() > 0).filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()).mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1).filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)).forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); + skillDepot.getInherentProudSkillOpens().stream() + .filter(openData -> openData.getProudSkillGroupId() > 0) + .filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) + .mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1) + .filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)) + .forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); this.recalcStats(); if (notify) { @@ -362,7 +318,7 @@ public class Avatar { * in its 'candSkillDepot's. * * @param elementTypeToChange The new element to change to. - * @param notify Whether to notify the player of the change. + * @param notify Whether to notify the player of the change. * @return True if the element was changed, false otherwise. */ public boolean changeElement(@Nonnull ElementType elementTypeToChange, boolean notify) { @@ -410,7 +366,8 @@ public class Avatar { ElementType element = depot.getElementType(); var maxEnergy = depot.getEnergySkillData().getCostElemVal(); this.setFightProperty(element.getMaxEnergyProp(), maxEnergy); - this.setFightProperty(element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); + this.setFightProperty( + element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); } } @@ -438,10 +395,14 @@ public class Avatar { return getFightProperties().getOrDefault(prop.getId(), 0f); } - public Map getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. + public Map + getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. var map = new Int2IntOpenHashMap(); if (this.skillDepot == null) return map; - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach( + skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); return map; } @@ -450,18 +411,21 @@ public class Avatar { public Map getProudSkillBonusMap() { var map = new Int2IntArrayMap(); if (this.skillDepot == null) return map; - this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> { - val skillData = GameData.getAvatarSkillDataMap().get(skillId); - if (skillData == null) return; - int proudSkillGroupId = skillData.getProudSkillGroupId(); - int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); - int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); - int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); - if (maxLevel > 0) { - bonus = Math.min(bonus, maxLevel - curLevel); - } - map.put(proudSkillGroupId, bonus); - }); + this.skillDepot + .getSkillsAndEnergySkill() + .forEach( + skillId -> { + val skillData = GameData.getAvatarSkillDataMap().get(skillId); + if (skillData == null) return; + int proudSkillGroupId = skillData.getProudSkillGroupId(); + int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); + int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); + int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); + if (maxLevel > 0) { + bonus = Math.min(bonus, maxLevel - curLevel); + } + map.put(proudSkillGroupId, bonus); + }); return map; } @@ -495,7 +459,9 @@ public class Avatar { if (otherAvatar != null) { // Unequip other avatar's item if (otherAvatar.unequipItem(item.getItemData().getEquipType())) { - getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); + getPlayer() + .sendPacket( + new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); } // Swap with other avatar if (getEquips().containsKey(itemEquipType.getValue())) { @@ -513,9 +479,14 @@ public class Avatar { this.getEquips().put(itemEquipType.getValue(), item); if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) { - item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); - this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == getPlayer().getScene())) { + item.setWeaponEntity( + new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); + this.getPlayer() + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); } // item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); } @@ -553,7 +524,8 @@ public class Avatar { public void recalcStats(boolean forceSendAbilityChange) { // Setup var data = this.getAvatarData(); - var promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); + var promoteData = + GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); var setMap = new Int2IntOpenHashMap(); // Extra ability embryos @@ -566,18 +538,27 @@ public class Avatar { this.setNameCardId(data.getNameCardId()); // Get hp percent, set to 100% if none - float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); + float hpPercent = + this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 + ? 1f + : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) + / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); // Store current energy value for later - float currentEnergy = (this.getSkillDepot() != null) ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) : 0f; + float currentEnergy = + (this.getSkillDepot() != null) + ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) + : 0f; // Clear properties this.getFightProperties().clear(); // Base stats this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel())); - this.setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); - this.setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); + this.setFightProperty( + FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); + this.setFightProperty( + FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical()); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt()); this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f); @@ -599,11 +580,14 @@ public class Avatar { continue; } // Artifact main stat - ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); + ReliquaryMainPropData mainPropData = + GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); if (mainPropData != null) { - ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); + ReliquaryLevelData levelData = + GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); if (levelData != null) { - this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); + this.addFightProperty( + mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); } } // Artifact sub stats @@ -620,31 +604,32 @@ public class Avatar { } // Set stuff - setMap.forEach((setId, amount) -> { - ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); - if (setData == null) return; + setMap.forEach( + (setId, amount) -> { + ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); + if (setData == null) return; - // Calculate how many items are from the set - // Add affix data from set bonus - val setNeedNum = setData.getSetNeedNum(); - for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { - if (amount < setNeedNum[setIndex]) break; + // Calculate how many items are from the set + // Add affix data from set bonus + val setNeedNum = setData.getSetNeedNum(); + for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { + if (amount < setNeedNum[setIndex]) break; - int affixId = (setData.getEquipAffixId() * 10) + setIndex; - EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); - if (affix == null) { - continue; - } + int affixId = (setData.getEquipAffixId() * 10) + setIndex; + EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); + if (affix == null) { + continue; + } - // Add properties from this affix to our avatar - for (FightPropData prop : affix.getAddProps()) { - this.addFightProperty(prop.getProp(), prop.getValue()); - } + // Add properties from this affix to our avatar + for (FightPropData prop : affix.getAddProps()) { + this.addFightProperty(prop.getProp(), prop.getValue()); + } - // Add any skill strings from this affix - this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); - } - }); + // Add any skill strings from this affix + this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); + } + }); // Weapon GameItem weapon = this.getWeapon(); @@ -653,11 +638,15 @@ public class Avatar { WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel()); if (curveData != null) { for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) { - this.addFightProperty(weaponProperty.getPropType(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); + this.addFightProperty( + weaponProperty.getPropType(), + weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); } } // Weapon promotion stats - WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); + WeaponPromoteData wepPromoteData = + GameData.getWeaponPromoteData( + weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); if (wepPromoteData != null) { for (FightPropData prop : wepPromoteData.getAddProps()) { if (prop.getValue() == 0f || prop.getProp() == null) { @@ -692,7 +681,8 @@ public class Avatar { } // Add proud skills and unlock them if needed - AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); + AvatarSkillDepotData skillDepot = + GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); this.getProudSkillList().clear(); if (skillDepot != null) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { @@ -725,17 +715,31 @@ public class Avatar { } // Constellations - this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).forEach(this::addToExtraAbilityEmbryos); + this.getTalentIdList() + .intStream() + .mapToObj(GameData.getAvatarTalentDataMap()::get) + .filter(Objects::nonNull) + .map(AvatarTalentData::getOpenConfig) + .filter(Objects::nonNull) + .forEach(this::addToExtraAbilityEmbryos); // Add any skill strings from this constellation // Set % stats - FightProperty.forEachCompoundProperty(c -> this.setFightProperty(c.getResult(), this.getFightProperty(c.getFlat()) + (this.getFightProperty(c.getBase()) * (1f + this.getFightProperty(c.getPercent()))))); + FightProperty.forEachCompoundProperty( + c -> + this.setFightProperty( + c.getResult(), + this.getFightProperty(c.getFlat()) + + (this.getFightProperty(c.getBase()) + * (1f + this.getFightProperty(c.getPercent()))))); // Reapply all overrides this.fightProperties.putAll(this.fightPropOverrides); // Set current hp - this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); + this.setFightProperty( + FightProperty.FIGHT_PROP_CUR_HP, + this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); // Packet if (getPlayer() != null && getPlayer().hasSentLoginPackets()) { @@ -743,7 +747,9 @@ public class Avatar { getPlayer().sendPacket(new PacketAvatarFightPropNotify(this)); // Update client abilities EntityAvatar entity = this.getAsEntity(); - if (entity != null && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) || forceSendAbilityChange)) { + if (entity != null + && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) + || forceSendAbilityChange)) { getPlayer().sendPacket(new PacketAbilityChangeNotify(entity)); } } @@ -781,12 +787,22 @@ public class Avatar { // Check if new constellation adds +3 to a skill level if (this.calcConstellationExtraLevels(entry) && notifyClient) { // Packet - this.getPlayer().sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); + this.getPlayer() + .sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); } // Check if new constellation adds skill charges if (this.calcConstellationExtraCharges(entry) && notifyClient) { // Packet - Stream.of(entry.getSkillPointModifiers()).mapToInt(SkillPointModifier::getSkillId).forEach(skillId -> this.getPlayer().sendPacket(new PacketAvatarSkillMaxChargeCountNotify(this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); + Stream.of(entry.getSkillPointModifiers()) + .mapToInt(SkillPointModifier::getSkillId) + .forEach( + skillId -> + this.getPlayer() + .sendPacket( + new PacketAvatarSkillMaxChargeCountNotify( + this, + skillId, + this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); } } @@ -800,7 +816,16 @@ public class Avatar { return; } - this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).filter(openConfig -> !openConfig.isEmpty()).map(GameData.getOpenConfigEntries()::get).filter(Objects::nonNull).forEach(e -> this.calcConstellation(e, false)); + this.getTalentIdList() + .intStream() + .mapToObj(GameData.getAvatarTalentDataMap()::get) + .filter(Objects::nonNull) + .map(AvatarTalentData::getOpenConfig) + .filter(Objects::nonNull) + .filter(openConfig -> !openConfig.isEmpty()) + .map(GameData.getOpenConfigEntries()::get) + .filter(Objects::nonNull) + .forEach(e -> this.calcConstellation(e, false)); } private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { @@ -820,14 +845,18 @@ public class Avatar { } private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { - if(this.skillDepot == null) return false; - int skillId = switch (entry.getExtraTalentIndex()) { - case 9 -> this.skillDepot.getEnergySkill(); // Ult skill - case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill - case 1 -> - (!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) - default -> 0; - }; + if (this.skillDepot == null) return false; + int skillId = + switch (entry.getExtraTalentIndex()) { + case 9 -> this.skillDepot.getEnergySkill(); // Ult skill + case 2 -> (this.skillDepot.getSkills().size() >= 2) + ? this.skillDepot.getSkills().get(1) + : 0; // E skill + case 1 -> (!this.skillDepot.getSkills().isEmpty()) + ? this.skillDepot.getSkills().get(0) + : 0; // Normal Attack (Liney) + default -> 0; + }; // Sanity check if (skillId == 0) { return false; @@ -846,7 +875,8 @@ public class Avatar { } private int addProudSkillLevelBonus(int proudSkillGroupId, int bonus) { - return this.proudSkillBonusMap.compute(proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); + return this.proudSkillBonusMap.compute( + proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); } public boolean upgradeSkill(int skillId) { @@ -877,7 +907,9 @@ public class Avatar { if (level < 0 || level > 15) return false; var validLevels = GameData.getAvatarSkillLevels(skillId); if (validLevels != null && !validLevels.contains(level)) return false; - int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns + int oldLevel = + this.skillLevelMap.getOrDefault( + skillId, 0); // just taking the return value of put would have null concerns this.skillLevelMap.put(skillId, level); this.save(); @@ -912,7 +944,9 @@ public class Avatar { var player = this.getPlayer(); // Pay constellation item if possible - if (!skipPayment && (player != null) && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { + if (!skipPayment + && (player != null) + && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { return false; } @@ -943,7 +977,8 @@ public class Avatar { this.save(); return; } - this.talentIdList.removeAll(this.getTalentIdList()); // Only remove constellations from active depot + this.talentIdList.removeAll( + this.getTalentIdList()); // Only remove constellations from active depot for (int i = 0; i < level; i++) this.unlockConstellation(true); this.recalcStats(); this.save(); @@ -952,7 +987,12 @@ public class Avatar { public boolean sendSkillExtraChargeMap() { val map = this.getSkillExtraChargeMap(); if (map.isEmpty()) return false; - this.getPlayer().sendPacket(new PacketAvatarSkillInfoNotify(this.guid, new Int2IntArrayMap(map))); // TODO: Remove this allocation when updating interfaces to FastUtils + this.getPlayer() + .sendPacket( + new PacketAvatarSkillInfoNotify( + this.guid, + new Int2IntArrayMap( + map))); // TODO: Remove this allocation when updating interfaces to FastUtils // later return true; } @@ -984,7 +1024,12 @@ public class Avatar { } if (this.fetters != null) { - this.fetters.forEach(fetterId -> avatarFetter.addFetterList(FetterData.newBuilder().setFetterId(fetterId).setFetterState(FetterState.FINISH.getValue()))); + this.fetters.forEach( + fetterId -> + avatarFetter.addFetterList( + FetterData.newBuilder() + .setFetterId(fetterId) + .setFetterState(FetterState.FINISH.getValue()))); } int cardId = this.getNameCardId(); @@ -993,40 +1038,100 @@ public class Avatar { avatarFetter.addRewardedFetterLevelList(10); } - AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder().setAvatarId(this.getAvatarId()).setGuid(this.getGuid()).setLifeState(1).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).putAllSkillLevelMap(this.getSkillLevelMap()).addAllInherentProudSkillList(this.getProudSkillList()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setAvatarType(this.getAvatarType()).setBornTime(this.getBornTime()).setFetterInfo(avatarFetter).setWearingFlycloakId(this.getFlyCloak()).setCostumeId(this.getCostume()); + AvatarInfo.Builder avatarInfo = + AvatarInfo.newBuilder() + .setAvatarId(this.getAvatarId()) + .setGuid(this.getGuid()) + .setLifeState(1) + .addAllTalentIdList(this.getTalentIdList()) + .putAllFightPropMap(this.getFightProperties()) + .setSkillDepotId(this.getSkillDepotId()) + .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) + .putAllSkillLevelMap(this.getSkillLevelMap()) + .addAllInherentProudSkillList(this.getProudSkillList()) + .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) + .setAvatarType(this.getAvatarType()) + .setBornTime(this.getBornTime()) + .setFetterInfo(avatarFetter) + .setWearingFlycloakId(this.getFlyCloak()) + .setCostumeId(this.getCostume()); - this.getSkillExtraChargeMap().forEach((skillId, count) -> avatarInfo.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); + this.getSkillExtraChargeMap() + .forEach( + (skillId, count) -> + avatarInfo.putSkillMap( + skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); this.getEquips().forEach((k, item) -> avatarInfo.addEquipGuidList(item.getGuid())); - avatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - avatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - avatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + avatarInfo.putPropMap( + PlayerProperty.PROP_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + avatarInfo.putPropMap( + PlayerProperty.PROP_EXP.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + avatarInfo.putPropMap( + PlayerProperty.PROP_BREAK_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + avatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_VAL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + avatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), + ProtoHelper.newPropValue( + PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); return avatarInfo.build(); } // used only in character showcase public ShowAvatarInfo toShowAvatarInfoProto() { - AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); + AvatarFetterInfo.Builder avatarFetter = + AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); - ShowAvatarInfo.Builder showAvatarInfo = ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder().setAvatarId(avatarId).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).addAllInherentProudSkillList(this.getProudSkillList()).putAllSkillLevelMap(this.getSkillLevelMap()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setFetterInfo(avatarFetter).setCostumeId(this.getCostume()); + ShowAvatarInfo.Builder showAvatarInfo = + ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder() + .setAvatarId(avatarId) + .addAllTalentIdList(this.getTalentIdList()) + .putAllFightPropMap(this.getFightProperties()) + .setSkillDepotId(this.getSkillDepotId()) + .setCoreProudSkillLevel(this.getCoreProudSkillLevel()) + .addAllInherentProudSkillList(this.getProudSkillList()) + .putAllSkillLevelMap(this.getSkillLevelMap()) + .putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()) + .setFetterInfo(avatarFetter) + .setCostumeId(this.getCostume()); - showAvatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); - showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_EXP.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_BREAK_LEVEL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_VAL.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), + ProtoHelper.newPropValue( + PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA); - showAvatarInfo.putPropMap(PlayerProperty.PROP_MAX_STAMINA.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); + showAvatarInfo.putPropMap( + PlayerProperty.PROP_MAX_STAMINA.getId(), + ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); for (GameItem item : this.getEquips().values()) { if (item.getItemType() == ItemType.ITEM_RELIQUARY) { - showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setReliquary(item.toReliquaryProto())); + showAvatarInfo.addEquipList( + ShowEquip.newBuilder() + .setItemId(item.getItemId()) + .setReliquary(item.toReliquaryProto())); } else if (item.getItemType() == ItemType.ITEM_WEAPON) { - showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); + showAvatarInfo.addEquipList( + ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); } } @@ -1036,12 +1141,13 @@ public class Avatar { /** * Converts this avatar into a trial avatar. * - * @param level The avatar's level. - * @param avatarId The ID of the avatar. + * @param level The avatar's level. + * @param avatarId The ID of the avatar. * @param grantReason The reason for granting the avatar. - * @param questId The ID of the quest that granted the avatar. + * @param questId The ID of the quest that granted the avatar. */ - public void setTrialAvatarInfo(int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { + public void setTrialAvatarInfo( + int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { this.setLevel(level); this.setPromoteLevel(getMinPromoteLevel(level)); this.setTrialAvatarId(avatarId); @@ -1058,7 +1164,10 @@ public class Avatar { * @return The avatar's template. */ private int getTrialTemplate() { - return this.getLevel() <= 9 ? 1 : (int) (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels + return this.getLevel() <= 9 + ? 1 + : (int) + (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels } /** @@ -1080,11 +1189,11 @@ public class Avatar { return trialData.getCoreProudSkillLevel(); // enhanced version of weapon } - /** - * Applies the correct skill level for the trial avatar. - */ + /** Applies the correct skill level for the trial avatar. */ public void applyTrialSkillLevels() { - this.getSkillLevelMap().keySet().forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); + this.getSkillLevelMap() + .keySet() + .forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); } /** @@ -1096,7 +1205,9 @@ public class Avatar { if (GameData.getTrialAvatarDataMap().get(this.getTrialAvatarId()) == null) return this.getAvatarData().getInitialWeapon(); - return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null ? getAvatarData().getInitialWeapon() : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon + return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null + ? getAvatarData().getInitialWeapon() + : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon } // Use custom data. @@ -1104,7 +1215,9 @@ public class Avatar { if (trialData == null) return 0; var trialCustomParams = trialData.getTrialAvatarParamList(); - return trialCustomParams.size() < 2 ? getAvatarData().getInitialWeapon() : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); + return trialCustomParams.size() < 2 + ? getAvatarData().getInitialWeapon() + : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); } /** @@ -1115,7 +1228,8 @@ public class Avatar { if (GameData.getTrialAvatarCustomData().isEmpty()) { int trialAvatarTemplateLevel = getTrialTemplate(); - TrialAvatarTemplateData templateData = GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); + TrialAvatarTemplateData templateData = + GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); return templateData == null ? List.of() : templateData.getTrialReliquaryList(); } @@ -1123,13 +1237,14 @@ public class Avatar { var trialData = GameData.getTrialAvatarCustomData().get(this.getTrialAvatarId()); if (trialData == null) return List.of(); - var trialCustomParams = GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); - return trialCustomParams.size() < 3 ? List.of() : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); + var trialCustomParams = + GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); + return trialCustomParams.size() < 3 + ? List.of() + : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); } - /** - * Applies the correct items for the trial avatar. - */ + /** Applies the correct items for the trial avatar. */ public void applyTrialItems() { // Use an enhanced version of the weapon if available. var weapon = new GameItem(this.getTrialWeaponId()); @@ -1139,44 +1254,55 @@ public class Avatar { this.getEquips().put(weapon.getEquipSlot(), weapon); // Add artifacts for the trial avatar. - this.getTrialReliquary().forEach(id -> { - var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); - if (reliquaryData == null) return; + this.getTrialReliquary() + .forEach( + id -> { + var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); + if (reliquaryData == null) return; - var relic = new GameItem(reliquaryData.getReliquaryId()); - relic.setLevel(reliquaryData.getLevel()); - relic.setMainPropId(reliquaryData.getMainPropId()); - relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); - this.getEquips().put(relic.getEquipSlot(), relic); - }); + var relic = new GameItem(reliquaryData.getReliquaryId()); + relic.setLevel(reliquaryData.getLevel()); + relic.setMainPropId(reliquaryData.getMainPropId()); + relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); + this.getEquips().put(relic.getEquipSlot(), relic); + }); // Add costume if avatar has a costume. if (GAME_OPTIONS.trialCostumes) { - GameData.getAvatarCostumeDataItemIdMap().values().forEach(costumeData -> { - if (costumeData.getCharacterId() != this.getAvatarId()) return; - this.setCostume(costumeData.getId()); - }); + GameData.getAvatarCostumeDataItemIdMap() + .values() + .forEach( + costumeData -> { + if (costumeData.getCharacterId() != this.getAvatarId()) return; + this.setCostume(costumeData.getId()); + }); } } - /** - * Equips the items applied from {@link Avatar#applyTrialItems()}. - */ + /** Equips the items applied from {@link Avatar#applyTrialItems()}. */ public void equipTrialItems() { var player = this.getPlayer(); - this.getEquips().values().forEach(item -> { - item.setEquipCharacter(this.getAvatarId()); - item.setOwner(player); - if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) { - item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); - player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); - } + this.getEquips() + .values() + .forEach( + item -> { + item.setEquipCharacter(this.getAvatarId()); + item.setOwner(player); + if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == player.getScene())) { + item.setWeaponEntity( + new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); + player + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + } - player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); - } - }); + player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); + } + }); } /** @@ -1185,20 +1311,26 @@ public class Avatar { * @return The trial info protocol buffer. */ public TrialAvatarInfo toTrialInfo() { - var trialAvatar = TrialAvatarInfo.newBuilder().setTrialAvatarId(this.getTrialAvatarId()).setGrantRecord(TrialAvatarGrantRecord.newBuilder().setGrantReason(this.getGrantReason()).setFromParentQuestId(this.getFromParentQuestId())); + var trialAvatar = + TrialAvatarInfo.newBuilder() + .setTrialAvatarId(this.getTrialAvatarId()) + .setGrantRecord( + TrialAvatarGrantRecord.newBuilder() + .setGrantReason(this.getGrantReason()) + .setFromParentQuestId(this.getFromParentQuestId())); // Check if the avatar is a trial avatar. if (this.getTrialAvatarId() > 0) { // Add the artifacts and weapons for the avatar. - trialAvatar.addAllTrialEquipList(this.getEquips().values().stream().map(GameItem::toProto).toList()); + trialAvatar.addAllTrialEquipList( + this.getEquips().values().stream().map(GameItem::toProto).toList()); } return trialAvatar.build(); } @PostLoad - private void onLoad() { - } + private void onLoad() {} @PrePersist private void prePersist() { @@ -1208,7 +1340,8 @@ public class Avatar { @AllArgsConstructor @Getter enum Type { - NORMAL(1), TRIAL(2); + NORMAL(1), + TRIAL(2); final int number; } diff --git a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java index 5d30007c6..c75ebaec4 100644 --- a/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java +++ b/src/main/java/emu/grasscutter/game/avatar/AvatarStorage.java @@ -15,14 +15,12 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import lombok.Getter; - import java.util.Iterator; import java.util.List; +import lombok.Getter; public class AvatarStorage extends BasePlayerManager implements Iterable { - @Getter - private final Int2ObjectMap avatars; + @Getter private final Int2ObjectMap avatars; private final Long2ObjectMap avatarsGuid; public AvatarStorage(Player player) { diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java index b22bc7de0..f5b0b1097 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java @@ -9,13 +9,9 @@ import lombok.Setter; @Entity public class BattlePassMission { - @Getter - private int id; - @Setter - @Getter - private int progress; - @Setter - private BattlePassMissionStatus status; + @Getter private int id; + @Setter @Getter private int progress; + @Setter private BattlePassMissionStatus status; @Transient private BattlePassMissionData data; diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java index d37518f45..b25b4ff96 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassReward.java @@ -8,12 +8,9 @@ import lombok.Getter; @Entity public class BattlePassReward { - @Getter - private int level; - @Getter - private int rewardId; - @Getter - private boolean paid; + @Getter private int level; + @Getter private int rewardId; + @Getter private boolean paid; @Transient private BattlePassMissionData data; diff --git a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java index bd1797270..220cdad65 100644 --- a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java +++ b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java @@ -10,10 +10,9 @@ import emu.grasscutter.server.event.player.PlayerChatEvent; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.Utils; -import lombok.Getter; - import java.util.*; import java.util.regex.Pattern; +import lombok.Getter; public class ChatSystem implements ChatSystemHandler { static final String PREFIXES = "[/!]"; @@ -24,8 +23,7 @@ public class ChatSystem implements ChatSystemHandler { // user id -> chat partner id -> [messages] private final Map>> history = new HashMap<>(); - @Getter - private final GameServer server; + @Getter private final GameServer server; public ChatSystem(GameServer server) { this.server = server; diff --git a/src/main/java/emu/grasscutter/game/combine/CombineManger.java b/src/main/java/emu/grasscutter/game/combine/CombineManger.java index 9fff60cf2..61baedec0 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineManger.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineManger.java @@ -27,8 +27,7 @@ public class CombineManger extends BaseGameSystem { // Read the data we need for strongbox. try { DataLoader.loadList("ReliquaryDecompose.json", ReliquaryDecomposeEntry.class) - .forEach( - entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems())); + .forEach(entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems())); Grasscutter.getLogger() .debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size()); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/combine/CombineResult.java b/src/main/java/emu/grasscutter/game/combine/CombineResult.java index 4f372cc25..1fc4db3cc 100644 --- a/src/main/java/emu/grasscutter/game/combine/CombineResult.java +++ b/src/main/java/emu/grasscutter/game/combine/CombineResult.java @@ -1,11 +1,10 @@ package emu.grasscutter.game.combine; import emu.grasscutter.data.common.ItemParamData; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class CombineResult { @@ -13,5 +12,4 @@ public class CombineResult { private List result; private List extra; private List back; - } diff --git a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java index cf6427752..40d576bf0 100644 --- a/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java +++ b/src/main/java/emu/grasscutter/game/combine/ReliquaryDecomposeEntry.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.combine; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class ReliquaryDecomposeEntry { private int configId; private List items; - } diff --git a/src/main/java/emu/grasscutter/game/drop/DropData.java b/src/main/java/emu/grasscutter/game/drop/DropData.java index 5d2cbbef0..6c8cec4ab 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropData.java +++ b/src/main/java/emu/grasscutter/game/drop/DropData.java @@ -8,13 +8,11 @@ import lombok.Setter; public class DropData { private int minWeight; private int maxWeight; - @Setter - private int itemId; + @Setter private int itemId; private int minCount; private int maxCount; private boolean share = false; - @Setter - private boolean give = false; + @Setter private boolean give = false; public void setIsShare(boolean share) { this.share = share; diff --git a/src/main/java/emu/grasscutter/game/drop/DropInfo.java b/src/main/java/emu/grasscutter/game/drop/DropInfo.java index f46e4986d..afdca351b 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropInfo.java +++ b/src/main/java/emu/grasscutter/game/drop/DropInfo.java @@ -1,13 +1,11 @@ package emu.grasscutter.game.drop; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @SuppressWarnings("deprecation") public class DropInfo { private int monsterId; private List dropDataList; - } diff --git a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java index 2a3bea754..b65708687 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java +++ b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java @@ -11,9 +11,8 @@ import emu.grasscutter.game.world.*; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter @SuppressWarnings("deprecation") diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java index 941b39405..7c9f7c1a2 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDrop.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.dungeons; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class DungeonDrop { private int dungeonId; private List drops; - } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java index a509a1786..60efe56d9 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonDropEntry.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.dungeons; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Setter @Getter public class DungeonDropEntry { @@ -13,5 +12,4 @@ public class DungeonDropEntry { private List probabilities; private List itemProbabilities; private boolean mpDouble; - } diff --git a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java index 8b17ac2b2..8be466286 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java +++ b/src/main/java/emu/grasscutter/game/dungeons/challenge/factory/KillMonsterTimeChallengeFactoryHandler.java @@ -29,7 +29,8 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH Scene scene, SceneGroup group) { val realGroup = scene.getScriptManager().getGroupById(groupId); - val challengeTriggers = new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); + val challengeTriggers = + new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId); val challengeType = challengeData.getChallengeType(); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java index 33bfb7050..0bb4cfb68 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityRegion.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityRegion.java @@ -82,7 +82,7 @@ public class EntityRegion extends GameEntity { @Override public SceneEntityInfoOuterClass.SceneEntityInfo toProto() { - /* The Region Entity would not be sent to client. */ + /* The Region Entity would not be sent to client. */ return null; } diff --git a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java index cbeecaf76..2cecac1f9 100644 --- a/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java +++ b/src/main/java/emu/grasscutter/game/entity/gadget/GadgetGatherObject.java @@ -19,8 +19,7 @@ import emu.grasscutter.utils.Utils; import lombok.Getter; public final class GadgetGatherObject extends GadgetContent { - @Getter - private int itemId; + @Getter private int itemId; private boolean isForbidGuest; public GadgetGatherObject(EntityGadget gadget) { diff --git a/src/main/java/emu/grasscutter/game/friends/Friendship.java b/src/main/java/emu/grasscutter/game/friends/Friendship.java index af17ea1ac..43c924578 100644 --- a/src/main/java/emu/grasscutter/game/friends/Friendship.java +++ b/src/main/java/emu/grasscutter/game/friends/Friendship.java @@ -15,19 +15,12 @@ import org.bson.types.ObjectId; public class Friendship { @Id private ObjectId id; - @Setter - @Getter - @Transient private Player owner; + @Setter @Getter @Transient private Player owner; - @Getter - @Indexed private int ownerId; - @Getter - @Indexed private int friendId; - @Setter - private boolean isFriend; - @Setter - @Getter - private int askerId; + @Getter @Indexed private int ownerId; + @Getter @Indexed private int friendId; + @Setter private boolean isFriend; + @Setter @Getter private int askerId; private PlayerProfile profile; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index 3d0c2db44..3b3d2c6a3 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -96,7 +96,10 @@ public class GachaBanner { private void warnDeprecated(String name, String replacement) { Grasscutter.getLogger() - .error("Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", name, replacement); + .error( + "Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", + name, + replacement); this.deprecated = true; } diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java index d66c12f3d..779a10424 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaRecord.java @@ -2,7 +2,6 @@ package emu.grasscutter.game.gacha; import dev.morphia.annotations.*; import java.util.Date; - import lombok.Getter; import lombok.Setter; import org.bson.types.ObjectId; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java index e119201eb..2657d3c02 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaSystem.java @@ -26,15 +26,13 @@ import it.unimi.dsi.fastutil.ints.*; import java.nio.file.*; import java.util.*; import java.util.concurrent.ThreadLocalRandom; - import lombok.Getter; import org.greenrobot.eventbus.Subscribe; public class GachaSystem extends BaseGameSystem { private static final int starglitterId = 221; private static final int stardustId = 222; - @Getter - private final Int2ObjectMap gachaBanners; + @Getter private final Int2ObjectMap gachaBanners; private WatchService watchService; public GachaSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/game/home/GameHome.java b/src/main/java/emu/grasscutter/game/home/GameHome.java index fd6ce6368..faafe050d 100644 --- a/src/main/java/emu/grasscutter/game/home/GameHome.java +++ b/src/main/java/emu/grasscutter/game/home/GameHome.java @@ -281,10 +281,11 @@ public class GameHome { return this.finishedTalkIdMap.entrySet().stream() .map( - e -> HomeAvatarTalkFinishInfo.newBuilder() - .setAvatarId(e.getKey()) - .addAllFinishTalkIdList(e.getValue()) - .build()) + e -> + HomeAvatarTalkFinishInfo.newBuilder() + .setAvatarId(e.getKey()) + .addAllFinishTalkIdList(e.getValue()) + .build()) .toList(); } @@ -393,9 +394,7 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> e.getDeployNPCList() - .forEach( - id -> invitedAvatars.add(id.getAvatarId()))); + (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId()))); // Check as realm 5 inside is not in defaults and will be null if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { @@ -404,9 +403,7 @@ public class GameHome { .get(player.getCurrentRealmId() + 2000) .getBlockItems() .forEach( - (i, e) -> e.getDeployNPCList() - .forEach( - id -> invitedAvatars.add(id.getAvatarId()))); + (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId()))); } // Add exp to all avatars diff --git a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java index 9297ce1fd..b7ac1d826 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java +++ b/src/main/java/emu/grasscutter/game/home/HomeModuleManager.java @@ -93,24 +93,25 @@ public class HomeModuleManager { .map(HomeBlockItem::getDeployNPCList) .flatMap(Collection::stream) .forEach( - avatar -> suites.forEach( - suite -> { - var data = - SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( - avatar.getAvatarId(), suite.getSuiteId()); - if (data == null || this.home.isRewardEventFinished(data.getId())) { - return; - } + avatar -> + suites.forEach( + suite -> { + var data = + SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( + avatar.getAvatarId(), suite.getSuiteId()); + if (data == null || this.home.isRewardEventFinished(data.getId())) { + return; + } - this.rewardEvents.add( - new HomeAvatarRewardEvent( - homeOwner, - data.getId(), - data.getRewardID(), - data.getAvatarID(), - data.getSuiteId(), - suite.getGuid())); - })); + this.rewardEvents.add( + new HomeAvatarRewardEvent( + homeOwner, + data.getId(), + data.getRewardID(), + data.getAvatarID(), + data.getSuiteId(), + suite.getGuid())); + })); if (this.summonEvents != null) { var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList(); diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index 1b0acee86..2953479f8 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -103,11 +103,12 @@ public class HomeSceneItem { homeAnimalItem -> GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId())) .map( - homeAnimalItem -> new EntityHomeAnimal( - scene, - GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), - homeAnimalItem.getSpawnPos(), - homeAnimalItem.getSpawnRot())) + homeAnimalItem -> + new EntityHomeAnimal( + scene, + GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), + homeAnimalItem.getSpawnPos(), + homeAnimalItem.getSpawnRot())) .toList(); } diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index edea4ad33..558dd6700 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -28,8 +28,7 @@ import org.bson.types.ObjectId; @Entity(value = "items", useDiscriminator = false) public class GameItem { @Id private ObjectId id; - @Getter - @Indexed private int ownerId; + @Getter @Indexed private int ownerId; @Getter @Setter private int itemId; @Getter @Setter private int count; diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 39a8d716c..5da8d49d3 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -21,14 +21,12 @@ import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.longs.*; import java.util.*; import javax.annotation.Nullable; - import lombok.Getter; import lombok.val; public class Inventory extends BasePlayerManager implements Iterable { private final Long2ObjectMap store; - @Getter - private final Int2ObjectMap inventoryTypes; + @Getter private final Int2ObjectMap inventoryTypes; public Inventory(Player player) { super(player); @@ -321,7 +319,9 @@ public class Inventory extends BasePlayerManager implements Iterable { case MATERIAL_COSTUME: case MATERIAL_NAMECARD: Grasscutter.getLogger() - .warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); + .warn( + "Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", + item.getItemData().getMaterialType().name()); return null; default: if (tab == null) { @@ -429,22 +429,24 @@ public class Inventory extends BasePlayerManager implements Iterable { private int getVirtualItemCount(int itemId) { return switch (itemId) { case 201 -> // Primogem - this.player.getPrimogems(); + this.player.getPrimogems(); case 202 -> // Mora - this.player.getMora(); + this.player.getMora(); case 203 -> // Genesis Crystals - this.player.getCrystals(); + this.player.getCrystals(); case 106 -> // Resin - this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); + this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); case 107 -> // Legendary Key - this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); + this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); case 204 -> // Home Coin - this.player.getHomeCoin(); + this.player.getHomeCoin(); default -> { GameItem item = - getInventoryTab(ItemType.ITEM_MATERIAL) - .getItemById( - itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S + getInventoryTab(ItemType.ITEM_MATERIAL) + .getItemById( + itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield + // (item == null) ? 0 : item.getCount(); // What if we ever want to + // operate on weapons/relics/furniture? :S } }; } diff --git a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java index e09d40a97..b0b4987f5 100644 --- a/src/main/java/emu/grasscutter/game/inventory/ItemDef.java +++ b/src/main/java/emu/grasscutter/game/inventory/ItemDef.java @@ -13,5 +13,4 @@ public class ItemDef { this.itemId = itemId; this.count = count; } - } diff --git a/src/main/java/emu/grasscutter/game/mail/Mail.java b/src/main/java/emu/grasscutter/game/mail/Mail.java index 8558e9de2..b1276f1ba 100644 --- a/src/main/java/emu/grasscutter/game/mail/Mail.java +++ b/src/main/java/emu/grasscutter/game/mail/Mail.java @@ -11,18 +11,14 @@ import emu.grasscutter.net.proto.MailCollectStateOuterClass.MailCollectState; import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; import java.time.Instant; import java.util.*; - import lombok.Getter; import lombok.Setter; import org.bson.types.ObjectId; @Entity(value = "mail", useDiscriminator = false) public final class Mail { - @Getter - @Id private ObjectId id; - @Setter - @Getter - @Indexed private int ownerUid; + @Getter @Id private ObjectId id; + @Setter @Getter @Indexed private int ownerUid; public final MailContent mailContent; public final List itemList; public final long sendTime; @@ -36,7 +32,7 @@ public final class Mail { public Mail() { this( new MailContent(), - new ArrayList<>(), + new ArrayList<>(), (int) Instant.now().getEpochSecond() + 604800); // TODO: add expire time to send mail command } diff --git a/src/main/java/emu/grasscutter/game/mail/MailHandler.java b/src/main/java/emu/grasscutter/game/mail/MailHandler.java index a14b0cafb..b6e38fb3a 100644 --- a/src/main/java/emu/grasscutter/game/mail/MailHandler.java +++ b/src/main/java/emu/grasscutter/game/mail/MailHandler.java @@ -5,9 +5,8 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.*; import emu.grasscutter.server.event.player.PlayerReceiveMailEvent; import emu.grasscutter.server.packet.send.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class MailHandler extends BasePlayerManager { @@ -34,7 +33,10 @@ public class MailHandler extends BasePlayerManager { this.mail.add(message); Grasscutter.getLogger() - .debug("Mail sent to user [{}:{}]!", this.getPlayer().getUid(), this.getPlayer().getNickname()); + .debug( + "Mail sent to user [{}:{}]!", + this.getPlayer().getUid(), + this.getPlayer().getNickname()); if (this.getPlayer().isOnline()) { this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message)); @@ -57,7 +59,7 @@ public class MailHandler extends BasePlayerManager { } public void deleteMail(List mailList) { - List sortedMailList = new ArrayList<>(mailList); + List sortedMailList = new ArrayList<>(mailList); sortedMailList.sort(Collections.reverseOrder()); List deleted = new ArrayList<>(); diff --git a/src/main/java/emu/grasscutter/game/managers/SotSManager.java b/src/main/java/emu/grasscutter/game/managers/SotSManager.java index 2864e223e..d3f5d0430 100644 --- a/src/main/java/emu/grasscutter/game/managers/SotSManager.java +++ b/src/main/java/emu/grasscutter/game/managers/SotSManager.java @@ -180,7 +180,10 @@ public class SotSManager extends BasePlayerManager { public void run() { refillSpringVolume(); - logger.trace("isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", getIsAutoRecoveryEnabled(), getAutoRecoveryPercentage()); + logger.trace( + "isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", + getIsAutoRecoveryEnabled(), + getAutoRecoveryPercentage()); if (getIsAutoRecoveryEnabled()) { List activeTeam = player.getTeamManager().getActiveTeam(); diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java index b8237fcea..7ff36ac7a 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomActivity.java @@ -8,17 +8,14 @@ import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.world.*; import emu.grasscutter.scripts.data.*; import emu.grasscutter.utils.Utils; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public final class BlossomActivity { private final SceneGroup tempSceneGroup; - @Getter - private final WorldChallenge challenge; - @Getter - private final EntityGadget gadget; + @Getter private final WorldChallenge challenge; + @Getter private final EntityGadget gadget; private EntityGadget chest; private int step; private final int goal; diff --git a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java index d1f59bf99..9644553cd 100644 --- a/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java +++ b/src/main/java/emu/grasscutter/game/managers/blossom/BlossomManager.java @@ -203,7 +203,7 @@ public class BlossomManager { RewardPreviewData blossomRewards = getRewardList(type, worldLevel); if (blossomRewards == null) { Grasscutter.getLogger() - .error("Blossom could not support world level : {}", worldLevel); + .error("Blossom could not support world level : {}", worldLevel); return null; } var rewards = blossomRewards.getPreviewItems(); diff --git a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java index 793bfdcab..b24eadbfc 100644 --- a/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java +++ b/src/main/java/emu/grasscutter/game/managers/cooking/CookingCompoundManager.java @@ -18,7 +18,6 @@ import emu.grasscutter.server.packet.send.PacketCompoundDataNotify; import emu.grasscutter.server.packet.send.PacketGetCompoundDataRsp; import emu.grasscutter.server.packet.send.PacketPlayerCompoundMaterialRsp; import emu.grasscutter.utils.Utils; - import java.util.*; public class CookingCompoundManager extends BasePlayerManager { @@ -34,24 +33,33 @@ public class CookingCompoundManager extends BasePlayerManager { public static void initialize() { defaultUnlockedCompounds = new HashSet<>(); compoundGroups = new HashMap<>(); - GameData.getCompoundDataMap().forEach((id, compound) -> { - if (compound.isDefaultUnlocked()) { - defaultUnlockedCompounds.add(id); - } - compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); - }); + GameData.getCompoundDataMap() + .forEach( + (id, compound) -> { + if (compound.isDefaultUnlocked()) { + defaultUnlockedCompounds.add(id); + } + compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); + }); // TODO:Because we haven't implemented fishing feature,unlock all compounds related to // fish.Besides,it should be bound to player rather than manager. unlocked = new HashSet<>(defaultUnlockedCompounds); if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error - unlocked.addAll(compoundGroups.get(3)); + unlocked.addAll(compoundGroups.get(3)); } private synchronized List getCompoundQueueData() { - List compoundQueueData = new ArrayList<>(player.getActiveCookCompounds().size()); + List compoundQueueData = + new ArrayList<>(player.getActiveCookCompounds().size()); int currentTime = Utils.getCurrentSeconds(); for (var item : player.getActiveCookCompounds().values()) { - var data = CompoundQueueData.newBuilder().setCompoundId(item.getCompoundId()).setOutputCount(item.getOutputCount(currentTime)).setOutputTime(item.getOutputTime(currentTime)).setWaitCount(item.getWaitCount(currentTime)).build(); + var data = + CompoundQueueData.newBuilder() + .setCompoundId(item.getCompoundId()) + .setOutputCount(item.getOutputCount(currentTime)) + .setOutputTime(item.getOutputTime(currentTime)) + .setWaitCount(item.getWaitCount(currentTime)) + .build(); compoundQueueData.add(data); } return compoundQueueData; @@ -73,14 +81,16 @@ public class CookingCompoundManager extends BasePlayerManager { return; } // check whether the queue is full - if (activeCompounds.containsKey(id) && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { + if (activeCompounds.containsKey(id) + && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_COMPOUND_QUEUE_FULL_VALUE)); return; } // try to consume raw materials if (!player.getInventory().payItems(compound.getInputVec(), count)) { // TODO:I'm not sure whether retcode is correct. - player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); + player.sendPacket( + new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); return; } ActiveCookCompoundData c; @@ -92,7 +102,13 @@ public class CookingCompoundManager extends BasePlayerManager { c = new ActiveCookCompoundData(id, compound.getCostTime(), count, currentTime); activeCompounds.put(id, c); } - var data = CompoundQueueData.newBuilder().setCompoundId(id).setOutputCount(c.getOutputCount(currentTime)).setOutputTime(c.getOutputTime(currentTime)).setWaitCount(c.getWaitCount(currentTime)).build(); + var data = + CompoundQueueData.newBuilder() + .setCompoundId(id) + .setOutputCount(c.getOutputCount(currentTime)) + .setOutputTime(c.getOutputTime(currentTime)) + .setWaitCount(c.getWaitCount(currentTime)) + .build(); player.sendPacket(new PacketPlayerCompoundMaterialRsp(data)); } @@ -124,9 +140,20 @@ public class CookingCompoundManager extends BasePlayerManager { // give player the rewards if (success) { player.getInventory().addItems(allRewards.values(), ActionReason.Compound); - player.sendPacket(new PackageTakeCompoundOutputRsp(allRewards.values().stream().map(i -> ItemParam.newBuilder().setItemId(i.getItemId()).setCount(i.getCount()).build()).toList(), Retcode.RET_SUCC_VALUE)); + player.sendPacket( + new PackageTakeCompoundOutputRsp( + allRewards.values().stream() + .map( + i -> + ItemParam.newBuilder() + .setItemId(i.getItemId()) + .setCount(i.getCount()) + .build()) + .toList(), + Retcode.RET_SUCC_VALUE)); } else { - player.sendPacket(new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); + player.sendPacket( + new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); } } diff --git a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java index 45fb27507..ebda78540 100644 --- a/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java +++ b/src/main/java/emu/grasscutter/game/managers/deforestation/HitTreeRecord.java @@ -3,12 +3,9 @@ package emu.grasscutter.game.managers.deforestation; import lombok.Getter; public class HitTreeRecord { - /** - * -- GETTER -- - * get unique id - */ - @Getter - private final int unique; + /** -- GETTER -- get unique id */ + @Getter private final int unique; + private short count; // hit this tree times private long time; // last available hitting time diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java index b42c2e6ef..451b2d8ce 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropEntry.java @@ -1,12 +1,10 @@ package emu.grasscutter.game.managers.energy; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class EnergyDropEntry { private int dropId; private List dropList; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java index 72d3763b3..420400b43 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyDropInfo.java @@ -6,5 +6,4 @@ import lombok.Getter; public class EnergyDropInfo { private int ballId; private int count; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java index 981f87881..dd177d6db 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/EnergyManager.java @@ -45,8 +45,7 @@ public class EnergyManager extends BasePlayerManager { // Read the data we need for monster energy drops. try { DataLoader.loadList("EnergyDrop.json", EnergyDropEntry.class) - .forEach( - entry -> energyDropData.put(entry.getDropId(), entry.getDropList())); + .forEach(entry -> energyDropData.put(entry.getDropId(), entry.getDropList())); Grasscutter.getLogger().debug("Energy drop data successfully loaded."); } catch (Exception ex) { diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java index 80fbcc686..2642fd665 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationEntry.java @@ -1,12 +1,10 @@ package emu.grasscutter.game.managers.energy; -import lombok.Getter; - import java.util.List; +import lombok.Getter; @Getter public class SkillParticleGenerationEntry { private int avatarId; private List amountList; - } diff --git a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java index d46ee16ef..115e5d018 100644 --- a/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java +++ b/src/main/java/emu/grasscutter/game/managers/energy/SkillParticleGenerationInfo.java @@ -6,5 +6,4 @@ import lombok.Getter; public class SkillParticleGenerationInfo { private int value; private int chance; - } diff --git a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java index dedb26ac8..f6854a2b9 100644 --- a/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java +++ b/src/main/java/emu/grasscutter/game/managers/forging/ActiveForgeData.java @@ -6,27 +6,15 @@ import lombok.Setter; @Entity public class ActiveForgeData { - @Setter - @Getter - private int forgeId; - @Setter - @Getter - private int avatarId; - @Setter - @Getter - private int count; + @Setter @Getter private int forgeId; + @Setter @Getter private int avatarId; + @Setter @Getter private int count; - @Setter - @Getter - private int startTime; - @Setter - @Getter - private int forgeTime; + @Setter @Getter private int startTime; + @Setter @Getter private int forgeTime; private int lastUnfinishedCount; - @Setter - @Getter - private boolean changed; + @Setter @Getter private boolean changed; public int getFinishedCount(int currentTime) { int timeDelta = currentTime - this.startTime; diff --git a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java index a8f05337c..9253a6cda 100644 --- a/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java +++ b/src/main/java/emu/grasscutter/game/managers/mapmark/MapMark.java @@ -33,5 +33,4 @@ public class MapMark { this.mapMarkFromType = mapMarkPoint.getFromType(); this.questId = mapMarkPoint.getQuestId(); } - } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java index f724d5d5e..fa8d42c0f 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCodex.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCodex.java @@ -63,15 +63,15 @@ public class PlayerCodex { MATERIAL_WIDGET, MATERIAL_EXCHANGE, MATERIAL_AVATAR_MATERIAL, - MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId)) - .ifPresent( - codexData -> { - if (this.getUnlockedMaterial().add(itemId)) { - this.player.save(); - this.player.sendPacket( - new PacketCodexDataUpdateNotify(4, codexData.getId())); - } - }); + MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable( + GameData.getCodexMaterialDataIdMap().get(itemId)) + .ifPresent( + codexData -> { + if (this.getUnlockedMaterial().add(itemId)) { + this.player.save(); + this.player.sendPacket(new PacketCodexDataUpdateNotify(4, codexData.getId())); + } + }); default -> {} } } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java index 1f3f1e1c8..35eab5b85 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerCollectionRecords.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.player; import dev.morphia.annotations.Entity; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Entity(useDiscriminator = false) public class PlayerCollectionRecords { @@ -58,6 +57,5 @@ public class PlayerCollectionRecords { this.configId = configId; this.expiredTime = expiredTime; } - } } diff --git a/src/main/java/emu/grasscutter/game/player/TeamInfo.java b/src/main/java/emu/grasscutter/game/player/TeamInfo.java index 4fffba9a4..835e82d06 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamInfo.java +++ b/src/main/java/emu/grasscutter/game/player/TeamInfo.java @@ -5,16 +5,14 @@ import static emu.grasscutter.config.Configuration.GAME_OPTIONS; import dev.morphia.annotations.Entity; import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; +import java.util.*; import lombok.Getter; import lombok.Setter; -import java.util.*; - @Getter @Entity public final class TeamInfo { - @Setter - private String name; + @Setter private String name; private final List avatars; public TeamInfo() { diff --git a/src/main/java/emu/grasscutter/game/props/ActionReason.java b/src/main/java/emu/grasscutter/game/props/ActionReason.java index 251aa6fbc..8e8a598f2 100644 --- a/src/main/java/emu/grasscutter/game/props/ActionReason.java +++ b/src/main/java/emu/grasscutter/game/props/ActionReason.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ActionReason { @@ -208,5 +207,4 @@ public enum ActionReason { public static ActionReason getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java index d5273f4e9..8f9141143 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionRefreshType.java @@ -14,5 +14,4 @@ public enum BattlePassMissionRefreshType { BattlePassMissionRefreshType(int value) { this.value = value; } - } diff --git a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java index 1abc80f1d..5cc877515 100644 --- a/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java +++ b/src/main/java/emu/grasscutter/game/props/BattlePassMissionStatus.java @@ -17,5 +17,4 @@ public enum BattlePassMissionStatus { this.value = value; this.missionStatus = missionStatus; // In case proto enum values change later } - } diff --git a/src/main/java/emu/grasscutter/game/props/CampTargetType.java b/src/main/java/emu/grasscutter/game/props/CampTargetType.java index 955b642cc..2b9eca324 100644 --- a/src/main/java/emu/grasscutter/game/props/CampTargetType.java +++ b/src/main/java/emu/grasscutter/game/props/CampTargetType.java @@ -2,10 +2,9 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum CampTargetType implements IntValueEnum { diff --git a/src/main/java/emu/grasscutter/game/props/ClimateType.java b/src/main/java/emu/grasscutter/game/props/ClimateType.java index 39ed137b0..582d13378 100644 --- a/src/main/java/emu/grasscutter/game/props/ClimateType.java +++ b/src/main/java/emu/grasscutter/game/props/ClimateType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ClimateType { diff --git a/src/main/java/emu/grasscutter/game/props/EnterReason.java b/src/main/java/emu/grasscutter/game/props/EnterReason.java index 683c486db..07d8ddf4c 100644 --- a/src/main/java/emu/grasscutter/game/props/EnterReason.java +++ b/src/main/java/emu/grasscutter/game/props/EnterReason.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum EnterReason { @@ -66,5 +65,4 @@ public enum EnterReason { public static EnterReason getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/EntityIdType.java b/src/main/java/emu/grasscutter/game/props/EntityIdType.java index 622069146..e6e672a28 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityIdType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityIdType.java @@ -1,8 +1,7 @@ package emu.grasscutter.game.props; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public enum EntityIdType { @@ -37,5 +36,4 @@ public enum EntityIdType { public static EntityType toEntityType(int entityId) { return map.getOrDefault(entityId, EntityType.None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/EntityType.java b/src/main/java/emu/grasscutter/game/props/EntityType.java index 883258582..42eae8ed3 100644 --- a/src/main/java/emu/grasscutter/game/props/EntityType.java +++ b/src/main/java/emu/grasscutter/game/props/EntityType.java @@ -2,10 +2,9 @@ package emu.grasscutter.game.props; import emu.grasscutter.scripts.constants.IntValueEnum; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum EntityType implements IntValueEnum { @@ -104,5 +103,4 @@ public enum EntityType implements IntValueEnum { public static EntityType getTypeByName(String name) { return stringMap.getOrDefault(name, None); } - } diff --git a/src/main/java/emu/grasscutter/game/props/FetterState.java b/src/main/java/emu/grasscutter/game/props/FetterState.java index 8ee65407d..1498a60be 100644 --- a/src/main/java/emu/grasscutter/game/props/FetterState.java +++ b/src/main/java/emu/grasscutter/game/props/FetterState.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum FetterState { @@ -38,5 +37,4 @@ public enum FetterState { public static FetterState getTypeByName(String name) { return stringMap.getOrDefault(name, NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/GrowCurve.java b/src/main/java/emu/grasscutter/game/props/GrowCurve.java index 4734350f7..a04c42205 100644 --- a/src/main/java/emu/grasscutter/game/props/GrowCurve.java +++ b/src/main/java/emu/grasscutter/game/props/GrowCurve.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum GrowCurve { @@ -99,5 +98,4 @@ public enum GrowCurve { public static GrowCurve getPropByName(String name) { return stringMap.getOrDefault(name, GROW_CURVE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java index 66eff8ed6..54cc2a6d1 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseOp.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseOp.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ItemUseOp { @@ -53,9 +52,7 @@ public enum ItemUseOp { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -67,5 +64,4 @@ public enum ItemUseOp { public static ItemUseOp getTypeByValue(int value) { return map.getOrDefault(value, ITEM_USE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java index 5ad8671c2..07701f36a 100644 --- a/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java +++ b/src/main/java/emu/grasscutter/game/props/ItemUseTarget.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ItemUseTarget { @@ -17,9 +16,7 @@ public enum ItemUseTarget { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -31,5 +28,4 @@ public enum ItemUseTarget { public static ItemUseTarget getTypeByValue(int value) { return map.getOrDefault(value, ITEM_USE_TARGET_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/LifeState.java b/src/main/java/emu/grasscutter/game/props/LifeState.java index 52a0622e0..e708d534a 100644 --- a/src/main/java/emu/grasscutter/game/props/LifeState.java +++ b/src/main/java/emu/grasscutter/game/props/LifeState.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum LifeState { @@ -38,5 +37,4 @@ public enum LifeState { public static LifeState getTypeByName(String name) { return stringMap.getOrDefault(name, LIFE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/MonsterType.java b/src/main/java/emu/grasscutter/game/props/MonsterType.java index adc080d4b..f2b370377 100644 --- a/src/main/java/emu/grasscutter/game/props/MonsterType.java +++ b/src/main/java/emu/grasscutter/game/props/MonsterType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum MonsterType { @@ -40,5 +39,4 @@ public enum MonsterType { public static MonsterType getTypeByName(String name) { return stringMap.getOrDefault(name, MONSTER_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/RefreshType.java b/src/main/java/emu/grasscutter/game/props/RefreshType.java index 5df028a79..bf362f2b1 100644 --- a/src/main/java/emu/grasscutter/game/props/RefreshType.java +++ b/src/main/java/emu/grasscutter/game/props/RefreshType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum RefreshType { diff --git a/src/main/java/emu/grasscutter/game/props/SceneType.java b/src/main/java/emu/grasscutter/game/props/SceneType.java index 48015a7e8..bf66d3277 100644 --- a/src/main/java/emu/grasscutter/game/props/SceneType.java +++ b/src/main/java/emu/grasscutter/game/props/SceneType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum SceneType { @@ -41,5 +40,4 @@ public enum SceneType { public static SceneType getTypeByName(String name) { return stringMap.getOrDefault(name, SCENE_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java index a55e13f3b..00ebb0e34 100644 --- a/src/main/java/emu/grasscutter/game/props/ServerBuffType.java +++ b/src/main/java/emu/grasscutter/game/props/ServerBuffType.java @@ -1,9 +1,8 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.stream.Stream; +import lombok.Getter; @Getter public enum ServerBuffType { @@ -15,9 +14,7 @@ public enum ServerBuffType { private static final Int2ObjectMap map = new Int2ObjectOpenHashMap<>(); static { - Stream.of(values()) - .forEach( - e -> map.put(e.getValue(), e)); + Stream.of(values()).forEach(e -> map.put(e.getValue(), e)); } private final int value; @@ -29,5 +26,4 @@ public enum ServerBuffType { public static ServerBuffType getTypeByValue(int value) { return map.getOrDefault(value, SERVER_BUFF_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java index 36c855635..432f0b61b 100644 --- a/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java +++ b/src/main/java/emu/grasscutter/game/props/WatcherTriggerType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum WatcherTriggerType { @@ -333,5 +332,4 @@ public enum WatcherTriggerType { public static WatcherTriggerType getTypeByName(String name) { return stringMap.getOrDefault(name, TRIGGER_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/props/WeaponType.java b/src/main/java/emu/grasscutter/game/props/WeaponType.java index d70af53be..b43d1c7a4 100644 --- a/src/main/java/emu/grasscutter/game/props/WeaponType.java +++ b/src/main/java/emu/grasscutter/game/props/WeaponType.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.props; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum WeaponType { @@ -56,5 +55,4 @@ public enum WeaponType { public static WeaponType getTypeByName(String name) { return stringMap.getOrDefault(name, WEAPON_NONE); } - } diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index d4b9e4839..b2e0b974a 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -294,8 +294,7 @@ public class GameQuest { public boolean rewind(boolean notifyDelete) { getMainQuest().getChildQuests().values().stream() .filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()) - .forEach( - q -> q.clearProgress(notifyDelete)); + .forEach(q -> q.clearProgress(notifyDelete)); clearProgress(notifyDelete); this.start(); return true; diff --git a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java index dd2e5cd91..ebb3bb903 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/LogicType.java @@ -3,7 +3,6 @@ package emu.grasscutter.game.quest.enums; import emu.grasscutter.Grasscutter; import java.util.*; import java.util.function.BooleanSupplier; - import lombok.Getter; import org.jetbrains.annotations.NotNull; @@ -91,5 +90,4 @@ public enum LogicType { } } } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java index 02019c360..39ffb7638 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ParentQuestState.java @@ -14,5 +14,4 @@ public enum ParentQuestState { ParentQuestState(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java index 9cb1faa83..c5d8bcb8d 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestCond.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestCond implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java index 053b559e5..2851265bf 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestContent.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestContent implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java index 2b14a98b2..6a339c084 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestExec.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.quest.enums; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; @Getter public enum QuestExec implements QuestTrigger { diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java index d9bbac8d4..3c872a621 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestGuideType.java @@ -13,5 +13,4 @@ public enum QuestGuideType { QuestGuideType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java index db76cdf7d..ef59d1a10 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestShowType.java @@ -12,5 +12,4 @@ public enum QuestShowType { QuestShowType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java index 692343835..04bf4dad2 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestState.java @@ -23,5 +23,4 @@ public enum QuestState implements IntValueEnum { QuestState(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java index 8fa4d6e75..f0fda0812 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/QuestType.java @@ -18,5 +18,4 @@ public enum QuestType { QuestType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java index f5c7d14d1..6ae10e778 100644 --- a/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java +++ b/src/main/java/emu/grasscutter/game/quest/enums/ShowQuestGuideType.java @@ -13,5 +13,4 @@ public enum ShowQuestGuideType { ShowQuestGuideType(int id) { this.value = id; } - } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java index 376d46326..ae9a2d348 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopLimit.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopLimit.java @@ -12,5 +12,4 @@ public class ShopLimit { private int hasBought; private int hasBoughtInPeriod = 0; private int nextRefreshTime = 0; - } diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index 71c6122ab..6f0edc176 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -9,15 +9,13 @@ import emu.grasscutter.data.excels.ShopGoodsData; import emu.grasscutter.server.game.*; import emu.grasscutter.utils.Utils; import it.unimi.dsi.fastutil.ints.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; public class ShopSystem extends BaseGameSystem { private static final int REFRESH_HOUR = 4; // In GMT+8 server private static final String TIME_ZONE = "Asia/Shanghai"; // GMT+8 Timezone - @Getter - private final Int2ObjectMap> shopData; + @Getter private final Int2ObjectMap> shopData; private final Int2ObjectMap> shopChestData; public ShopSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/game/shop/ShopTable.java b/src/main/java/emu/grasscutter/game/shop/ShopTable.java index 1cd9831a2..459f843b7 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopTable.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopTable.java @@ -1,14 +1,12 @@ package emu.grasscutter.game.shop; +import java.util.*; import lombok.Getter; import lombok.Setter; -import java.util.*; - @Setter @Getter public class ShopTable { private int shopId; private List items = new ArrayList<>(); - } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index cdbfc22cd..47c9affc0 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -82,7 +82,10 @@ public class InventorySystem extends BaseGameSystem { val avatarData = avatar.getSkillDepot(); if (avatarData == null) { Grasscutter.getLogger() - .error("Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", player.getUid(), avatarId); + .error( + "Attempted to check constellation level for UID{}'s avatar {} but avatar has no skillDepot!", + player.getUid(), + avatarId); return 0; } int constItemId = avatarData.getTalentCostItemId(); diff --git a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java index a63cbf0f4..997c40ded 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerLevelRecord.java @@ -1,11 +1,10 @@ package emu.grasscutter.game.tower; import dev.morphia.annotations.Entity; +import java.util.*; import lombok.Getter; import lombok.Setter; -import java.util.*; - @Setter @Getter @Entity @@ -37,5 +36,4 @@ public class TowerLevelRecord { public int getStarCount() { return passedLevelMap.values().stream().mapToInt(Integer::intValue).sum(); } - } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java index fa4e653c0..a3f539b13 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerScheduleConfig.java @@ -1,10 +1,9 @@ package emu.grasscutter.game.tower; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Setter @Getter public class TowerScheduleConfig { @@ -12,5 +11,4 @@ public class TowerScheduleConfig { private Date scheduleStartTime; private Date nextScheduleChangeTime; - } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java index 5369ecb40..0d28d1a70 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerSystem.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerSystem.java @@ -4,9 +4,8 @@ import emu.grasscutter.Grasscutter; import emu.grasscutter.data.*; import emu.grasscutter.data.excels.tower.TowerScheduleData; import emu.grasscutter.server.game.*; -import lombok.Getter; - import java.util.*; +import lombok.Getter; @Getter public class TowerSystem extends BaseGameSystem { diff --git a/src/main/java/emu/grasscutter/game/world/GridPosition.java b/src/main/java/emu/grasscutter/game/world/GridPosition.java index 13caa8eaa..a90cc3159 100644 --- a/src/main/java/emu/grasscutter/game/world/GridPosition.java +++ b/src/main/java/emu/grasscutter/game/world/GridPosition.java @@ -10,8 +10,7 @@ import lombok.*; @Getter @Entity public final class GridPosition implements Serializable { - @Serial - private static final long serialVersionUID = -2001232300615923575L; + @Serial private static final long serialVersionUID = -2001232300615923575L; private int x; diff --git a/src/main/java/emu/grasscutter/game/world/Location.java b/src/main/java/emu/grasscutter/game/world/Location.java index 16ed72ae4..e25fa3b10 100644 --- a/src/main/java/emu/grasscutter/game/world/Location.java +++ b/src/main/java/emu/grasscutter/game/world/Location.java @@ -7,8 +7,7 @@ import lombok.*; @Getter @Entity public class Location extends Position { - @Transient - private Scene scene; + @Transient private Scene scene; public Location(Scene scene, Position position) { this.set(position); diff --git a/src/main/java/emu/grasscutter/game/world/Position.java b/src/main/java/emu/grasscutter/game/world/Position.java index 6e3348e02..b885ec4c8 100644 --- a/src/main/java/emu/grasscutter/game/world/Position.java +++ b/src/main/java/emu/grasscutter/game/world/Position.java @@ -5,7 +5,6 @@ import com.google.gson.annotations.SerializedName; import dev.morphia.annotations.Entity; import emu.grasscutter.net.proto.VectorOuterClass.Vector; import emu.grasscutter.utils.Utils; - import java.io.Serial; import java.io.Serializable; import java.util.List; @@ -17,8 +16,7 @@ import lombok.experimental.Accessors; @Entity @Accessors(chain = true) public class Position implements Serializable { - @Serial - private static final long serialVersionUID = -2001232313615923575L; + @Serial private static final long serialVersionUID = -2001232313615923575L; public static final Position ZERO = new Position(0, 0, 0); public static final Position IDENTITY = new Position(0, 0); diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 53f028746..dca0f35d0 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -392,7 +392,8 @@ public class Scene { } public void updateEntity(GameEntity entity, VisionType type) { - this.broadcastPacket(new PacketSceneEntityUpdateNotify(Collections.singletonList(entity), type)); + this.broadcastPacket( + new PacketSceneEntityUpdateNotify(Collections.singletonList(entity), type)); } private static List> chopped(List list, final int L) { diff --git a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java index 949747717..91d4b4d71 100644 --- a/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java +++ b/src/main/java/emu/grasscutter/game/world/SceneGroupInstance.java @@ -7,45 +7,31 @@ import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.player.Player; import emu.grasscutter.scripts.data.SceneGadget; import emu.grasscutter.scripts.data.SceneGroup; -import lombok.Getter; -import lombok.Setter; -import org.bson.types.ObjectId; - import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import lombok.Getter; +import lombok.Setter; +import org.bson.types.ObjectId; @Entity(value = "group_instances", useDiscriminator = false) public final class SceneGroupInstance { - @Id - private ObjectId id; + @Id private ObjectId id; - @Indexed - private int ownerUid; // This group is owned by the host player - @Getter - private int groupId; + @Indexed private int ownerUid; // This group is owned by the host player + @Getter private int groupId; - @Getter - private transient SceneGroup luaGroup; - @Getter - @Setter - private int targetSuiteId; - @Getter - @Setter - private int activeSuiteId; - @Getter - private final Set deadEntities; // Config_ids + @Getter private transient SceneGroup luaGroup; + @Getter @Setter private int targetSuiteId; + @Getter @Setter private int activeSuiteId; + @Getter private final Set deadEntities; // Config_ids private boolean isCached; - @Getter - private final Map cachedGadgetStates; - @Getter - private final Map cachedVariables; + @Getter private final Map cachedGadgetStates; + @Getter private final Map cachedVariables; - @Getter - @Setter - private int lastTimeRefreshed; + @Getter @Setter private int lastTimeRefreshed; public SceneGroupInstance(SceneGroup group, Player owner) { this.luaGroup = group; @@ -59,11 +45,11 @@ public final class SceneGroupInstance { this.cachedVariables = new ConcurrentHashMap<>(); this.isCached = - false; // This is true when the group is not loaded on scene but caches suite data + false; // This is true when the group is not loaded on scene but caches suite data } @Deprecated - // Morphia only! + // Morphia only! SceneGroupInstance() { this.cachedVariables = new ConcurrentHashMap<>(); this.deadEntities = new HashSet<>(); @@ -86,7 +72,7 @@ public final class SceneGroupInstance { public void cacheGadgetState(SceneGadget g, int state) { if (g.persistent) // Only cache when is persistent - cachedGadgetStates.put(g.config_id, state); + cachedGadgetStates.put(g.config_id, state); } public int getCachedGadgetState(SceneGadget g) { diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index ed32b1e1a..5e5a250b2 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -52,9 +52,7 @@ public class World implements Iterable { @Getter private final EntityWorld entity; private int nextEntityId = 0; private int nextPeerId = 0; - @Setter - @Getter - private int worldLevel; + @Setter @Getter private int worldLevel; @Getter private boolean isMultiplayer = false; @Getter private boolean timeLocked; diff --git a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java index 5dd2d10bf..b9c4e0dad 100644 --- a/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java +++ b/src/main/java/emu/grasscutter/game/world/WorldDataSystem.java @@ -11,13 +11,13 @@ import emu.grasscutter.scripts.data.*; import emu.grasscutter.server.game.*; import java.util.*; import java.util.concurrent.ConcurrentHashMap; - import lombok.Getter; import org.luaj.vm2.LuaError; public class WorldDataSystem extends BaseGameSystem { @Getter private final Map chestInteractHandlerMap; // chestType-Handler + private final Map sceneInvestigationGroupMap; // public WorldDataSystem(GameServer server) { diff --git a/src/main/java/emu/grasscutter/net/packet/BasePacket.java b/src/main/java/emu/grasscutter/net/packet/BasePacket.java index 438b98f89..5620a08c7 100644 --- a/src/main/java/emu/grasscutter/net/packet/BasePacket.java +++ b/src/main/java/emu/grasscutter/net/packet/BasePacket.java @@ -2,28 +2,20 @@ package emu.grasscutter.net.packet; import com.google.protobuf.GeneratedMessageV3; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; +import java.io.*; import lombok.Getter; import lombok.Setter; -import java.io.*; - public class BasePacket { private static final int const1 = 17767; // 0x4567 private static final int const2 = -30293; // 0x89ab public final boolean shouldEncrypt = true; - @Setter - @Getter - private int opcode; + @Setter @Getter private int opcode; private boolean shouldBuildHeader = false; - @Setter - @Getter - private byte[] header; - @Setter - @Getter - private byte[] data; + @Setter @Getter private byte[] header; + @Setter @Getter private byte[] data; // Encryption - @Setter - private boolean useDispatchKey; + @Setter private boolean useDispatchKey; public BasePacket(int opcode) { this.opcode = opcode; diff --git a/src/main/java/emu/grasscutter/plugin/Plugin.java b/src/main/java/emu/grasscutter/plugin/Plugin.java index 1c6cbdc5b..b98b2cc52 100644 --- a/src/main/java/emu/grasscutter/plugin/Plugin.java +++ b/src/main/java/emu/grasscutter/plugin/Plugin.java @@ -45,7 +45,7 @@ public abstract class Plugin { if (!this.dataFolder.exists() && !this.dataFolder.mkdirs()) { Grasscutter.getLogger() - .warn("Failed to create plugin data folder for {}", this.identifier.name); + .warn("Failed to create plugin data folder for {}", this.identifier.name); } } diff --git a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java index 852a28246..af2a99901 100644 --- a/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java +++ b/src/main/java/emu/grasscutter/plugin/api/ServerHelper.java @@ -7,21 +7,19 @@ import emu.grasscutter.game.player.Player; import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.http.*; import emu.grasscutter.server.scheduler.ServerTaskScheduler; -import lombok.Getter; - import java.util.*; import java.util.stream.Stream; +import lombok.Getter; /** Hooks into the {@link GameServer} class, adding convenient ways to do certain things. */ public final class ServerHelper { /** - * -- GETTER -- - * Gets the server hook instance. + * -- GETTER -- Gets the server hook instance. * * @return A {@link ServerHelper} singleton. */ - @Getter - private static ServerHelper instance; + @Getter private static ServerHelper instance; + private final GameServer gameServer; private final HttpServer httpServer; diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 30bb4fe3e..82317bb3d 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -36,8 +36,7 @@ import org.luaj.vm2.*; import org.luaj.vm2.lib.jse.CoerceJavaToLua; public class SceneScriptManager { - @Getter - private final Scene scene; + @Getter private final Scene scene; private final Map variables; private SceneMeta meta; private boolean isInit; @@ -56,13 +55,10 @@ public class SceneScriptManager { private final Map sceneGroups; private final Map sceneGroupsInstances; private final Map cachedSceneGroupsInstances; - @Getter - private ScriptMonsterTideService scriptMonsterTideService; - @Getter - private final ScriptMonsterSpawnService scriptMonsterSpawnService; + @Getter private ScriptMonsterTideService scriptMonsterTideService; + @Getter private final ScriptMonsterSpawnService scriptMonsterSpawnService; /** blockid - loaded groupSet */ - @Getter - private final Map> loadedGroupSetPerBlock; + @Getter private final Map> loadedGroupSetPerBlock; private static final Int2ObjectMap> groupGridsCache = new Int2ObjectOpenHashMap<>(); public static final ExecutorService eventExecutor; @@ -845,12 +841,12 @@ public class SceneScriptManager { public Future callEvent(@Nonnull ScriptArgs params) { /* - We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for - every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib - func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could - not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> - (remove) So we use thread pool to clean the stack to avoid this new issue. - */ + We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for + every groups' trigger in every scene instances. But when callEvent is called in a ScriptLib + func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could + not get it. e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> + (remove) So we use thread pool to clean the stack to avoid this new issue. + */ return eventExecutor.submit(() -> this.realCallEvent(params)); } @@ -884,7 +880,7 @@ public class SceneScriptManager { } } catch (Throwable throwable) { Grasscutter.getLogger() - .error("Condition Trigger {} triggered exception", params.type, throwable); + .error("Condition Trigger {} triggered exception", params.type, throwable); } finally { // make sure it is removed ScriptLoader.getScriptLib().removeSceneScriptManager(); @@ -910,7 +906,7 @@ public class SceneScriptManager { return false; } catch (Throwable ex) { Grasscutter.getLogger() - .error("Condition Trigger {} triggered exception", trigger.getName(), ex); + .error("Condition Trigger {} triggered exception", trigger.getName(), ex); return false; } finally { ScriptLoader.getScriptLib().removeCurrentGroup(); diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java index eaea56215..530c38542 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLoader.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLoader.java @@ -34,7 +34,8 @@ public class ScriptLoader { private static final Map> scriptsCache = new ConcurrentHashMap<>(); /** sceneId - SceneMeta */ - private static final Map> sceneMetaCache = new ConcurrentHashMap<>(); + private static final Map> sceneMetaCache = + new ConcurrentHashMap<>(); private static final AtomicReference currentBindings = new AtomicReference<>(null); private static final AtomicReference currentContext = new AtomicReference<>(null); diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java index 782ef2a8c..c7fce1d9e 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneBlock.java @@ -22,9 +22,7 @@ public class SceneBlock { public Map groups; public RTree sceneGroupIndex; - @Setter - @Getter - private transient boolean loaded; // Not an actual variable in the scripts either + @Setter @Getter private transient boolean loaded; // Not an actual variable in the scripts either public boolean contains(Position pos) { int range = Grasscutter.getConfig().server.game.loadEntitiesForPlayerRange; @@ -67,7 +65,8 @@ public class SceneBlock { SceneIndexManager.buildIndex(3, this.groups.values(), g -> g.pos.toPoint()); } catch (ScriptException exception) { Grasscutter.getLogger() - .error("An error occurred while loading block {} in scene {}", this.id, sceneId, exception); + .error( + "An error occurred while loading block {} in scene {}", this.id, sceneId, exception); } Grasscutter.getLogger().trace("Successfully loaded block {} in scene {}.", this.id, sceneId); return this; diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java index 8cd7d6d9c..1681cd919 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGadget.java @@ -24,8 +24,7 @@ public class SceneGadget extends SceneObject { * isOneOff=false, like investigation points, it will disappear temporarily, and appear again in * next big world resource refresh routine. */ - @Setter - public boolean isOneoff; + @Setter public boolean isOneoff; public int draft_id; public int route_id; @@ -35,5 +34,4 @@ public class SceneGadget extends SceneObject { public int mark_flag; public Explore explore; public int trigger_count; - } diff --git a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java index ccfe70b82..a32318f81 100644 --- a/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java +++ b/src/main/java/emu/grasscutter/scripts/data/SceneGroup.java @@ -3,7 +3,6 @@ package emu.grasscutter.scripts.data; import emu.grasscutter.Grasscutter; import emu.grasscutter.game.world.Position; import emu.grasscutter.scripts.ScriptLoader; - import java.util.*; import java.util.stream.Collectors; import javax.script.*; @@ -37,13 +36,9 @@ public final class SceneGroup { public SceneReplaceable is_replaceable; /* These are not script variables. */ - @Setter - @Getter - private transient boolean loaded; - @Getter - private transient CompiledScript script; - @Getter - private transient Bindings bindings; + @Setter @Getter private transient boolean loaded; + @Getter private transient CompiledScript script; + @Getter private transient Bindings bindings; public String overrideScriptPath; public static SceneGroup of(int groupId) { @@ -156,7 +151,7 @@ public final class SceneGroup { this.suites.forEach(i -> i.init(this)); } catch (ScriptException e) { Grasscutter.getLogger() - .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e); + .error("An error occurred while loading group {} in scene {}.", this.id, sceneId, e); } catch (LuaError luaError) { Grasscutter.getLogger() .error( diff --git a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java index 883c66e0b..bf26d1705 100644 --- a/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java +++ b/src/main/java/emu/grasscutter/scripts/data/ScriptArgs.java @@ -5,12 +5,9 @@ import lombok.ToString; @ToString public class ScriptArgs { - @Getter - public int param1; - @Getter - public int param2; - @Getter - public int param3; + @Getter public int param1; + @Getter public int param2; + @Getter public int param3; public int source_eid; // Source entity public int target_eid; public int group_id; diff --git a/src/main/java/emu/grasscutter/server/event/EventHandler.java b/src/main/java/emu/grasscutter/server/event/EventHandler.java index d9b0450b3..b47c91210 100644 --- a/src/main/java/emu/grasscutter/server/event/EventHandler.java +++ b/src/main/java/emu/grasscutter/server/event/EventHandler.java @@ -59,13 +59,12 @@ public final class EventHandler { private final Class eventClass; private EventConsumer listener; /** - * -- GETTER -- - * Returns the handler's priority. + * -- GETTER -- Returns the handler's priority. * * @return The priority of the handler. */ - @Getter - private HandlerPriority priority; + @Getter private HandlerPriority priority; + private boolean handleCanceled; private Plugin plugin; diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java index c54b4750c..b386331de 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java @@ -14,5 +14,4 @@ public final class QueryAllRegionsEvent extends ServerEvent { this.regionList = regionList; } - } diff --git a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java index b6c0a0cff..8054cc223 100644 --- a/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java +++ b/src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java @@ -14,5 +14,4 @@ public final class QueryCurrentRegionEvent extends ServerEvent { this.regionInfo = regionInfo; } - } diff --git a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java index 410458818..fedda674d 100644 --- a/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java +++ b/src/main/java/emu/grasscutter/server/event/entity/EntityMoveEvent.java @@ -19,5 +19,4 @@ public final class EntityMoveEvent extends EntityEvent { this.rotation = rotation; this.motionState = motionState; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java index 699105d16..e94aca6f4 100644 --- a/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/PlayerCreationEvent.java @@ -9,12 +9,10 @@ import lombok.Setter; @Getter public final class PlayerCreationEvent extends GameEvent { private final GameSession session; - @Setter - private Class playerClass; + @Setter private Class playerClass; public PlayerCreationEvent(GameSession session, Class playerClass) { this.session = session; this.playerClass = playerClass; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java index fc6f247cc..7080641a1 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceiveCommandFeedbackEvent.java @@ -3,16 +3,13 @@ package emu.grasscutter.server.event.game; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.event.Cancellable; import emu.grasscutter.server.event.types.ServerEvent; +import javax.annotation.Nullable; import lombok.Getter; import lombok.Setter; -import javax.annotation.Nullable; - public final class ReceiveCommandFeedbackEvent extends ServerEvent implements Cancellable { @Nullable private final Player player; - @Setter - @Getter - private String message; + @Setter @Getter private String message; public ReceiveCommandFeedbackEvent(@Nullable Player player, String message) { super(Type.GAME); diff --git a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java index 9419aef77..092dab884 100644 --- a/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java @@ -10,8 +10,7 @@ import lombok.Setter; public final class ReceivePacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; private final int packetId; - @Setter - private byte[] packetData; + @Setter private byte[] packetData; public ReceivePacketEvent(GameSession gameSession, int packetId, byte[] packetData) { super(Type.GAME); @@ -20,5 +19,4 @@ public final class ReceivePacketEvent extends ServerEvent implements Cancellable this.packetId = packetId; this.packetData = packetData; } - } diff --git a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java index 9d6d724ca..cd194a7aa 100644 --- a/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java +++ b/src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java @@ -10,8 +10,7 @@ import lombok.Setter; @Getter public final class SendPacketEvent extends ServerEvent implements Cancellable { private final GameSession gameSession; - @Setter - private BasePacket packet; + @Setter private BasePacket packet; public SendPacketEvent(GameSession gameSession, BasePacket packet) { super(Type.GAME); @@ -19,5 +18,4 @@ public final class SendPacketEvent extends ServerEvent implements Cancellable { this.gameSession = gameSession; this.packet = packet; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java index 121271b9f..355e5f18a 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerLogEvent.java @@ -15,5 +15,4 @@ public final class ServerLogEvent extends ServerEvent { this.loggingEvent = loggingEvent; this.consoleMessage = consoleMessage; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java index e9951098b..92c1abac0 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStartEvent.java @@ -1,9 +1,8 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; -import lombok.Getter; - import java.time.OffsetDateTime; +import lombok.Getter; @Getter public final class ServerStartEvent extends ServerEvent { @@ -14,5 +13,4 @@ public final class ServerStartEvent extends ServerEvent { this.startTime = startTime; } - } diff --git a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java index eff1b97c7..0f577a875 100644 --- a/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java +++ b/src/main/java/emu/grasscutter/server/event/internal/ServerStopEvent.java @@ -1,9 +1,8 @@ package emu.grasscutter.server.event.internal; import emu.grasscutter.server.event.types.ServerEvent; -import lombok.Getter; - import java.time.OffsetDateTime; +import lombok.Getter; @Getter public final class ServerStopEvent extends ServerEvent { @@ -14,5 +13,4 @@ public final class ServerStopEvent extends ServerEvent { this.stopTime = stopTime; } - } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java index 05f440733..c24caccd6 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerOpenChestEvent.java @@ -11,8 +11,7 @@ import lombok.Setter; @Getter public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellable { private final GadgetChest chest; - @Setter - private ChestReward reward; + @Setter private ChestReward reward; public PlayerOpenChestEvent(Player player, GadgetChest chest, ChestReward reward) { super(player); @@ -20,5 +19,4 @@ public final class PlayerOpenChestEvent extends PlayerEvent implements Cancellab this.chest = chest; this.reward = reward; } - } diff --git a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java index 7cfe831aa..c040bfe4a 100644 --- a/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java +++ b/src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java @@ -17,5 +17,4 @@ public final class PlayerReceiveMailEvent extends PlayerEvent implements Cancell this.message = message; } - } diff --git a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java index 12948bdbf..51546dd96 100644 --- a/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/EntityEvent.java @@ -12,5 +12,4 @@ public abstract class EntityEvent extends Event { public EntityEvent(GameEntity entity) { this.entity = entity; } - } diff --git a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java index b506f95e5..f59a18e98 100644 --- a/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java +++ b/src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java @@ -12,5 +12,4 @@ public abstract class PlayerEvent extends Event { public PlayerEvent(Player player) { this.player = player; } - } diff --git a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java index 883cd2b7f..c7e9bbdb6 100644 --- a/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java +++ b/src/main/java/emu/grasscutter/server/game/BaseGameSystem.java @@ -9,5 +9,4 @@ public abstract class BaseGameSystem { public BaseGameSystem(GameServer server) { this.server = server; } - } diff --git a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java index d1e47b54d..13cd482be 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java +++ b/src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.game; +import static emu.grasscutter.config.Configuration.GAME_INFO; + import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.net.packet.Opcodes; @@ -11,8 +13,6 @@ import emu.grasscutter.server.game.GameSession.SessionState; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import static emu.grasscutter.config.Configuration.GAME_INFO; - public final class GameServerPacketHandler { private final Int2ObjectMap handlers; @@ -33,7 +33,7 @@ public final class GameServerPacketHandler { this.handlers.put(opcode.value(), packetHandler); } catch (Exception e) { Grasscutter.getLogger() - .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); + .warn("Unable to register handler {}.", handlerClass.getSimpleName(), e); } } @@ -45,7 +45,7 @@ public final class GameServerPacketHandler { // Debug Grasscutter.getLogger() - .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName()); + .debug("Registered {} {}s", this.handlers.size(), handlerClass.getSimpleName()); } public void handle(GameSession session, int opcode, byte[] header, byte[] payload) { @@ -83,7 +83,7 @@ public final class GameServerPacketHandler { ReceivePacketEvent event = new ReceivePacketEvent(session, opcode, payload); event.call(); if (!event.isCanceled()) // If event is not canceled, continue. - handler.handle(session, header, event.getPacketData()); + handler.handle(session, header, event.getPacketData()); } catch (Exception ex) { // TODO Remove this when no more needed ex.printStackTrace(); @@ -93,9 +93,9 @@ public final class GameServerPacketHandler { // Log unhandled packets if (GAME_INFO.logPackets == ServerDebugMode.MISSING - || GAME_INFO.logPackets == ServerDebugMode.ALL) { + || GAME_INFO.logPackets == ServerDebugMode.ALL) { Grasscutter.getLogger() - .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); + .info("Unhandled packet ({}): {}", opcode, PacketOpcodesUtils.getOpcodeName(opcode)); } } } diff --git a/src/main/java/emu/grasscutter/server/game/GameSession.java b/src/main/java/emu/grasscutter/server/game/GameSession.java index 092bf72d3..a3ffdf8af 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSession.java +++ b/src/main/java/emu/grasscutter/server/game/GameSession.java @@ -17,8 +17,7 @@ import java.nio.file.Path; import lombok.*; public class GameSession implements GameSessionManager.KcpChannel { - @Getter - private final GameServer server; + @Getter private final GameServer server; private GameSessionManager.KcpTunnel tunnel; @Getter @Setter private Account account; @@ -96,7 +95,7 @@ public class GameSession implements GameSessionManager.KcpChannel { public void logPacket(String sendOrRecv, int opcode, byte[] payload) { Grasscutter.getLogger() - .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode); + .info("{}: {} ({})", sendOrRecv, PacketOpcodesUtils.getOpcodeName(opcode), opcode); if (GAME_INFO.isShowPacketPayload) System.out.println(Utils.bytesToHex(payload)); } diff --git a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java index ed1b292ff..6d8702e62 100644 --- a/src/main/java/emu/grasscutter/server/game/GameSessionManager.java +++ b/src/main/java/emu/grasscutter/server/game/GameSessionManager.java @@ -12,6 +12,7 @@ import lombok.Getter; public class GameSessionManager { @Getter private static final DefaultEventLoop logicThread = new DefaultEventLoop(); private static final ConcurrentHashMap sessions = new ConcurrentHashMap<>(); + @Getter private static final KcpListener listener = new KcpListener() { diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index cc29fbe28..be8d4cc8b 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -22,7 +22,6 @@ import java.time.Instant; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Pattern; - import lombok.Getter; import org.slf4j.Logger; @@ -332,7 +331,6 @@ public final class RegionHandler implements Router { this.regionQuery = prq; this.base64 = b64; } - } /** diff --git a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java index 70e3f053a..f7a37c8f2 100644 --- a/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java +++ b/src/main/java/emu/grasscutter/server/http/objects/HttpJsonResponse.java @@ -38,11 +38,14 @@ public final class HttpJsonResponse implements Handler { && Arrays.stream(missingRoutes) .anyMatch(x -> Objects.equals(x, ctx.endpointHandlerPath()))) { Grasscutter.getLogger() - .info("{}{}", translate( - "messages.dispatch.request", - Utils.address(ctx), - ctx.method(), - ctx.endpointHandlerPath()), DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""); + .info( + "{}{}", + translate( + "messages.dispatch.request", + Utils.address(ctx), + ctx.method(), + ctx.endpointHandlerPath()), + DISPATCH_INFO.logRequests == ServerDebugMode.MISSING ? "(MISSING)" : ""); } ctx.result(response); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java index 3e2947662..0764d4aa2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java @@ -48,8 +48,7 @@ public class HandlerBuyGoodsReq extends PacketHandler { return; } - List costs = - new ArrayList<>(sg.getCostItemList()); // Can this even be null? + List costs = new ArrayList<>(sg.getCostItemList()); // Can this even be null? costs.add(new ItemParamData(202, sg.getScoin())); costs.add(new ItemParamData(201, sg.getHcoin())); costs.add(new ItemParamData(203, sg.getMcoin())); diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java index ffd1724f7..bcddf0283 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java @@ -129,7 +129,11 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { int maxDelay = 200; long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond; Grasscutter.getLogger() - .trace("MOTION_FALL_ON_GROUND received after {}/{}ms.{}", actualDelay, maxDelay, actualDelay > maxDelay ? " Discard" : ""); + .trace( + "MOTION_FALL_ON_GROUND received after {}/{}ms.{}", + actualDelay, + maxDelay, + actualDelay > maxDelay ? " Discard" : ""); if (actualDelay > maxDelay) { return; } @@ -155,7 +159,14 @@ public class HandlerCombatInvocationsNotify extends PacketHandler { } if (damageFactor > 0) { Grasscutter.getLogger() - .debug("{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", currentHP, maxHP, cachedLandingSpeed, damageFactor, damage, newHP); + .debug( + "{}/{}\tLandingSpeed: {}\tDamageFactor: {}\tDamage: {}\tNewHP: {}", + currentHP, + maxHP, + cachedLandingSpeed, + damageFactor, + damage, + newHP); } else { Grasscutter.getLogger().trace("{}/{}\tLandingSpeed: 0\tNo damage", currentHP, maxHP); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java index f0b084f27..607992c69 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeKickPlayerReq.java @@ -17,11 +17,12 @@ public class HandlerHomeKickPlayerReq extends PacketHandler { .filter(player -> player.getUid() == req.getTargetUid()) .findFirst() .ifPresent( - player -> success.set( - session - .getServer() - .getHomeWorldMPSystem() - .kickPlayerFromHome(session.getPlayer(), player.getUid()))); + player -> + success.set( + session + .getServer() + .getHomeWorldMPSystem() + .kickPlayerFromHome(session.getPlayer(), player.getUid()))); session.send( new PacketHomeKickPlayerRsp( diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java index b4752b421..55f9ed0a2 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java @@ -46,6 +46,5 @@ public class HandlerSetPlayerBirthdayReq extends PacketHandler { case 2 -> day > 0 & day <= 29; default -> false; }; - } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index e2425fc36..d820ce47c 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -44,19 +44,19 @@ public class HandlerTryEnterHomeReq extends PacketHandler { } case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption .FRIEND_ENTER_HOME_OPTION_REFUSE_VALUE -> session.send( - new PacketTryEnterHomeRsp( - RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, - req.getTargetUid())); + new PacketTryEnterHomeRsp( + RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, + req.getTargetUid())); case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> session - .getServer() - .getHomeWorldMPSystem() - .enterHome( - session.getPlayer(), - targetPlayer, - req.getTargetPoint(), - req.getIsTransferToSafePoint()); + .getServer() + .getHomeWorldMPSystem() + .enterHome( + session.getPlayer(), + targetPlayer, + req.getTargetPoint(), + req.getIsTransferToSafePoint()); } return; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java index f50d1b022..e27ee0fe2 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketActivityScheduleInfoNotify.java @@ -14,14 +14,15 @@ public class PacketActivityScheduleInfoNotify extends BasePacket { var proto = ActivityScheduleInfoNotifyOuterClass.ActivityScheduleInfoNotify.newBuilder(); activityConfigItemList.forEach( - item -> proto.addActivityScheduleList( - ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() - .setActivityId(item.getActivityId()) - .setScheduleId(item.getScheduleId()) - .setIsOpen(true) - .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) - .setEndTime(DateHelper.getUnixTime(item.getEndTime())) - .build())); + item -> + proto.addActivityScheduleList( + ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder() + .setActivityId(item.getActivityId()) + .setScheduleId(item.getScheduleId()) + .setIsOpen(true) + .setBeginTime(DateHelper.getUnixTime(item.getBeginTime())) + .setEndTime(DateHelper.getUnixTime(item.getEndTime())) + .build())); this.setData(proto); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java index 74a02ea09..a5679f024 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketBattlePassMissionUpdateNotify.java @@ -21,8 +21,7 @@ public class PacketBattlePassMissionUpdateNotify extends BasePacket { var proto = BattlePassMissionUpdateNotify.newBuilder(); - missions.forEach( - mission -> proto.addMissionList(mission.toProto())); + missions.forEach(mission -> proto.addMissionList(mission.toProto())); this.setData(proto.build()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java index 67e464d03..4ddc149e6 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCodexDataFullNotify.java @@ -93,9 +93,10 @@ public class PacketCodexDataFullNotify extends BasePacket { .getCodex() .getUnlockedReliquarySuitCodex() .forEach( - reliquarySuit -> reliquaryData - .addCodexIdList(reliquarySuit) - .addAllHaveViewedList(Collections.singleton(true))); + reliquarySuit -> + reliquaryData + .addCodexIdList(reliquarySuit) + .addAllHaveViewedList(Collections.singleton(true))); CodexDataFullNotify.Builder proto = CodexDataFullNotify.newBuilder() diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java index 2d6403e42..1b8787063 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCreateVehicleRsp.java @@ -26,25 +26,24 @@ public class PacketCreateVehicleRsp extends BasePacket { && ((EntityVehicle) entity).getOwner().equals(player)) .toList(); - previousVehicles - .forEach( - entity -> { - List vehicleMembers = - ((EntityVehicle) entity).getVehicleMembers().stream().toList(); + previousVehicles.forEach( + entity -> { + List vehicleMembers = + ((EntityVehicle) entity).getVehicleMembers().stream().toList(); - vehicleMembers - .forEach( - vehicleMember -> player - .getScene() - .broadcastPacket( - new PacketVehicleInteractRsp( - ((EntityVehicle) entity), - vehicleMember, - VehicleInteractTypeOuterClass.VehicleInteractType - .VEHICLE_INTERACT_TYPE_OUT))); + vehicleMembers.forEach( + vehicleMember -> + player + .getScene() + .broadcastPacket( + new PacketVehicleInteractRsp( + ((EntityVehicle) entity), + vehicleMember, + VehicleInteractTypeOuterClass.VehicleInteractType + .VEHICLE_INTERACT_TYPE_OUT))); - player.getScene().killEntity(entity, 0); - }); + player.getScene().killEntity(entity, 0); + }); EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java index 402e13aed..65513c620 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java @@ -15,11 +15,11 @@ public class PacketMailChangeNotify extends BasePacket { public PacketMailChangeNotify(Player player, Mail message) { this( player, - new ArrayList<>() { - { - add(message); - } - }); + new ArrayList<>() { + { + add(message); + } + }); } public PacketMailChangeNotify(Player player, List mailList) { diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java index 6d25619cd..47d4124f8 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerDataNotify.java @@ -20,8 +20,9 @@ public class PacketPlayerDataNotify extends BasePacket { player .getProperties() .forEach( - (key, value) -> p.putPropMap( - key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build())); + (key, value) -> + p.putPropMap( + key, PropValue.newBuilder().setType(key).setIval(value).setVal(value).build())); this.setData(p.build()); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java index f1df152c9..1853b681b 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketVehicleInteractRsp.java @@ -37,7 +37,9 @@ public class PacketVehicleInteractRsp extends BasePacket { QuestContent.QUEST_CONTENT_ENTER_VEHICLE, ((EntityVehicle) vehicle).getGadgetId()); } - case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle).getVehicleMembers().remove(vehicleMember); + case VEHICLE_INTERACT_TYPE_OUT -> ((EntityVehicle) vehicle) + .getVehicleMembers() + .remove(vehicleMember); default -> {} } } diff --git a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java index b152bdeb6..fca50cfb2 100644 --- a/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java +++ b/src/main/java/emu/grasscutter/server/scheduler/AsyncServerTask.java @@ -15,14 +15,12 @@ public final class AsyncServerTask implements Runnable { /* Has the task already been started? */ private boolean started = false; /** - * -- GETTER -- - * Returns the state of the task. + * -- GETTER -- Returns the state of the task. * * @return True if the task has finished execution, false otherwise. */ /* Has the task finished execution? */ - @Getter - private boolean finished = false; + @Getter private boolean finished = false; /* The result produced in the async task. */ @Nullable private Object result = null; diff --git a/src/main/java/emu/grasscutter/task/TaskMap.java b/src/main/java/emu/grasscutter/task/TaskMap.java index af98a46ea..22f42d616 100644 --- a/src/main/java/emu/grasscutter/task/TaskMap.java +++ b/src/main/java/emu/grasscutter/task/TaskMap.java @@ -154,12 +154,12 @@ public final class TaskMap { this.afterReset.put(taskData.taskName(), (TaskHandler) object); } } else { - Grasscutter.getLogger() - .error("Class {} is not a TaskHandler!", annotated.getName()); + Grasscutter.getLogger().error("Class {} is not a TaskHandler!", annotated.getName()); } } catch (Exception exception) { Grasscutter.getLogger() - .error("Failed to register task handler for {}", annotated.getSimpleName(), exception); + .error( + "Failed to register task handler for {}", annotated.getSimpleName(), exception); } }); try { diff --git a/src/main/java/emu/grasscutter/tools/Dumpers.java b/src/main/java/emu/grasscutter/tools/Dumpers.java index 47c0e663b..a21579830 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ public interface Dumpers { Language.getTextMapKey(item.getNameTextMapHash()).get(locale), Quality.from(item.getRankLevel()), item.getItemType(), - !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); + !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); // Create a new dump with filtered duplicates. var names = new ArrayList(); diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index a8e62ab54..5cdaaa13f 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -54,7 +54,8 @@ public final class Tools { GameData.getMainQuestDataMap().int2ObjectEntrySet().stream() .collect( Collectors.toMap( - Int2ObjectMap.Entry::getIntKey, e -> (int) e.getValue().getTitleTextMapHash()))); + Int2ObjectMap.Entry::getIntKey, + e -> (int) e.getValue().getTitleTextMapHash()))); // val questDescs = new // Int2IntRBTreeMap(GameData.getQuestDataMap().int2ObjectEntrySet().stream().collect(Collectors.toMap(e -> (int) e.getIntKey(), e -> (int) e.getValue().getDescTextMapHash()))); @@ -189,10 +190,11 @@ public final class Tools { achievementDataMap.values().stream() .filter(AchievementData::isUsed) .forEach( - data -> h.newTranslatedLine( - padAchievementId.formatted(data.getId()) + "{0} - {1}", - data.getTitleTextMapHash(), - data.getDescTextMapHash())); + data -> + h.newTranslatedLine( + padAchievementId.formatted(data.getId()) + "{0} - {1}", + data.getTitleTextMapHash(), + data.getDescTextMapHash())); // Write txt files for (int i = 0; i < TextStrings.NUM_LANGUAGES; i++) { @@ -350,12 +352,13 @@ public final class Tools { try { Files.newDirectoryStream(getResourcePath("TextMap"), "TextMap*.json") .forEach( - path -> availableLangList.add( - path.getFileName() - .toString() - .replace("TextMap", "") - .replace(".json", "") - .toLowerCase())); + path -> + availableLangList.add( + path.getFileName() + .toString() + .replace("TextMap", "") + .replace(".json", "") + .toLowerCase())); } catch (IOException e) { Grasscutter.getLogger().error("Failed to get available languages:", e); } diff --git a/src/main/java/emu/grasscutter/utils/FileUtils.java b/src/main/java/emu/grasscutter/utils/FileUtils.java index 21566bd75..eebacc014 100644 --- a/src/main/java/emu/grasscutter/utils/FileUtils.java +++ b/src/main/java/emu/grasscutter/utils/FileUtils.java @@ -41,7 +41,7 @@ public final class FileUtils { break; default: Grasscutter.getLogger() - .error("Invalid URI scheme for class resources: {}", uri.getScheme()); + .error("Invalid URI scheme for class resources: {}", uri.getScheme()); break; } } catch (URISyntaxException | IOException e) { @@ -82,10 +82,10 @@ public final class FileUtils { path = excelBinOutput.get().getParent(); if (path == null) path = root; Grasscutter.getLogger() - .debug("Resources will be loaded from \"" + resources + "/{}\"", path); + .debug("Resources will be loaded from \"" + resources + "/{}\"", path); } else { Grasscutter.getLogger() - .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); + .error("Failed to find ExcelBinOutput in resources zip \"" + resources + "\""); } } catch (IOException e) { Grasscutter.getLogger().error("Failed to scan resources zip \"" + resources + "\""); diff --git a/src/main/java/emu/grasscutter/utils/JsonAdapters.java b/src/main/java/emu/grasscutter/utils/JsonAdapters.java index d5f765bee..8f0920027 100644 --- a/src/main/java/emu/grasscutter/utils/JsonAdapters.java +++ b/src/main/java/emu/grasscutter/utils/JsonAdapters.java @@ -13,13 +13,12 @@ import emu.grasscutter.game.world.Position; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import lombok.val; - import java.io.IOException; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.Objects; +import lombok.val; public interface JsonAdapters { class DynamicFloatAdapter extends TypeAdapter { @@ -40,25 +39,24 @@ public interface JsonAdapters { val opStack = new ArrayList(); while (reader.hasNext()) { opStack.add( - switch (reader.peek()) { - case STRING -> new DynamicFloat.StackOp(reader.nextString()); - case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); - case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); - default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); - }); + switch (reader.peek()) { + case STRING -> new DynamicFloat.StackOp(reader.nextString()); + case NUMBER -> new DynamicFloat.StackOp((float) reader.nextDouble()); + case BOOLEAN -> new DynamicFloat.StackOp(reader.nextBoolean()); + default -> throw new IOException( + "Invalid DynamicFloat definition - " + reader.peek().name()); + }); } reader.endArray(); return new DynamicFloat(opStack); } default -> throw new IOException( - "Invalid DynamicFloat definition - " + reader.peek().name()); + "Invalid DynamicFloat definition - " + reader.peek().name()); } } @Override - public void write(JsonWriter writer, DynamicFloat f) { - } + public void write(JsonWriter writer, DynamicFloat f) {} } class IntListAdapter extends TypeAdapter { @@ -80,7 +78,7 @@ public interface JsonAdapters { public void write(JsonWriter writer, IntList l) throws IOException { writer.beginArray(); for (val i : l) // .forEach() doesn't appreciate exceptions - writer.value(i); + writer.value(i); writer.endArray(); } } @@ -117,7 +115,7 @@ public interface JsonAdapters { throw new IOException("Invalid GridPosition definition - " + in.peek().name()); return new GridPosition( - Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); + Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])); } } diff --git a/src/main/java/emu/grasscutter/utils/TsvUtils.java b/src/main/java/emu/grasscutter/utils/TsvUtils.java index 16fc75941..5381059e5 100644 --- a/src/main/java/emu/grasscutter/utils/TsvUtils.java +++ b/src/main/java/emu/grasscutter/utils/TsvUtils.java @@ -228,7 +228,9 @@ public final class TsvUtils { return tree.toClass(classType, null); } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + .warn( + "Error deserializing an instance of class {}", + classType.getCanonicalName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger().warn("Tokens are: {}", tokens); @@ -283,7 +285,9 @@ public final class TsvUtils { return obj; } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {}", classType.getCanonicalName()); + .warn( + "Error deserializing an instance of class {}", + classType.getCanonicalName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger().warn("Tokens are: {}", tokens); @@ -294,14 +298,16 @@ public final class TsvUtils { .toList(); } catch (NoSuchFileException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", filename); + .error( + "Error loading file '{}' - File does not exist. You are missing resources. Note that this file may exist in JSON, TSV, or TSJ format, any of which are suitable.", + filename); return null; } catch (IOException e) { Grasscutter.getLogger().error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } catch (NoSuchMethodException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename); + .error("Error loading file '{}' - Class is missing NoArgsConstructor", filename); return null; } } @@ -398,20 +404,25 @@ public final class TsvUtils { return constructor.newInstance(args); } catch (Exception e) { Grasscutter.getLogger() - .warn("Error deserializing an instance of class {} : {}", classType.getCanonicalName(), constructor.getName()); + .warn( + "Error deserializing an instance of class {} : {}", + classType.getCanonicalName(), + constructor.getName()); Grasscutter.getLogger().warn("At token #{} of #{}", t, m); Grasscutter.getLogger() - .warn("Arg names are: {}", Arrays.toString(conArgNames)); + .warn("Arg names are: {}", Arrays.toString(conArgNames)); Grasscutter.getLogger() - .warn("Arg types are: {}", Arrays.toString(argTypes)); + .warn("Arg types are: {}", Arrays.toString(argTypes)); Grasscutter.getLogger() - .warn("Default Args are: {}", Arrays.toString(defaultArgs)); + .warn("Default Args are: {}", Arrays.toString(defaultArgs)); Grasscutter.getLogger().warn("Args are: {}", Arrays.toString(args)); Grasscutter.getLogger().warn("Header names are: {}", headerNames); Grasscutter.getLogger() - .warn("Header types are: {}", IntStream.of(argPositions) - .mapToObj(i -> (i >= 0) ? argTypes[i] : null) - .toList()); + .warn( + "Header types are: {}", + IntStream.of(argPositions) + .mapToObj(i -> (i >= 0) ? argTypes[i] : null) + .toList()); Grasscutter.getLogger().warn("Tokens are: {}", tokens); Grasscutter.getLogger().warn("Stacktrace is: ", e); return null; @@ -420,7 +431,7 @@ public final class TsvUtils { .toList(); } catch (IOException e) { Grasscutter.getLogger() - .error("Error loading file '{}' - Stacktrace is: ", filename, e); + .error("Error loading file '{}' - Stacktrace is: ", filename, e); return null; } }) @@ -569,14 +580,19 @@ public final class TsvUtils { // System.out.println("Exception while setting field "+name+" for class "+objClass+" // - "+e); Grasscutter.getLogger() - .error("Exception while setting field {} ({}) for class {} - ", name, field.classType, objClass, e); + .error( + "Exception while setting field {} ({}) for class {} - ", + name, + field.classType, + objClass, + e); } }); return obj; } catch (Exception e) { // System.out.println("Exception while creating object of class "+objClass+" - "+e); Grasscutter.getLogger() - .error("Exception while creating object of class {} - ", objClass, e); + .error("Exception while creating object of class {} - ", objClass, e); return null; } } diff --git a/src/main/java/emu/grasscutter/utils/Utils.java b/src/main/java/emu/grasscutter/utils/Utils.java index e4fc8c0e7..5e7729460 100644 --- a/src/main/java/emu/grasscutter/utils/Utils.java +++ b/src/main/java/emu/grasscutter/utils/Utils.java @@ -151,7 +151,7 @@ public final class Utils { return true; } catch (Exception exception) { Grasscutter.getLogger() - .warn("Unable to copy resource {} to {}", resource, destination, exception); + .warn("Unable to copy resource {} to {}", resource, destination, exception); return false; } } diff --git a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java index 6a0f4e1dd..c7bc42a80 100644 --- a/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java +++ b/src/main/java/emu/grasscutter/utils/algorithms/KahnsSort.java @@ -57,8 +57,7 @@ public class KahnsSort { } } - if (degreeList.values().stream().anyMatch(value -> value != 0)) - return null; // Loop found + if (degreeList.values().stream().anyMatch(value -> value != 0)) return null; // Loop found return orderedList; } diff --git a/src/main/java/emu/grasscutter/utils/lang/Language.java b/src/main/java/emu/grasscutter/utils/lang/Language.java index 293ecd4be..5c3b1c968 100644 --- a/src/main/java/emu/grasscutter/utils/lang/Language.java +++ b/src/main/java/emu/grasscutter/utils/lang/Language.java @@ -29,12 +29,9 @@ public final class Language { private static boolean scannedTextmaps = false; // Ensure that we don't infinitely rescan on cache misses that don't exist private static Int2ObjectMap textMapStrings; - /** - * -- GETTER -- - * get language code - */ - @Getter - private final String languageCode; + /** -- GETTER -- get language code */ + @Getter private final String languageCode; + private final Map translations = new ConcurrentHashMap<>(); /** Reads a file and creates a language instance. */ @@ -50,7 +47,7 @@ public final class Language { .forEach(entry -> putFlattenedKey(translations, entry.getKey(), entry.getValue())); } catch (Exception exception) { Grasscutter.getLogger() - .warn("Failed to load language file: {}", description.getLanguageCode(), exception); + .warn("Failed to load language file: {}", description.getLanguageCode(), exception); } } @@ -200,7 +197,7 @@ public final class Language { if (file == null) { // Provided fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback); + .warn("Failed to load language file: {}, falling back to: {}", fileName, fallback); actualLanguageCode = fallbackLanguageCode; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -211,7 +208,7 @@ public final class Language { if (file == null) { // Fallback the fallback language. Grasscutter.getLogger() - .warn("Failed to load language file: {}, falling back to: en-US.json", fallback); + .warn("Failed to load language file: {}, falling back to: en-US.json", fallback); actualLanguageCode = "en-US"; if (cachedLanguages.containsKey(actualLanguageCode)) { return new LanguageStreamDescription(actualLanguageCode, null); @@ -259,30 +256,27 @@ public final class Language { TextStrings.LIST_LANGUAGES.parallelStream() .collect( Collectors.toConcurrentMap( - TextStrings.MAP_LANGUAGES::getInt, - s -> loadTextMapFile(s, nameHashes))); + TextStrings.MAP_LANGUAGES::getInt, s -> loadTextMapFile(s, nameHashes))); List> languageMaps = - IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(mapLanguageMaps::get) - .toList(); + IntStream.range(0, TextStrings.NUM_LANGUAGES).mapToObj(mapLanguageMaps::get).toList(); Map canonicalTextStrings = new HashMap<>(); return new Int2ObjectOpenHashMap<>( - nameHashes - .intStream() - .boxed() - .collect( - Collectors.toMap( - key -> key, - key -> { - TextStrings t = - new TextStrings( - IntStream.range(0, TextStrings.NUM_LANGUAGES) - .mapToObj(i -> languageMaps.get(i).get((int) key)) - .collect(Collectors.toList()), - key); - return canonicalTextStrings.computeIfAbsent(t, x -> t); - }))); + nameHashes + .intStream() + .boxed() + .collect( + Collectors.toMap( + key -> key, + key -> { + TextStrings t = + new TextStrings( + IntStream.range(0, TextStrings.NUM_LANGUAGES) + .mapToObj(i -> languageMaps.get(i).get((int) key)) + .collect(Collectors.toList()), + key); + return canonicalTextStrings.computeIfAbsent(t, x -> t); + }))); } @SuppressWarnings("unchecked") diff --git a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java index 5b6b8abc0..3ac2e49f8 100644 --- a/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java +++ b/src/main/java/emu/grasscutter/utils/objects/ServerLogEventAppender.java @@ -4,11 +4,10 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.AppenderBase; import ch.qos.logback.core.encoder.Encoder; import emu.grasscutter.server.event.internal.ServerLogEvent; +import java.nio.charset.StandardCharsets; import lombok.Getter; import lombok.Setter; -import java.nio.charset.StandardCharsets; - @Setter @Getter public final class ServerLogEventAppender extends AppenderBase { @@ -21,5 +20,4 @@ public final class ServerLogEventAppender extends AppenderBase { new ServerLogEvent((ILoggingEvent) event, new String(byteArray, StandardCharsets.UTF_8)); sle.call(); } - }