From ef58ab3e5a56f9e3164c88a4ea0a600bfbdf72c3 Mon Sep 17 00:00:00 2001 From: "Breno A." Date: Sun, 9 Jun 2024 08:54:37 -0300 Subject: [PATCH] refactor: replace `size() == 0` with isEmpty() --- .../command/commands/AchievementCommand.java | 6 +++--- .../command/commands/AnnounceCommand.java | 2 +- .../grasscutter/command/commands/ClearCommand.java | 2 +- .../command/commands/EnterDungeonCommand.java | 2 +- .../grasscutter/command/commands/GiveCommand.java | 4 ++-- .../grasscutter/command/commands/ListCommand.java | 4 ++-- .../command/commands/ResetConstCommand.java | 2 +- .../command/commands/SendMailCommand.java | 2 +- .../command/commands/SendMessageCommand.java | 2 +- .../command/commands/SetConstCommand.java | 2 +- .../grasscutter/command/commands/SpawnCommand.java | 2 +- .../command/commands/TalentCommand.java | 2 +- src/main/java/emu/grasscutter/data/GameDepot.java | 2 +- .../java/emu/grasscutter/data/ResourceLoader.java | 4 ++-- .../grasscutter/data/binout/OpenConfigEntry.java | 4 ++-- .../data/excels/EnvAnimalGatherConfigData.java | 2 +- .../data/excels/RefreshPolicyExcelConfigData.java | 2 +- .../data/excels/avatar/AvatarSkillDepotData.java | 2 +- .../data/excels/tower/TowerScheduleData.java | 2 +- .../grasscutter/game/ability/AbilityManager.java | 14 ++++++-------- .../java/emu/grasscutter/game/avatar/Avatar.java | 8 ++++---- .../game/battlepass/BattlePassManager.java | 2 +- .../java/emu/grasscutter/game/chat/ChatSystem.java | 12 ++++++------ .../grasscutter/game/drop/DropSystemLegacy.java | 2 +- .../grasscutter/game/dungeons/DungeonSystem.java | 2 +- .../emu/grasscutter/game/entity/EntityAvatar.java | 2 +- .../game/expedition/ExpeditionSystem.java | 2 +- .../emu/grasscutter/game/inventory/GameItem.java | 6 +++--- .../emu/grasscutter/game/inventory/Inventory.java | 2 +- .../emu/grasscutter/game/player/InvokeHandler.java | 6 +++--- .../grasscutter/game/player/PlayerBuffManager.java | 2 +- .../emu/grasscutter/game/player/TeamManager.java | 10 +++++----- .../java/emu/grasscutter/game/quest/GameQuest.java | 8 ++++---- .../java/emu/grasscutter/game/shop/ShopSystem.java | 2 +- .../game/systems/AnnouncementSystem.java | 2 +- .../grasscutter/game/systems/InventorySystem.java | 4 ++-- .../emu/grasscutter/game/tower/TowerManager.java | 2 +- .../java/emu/grasscutter/game/world/Scene.java | 8 ++++---- .../java/emu/grasscutter/game/world/World.java | 2 +- .../grasscutter/scripts/SceneScriptManager.java | 2 +- .../scripts/serializer/LuaSerializer.java | 2 +- .../server/http/dispatch/RegionHandler.java | 4 ++-- .../server/http/documentation/HandbookHandler.java | 2 +- ...dlerClientAbilitiesInitFinishCombineNotify.java | 2 +- .../recv/HandlerClientAbilityInitFinishNotify.java | 2 +- .../server/packet/recv/HandlerQueryPathReq.java | 2 +- .../packet/recv/HandlerSetPlayerNameReq.java | 2 +- .../packet/recv/HandlerSetPlayerSignatureReq.java | 2 +- .../send/PacketClientAbilityInitFinishNotify.java | 2 +- .../packet/send/PacketGetAllMailResultNotify.java | 2 +- .../packet/send/PacketGetOnlinePlayerListRsp.java | 2 +- .../server/packet/send/PacketGetScenePointRsp.java | 2 +- .../server/scheduler/ServerTaskScheduler.java | 2 +- src/main/java/emu/grasscutter/tools/Dumpers.java | 2 +- 54 files changed, 89 insertions(+), 91 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java index 85603931d..7510895e5 100644 --- a/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AchievementCommand.java @@ -69,7 +69,7 @@ public final class AchievementCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); return; } @@ -88,7 +88,7 @@ public final class AchievementCommand implements CommandHandler { private void grant( Player sender, Player targetPlayer, Achievements achievements, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); } @@ -109,7 +109,7 @@ public final class AchievementCommand implements CommandHandler { private void revoke( Player sender, Player targetPlayer, Achievements achievements, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { this.sendUsageMessage(sender); } diff --git a/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java b/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java index 9cd76ba13..9433a8a57 100644 --- a/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/AnnounceCommand.java @@ -19,7 +19,7 @@ public final class AnnounceCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { var manager = Grasscutter.getGameServer().getAnnouncementSystem(); - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java index 792ce1b3b..bbfb47078 100644 --- a/src/main/java/emu/grasscutter/command/commands/ClearCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ClearCommand.java @@ -51,7 +51,7 @@ public final class ClearCommand implements CommandHandler { // Extract any tagged int arguments (e.g. "lv90", "x100", "r5") parseIntParameters(args, param, intCommandHandlers); - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java b/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java index c61923452..6bce736f8 100644 --- a/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/EnterDungeonCommand.java @@ -16,7 +16,7 @@ public final class EnterDungeonCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java index d5134af34..f7b02892b 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveCommand.java @@ -279,7 +279,7 @@ public final class GiveCommand implements CommandHandler { parseIntParameters(args, param, intCommandHandlers); // At this point, first remaining argument MUST be itemId/avatarId - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar throw new IllegalArgumentException(); } @@ -362,7 +362,7 @@ public final class GiveCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { // *No args* + if (args.isEmpty()) { // *No args* sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/ListCommand.java b/src/main/java/emu/grasscutter/command/commands/ListCommand.java index ce0259e09..a4831eed6 100644 --- a/src/main/java/emu/grasscutter/command/commands/ListCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ListCommand.java @@ -19,14 +19,14 @@ public final class ListCommand implements CommandHandler { Map playersMap = Grasscutter.getGameServer().getPlayers(); boolean needUID = false; - if (args.size() > 0) { + if (!args.isEmpty()) { needUID = args.get(0).equals("uid"); } CommandHandler.sendMessage( sender, translate(sender, "commands.list.success", playersMap.size())); - if (playersMap.size() != 0) { + if (!playersMap.isEmpty()) { StringBuilder playerSet = new StringBuilder(); boolean finalNeedUID = needUID; diff --git a/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java b/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java index acecf334d..1ea37f8b7 100644 --- a/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/ResetConstCommand.java @@ -18,7 +18,7 @@ public final class ResetConstCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() > 0 && args.get(0).equalsIgnoreCase("all")) { + if (!args.isEmpty() && args.get(0).equalsIgnoreCase("all")) { targetPlayer.getAvatars().forEach(this::resetConstellation); CommandHandler.sendMessage(sender, translate(sender, "commands.resetConst.reset_all")); } else { diff --git a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java index bf4d96246..b1ed3ad4b 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMailCommand.java @@ -69,7 +69,7 @@ public final class SendMailCommand implements CommandHandler { } else { MailBuilder mailBuilder = mailBeingConstructed.get(senderId); - if (args.size() >= 1) { + if (!args.isEmpty()) { switch (args.get(0).toLowerCase()) { case "stop" -> { mailBeingConstructed.remove(senderId); diff --git a/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java b/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java index cae221176..69d46e103 100644 --- a/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SendMessageCommand.java @@ -17,7 +17,7 @@ public final class SendMessageCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() == 0) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java b/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java index 1e0edd264..a8debd4e6 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetConstCommand.java @@ -17,7 +17,7 @@ import java.util.List; public final class SetConstCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java b/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java index d62f8b854..a8a0f13e2 100644 --- a/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SpawnCommand.java @@ -49,7 +49,7 @@ public final class SpawnCommand implements CommandHandler { parseIntParameters(args, param, intCommandHandlers); // At this point, first remaining argument MUST be the id and the rest the pos - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar throw new IllegalArgumentException(); } diff --git a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java index ff71be1bf..6edd2dd68 100644 --- a/src/main/java/emu/grasscutter/command/commands/TalentCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/TalentCommand.java @@ -27,7 +27,7 @@ public final class TalentCommand implements CommandHandler { @Override public void execute(Player sender, Player targetPlayer, List args) { - if (args.size() < 1) { + if (args.isEmpty()) { sendUsageMessage(sender); return; } diff --git a/src/main/java/emu/grasscutter/data/GameDepot.java b/src/main/java/emu/grasscutter/data/GameDepot.java index 34cfd57ee..0d8711318 100644 --- a/src/main/java/emu/grasscutter/data/GameDepot.java +++ b/src/main/java/emu/grasscutter/data/GameDepot.java @@ -50,7 +50,7 @@ public class GameDepot { list.add(data); } // Let the server owner know if theyre missing weights - if (relicMainPropDepot.size() == 0 || relicAffixDepot.size() == 0) { + if (relicMainPropDepot.isEmpty() || relicAffixDepot.isEmpty()) { Grasscutter.getLogger() .error( "Relic properties are missing weights! Please check your ReliquaryMainPropExcelConfigData or ReliquaryAffixExcelConfigData files in your ExcelBinOutput folder."); diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 8a6c91879..7d1b767f8 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -413,7 +413,7 @@ public final class ResourceLoader { GameData.getAbilityHashes().put(Utils.abilityHash(data.abilityName), data.abilityName); var modifiers = data.modifiers; - if (modifiers == null || modifiers.size() == 0) return; + if (modifiers == null || modifiers.isEmpty()) return; var name = data.abilityName; var modifierEntry = new AbilityModifierEntry(name); @@ -647,7 +647,7 @@ public final class ResourceLoader { path -> { try { val data = JsonUtils.loadToClass(path, SceneNpcBornData.class); - if (data.getBornPosList() == null || data.getBornPosList().size() == 0) { + if (data.getBornPosList() == null || data.getBornPosList().isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java index 6270eb601..c5f9c1a40 100644 --- a/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java +++ b/src/main/java/emu/grasscutter/data/binout/OpenConfigEntry.java @@ -25,11 +25,11 @@ public class OpenConfigEntry { } } - if (abilityList.size() > 0) { + if (!abilityList.isEmpty()) { this.addAbilities = abilityList.toArray(new String[0]); } - if (modList.size() > 0) { + if (!modList.isEmpty()) { this.skillPointModifiers = modList.toArray(new SkillPointModifier[0]); } } diff --git a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java index ebec960cb..002c75141 100644 --- a/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/EnvAnimalGatherConfigData.java @@ -30,6 +30,6 @@ public class EnvAnimalGatherConfigData extends GameResource { } public ItemParamData getGatherItem() { - return gatherItemId.size() > 0 ? gatherItemId.get(0) : null; + return !gatherItemId.isEmpty() ? gatherItemId.get(0) : null; } } diff --git a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java index a81d3a2c8..6429728f8 100644 --- a/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java +++ b/src/main/java/emu/grasscutter/data/excels/RefreshPolicyExcelConfigData.java @@ -72,7 +72,7 @@ public class RefreshPolicyExcelConfigData extends GameResource { return (params.get(upper_bound_idx - 1) - params.get(0)); } case REFRESH_DAYBEGIN_INTERVAL: - if (params.size() == 0) return -1; + if (params.isEmpty()) return -1; return params.get(0) * 60 * 60 * 24; } } catch (Exception e) { diff --git a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java index 0f844701d..1e055ec2e 100644 --- a/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java +++ b/src/main/java/emu/grasscutter/data/excels/avatar/AvatarSkillDepotData.java @@ -52,7 +52,7 @@ public class AvatarSkillDepotData extends GameResource { this.elementType = ElementType.None; } // Set embryo abilities (if player skill depot) - if (getSkillDepotAbilityGroup() != null && getSkillDepotAbilityGroup().length() > 0) { + if (getSkillDepotAbilityGroup() != null && !getSkillDepotAbilityGroup().isEmpty()) { AvatarConfig config = GameDepot.getPlayerAbilities().get(getSkillDepotAbilityGroup()); if (config != null) { diff --git a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java index 4a050829f..7652e644b 100644 --- a/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java +++ b/src/main/java/emu/grasscutter/data/excels/tower/TowerScheduleData.java @@ -19,7 +19,7 @@ public class TowerScheduleData extends GameResource { public void onLoad() { super.onLoad(); this.schedules = - this.schedules.stream().filter(item -> item.getFloorList().size() > 0).toList(); + this.schedules.stream().filter(item -> !item.getFloorList().isEmpty()).toList(); } public int getScheduleId() { diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index b5bef4276..3bf06e5ad 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -83,14 +83,12 @@ public final class AbilityManager extends BasePlayerManager { boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; if (modifier.onAdded != null) { skillInvincibility |= - Arrays.stream(modifier.onAdded) - .filter( - action -> - action.type == AbilityModifierAction.Type.AttachAbilityStateResistance - && action.resistanceListID == 11002) - .toList() - .size() - > 0; + !Arrays.stream(modifier.onAdded) + .filter( + action -> + action.type == AbilityModifierAction.Type.AttachAbilityStateResistance + && action.resistanceListID == 11002) + .toList().isEmpty(); } if (this.burstCasterId == entityId diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 0bae0a2b4..fe3b5e424 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -636,7 +636,7 @@ public class Avatar { } } // Add weapon skill from affixes - if (weapon.getAffixes() != null && weapon.getAffixes().size() > 0) { + if (weapon.getAffixes() != null && !weapon.getAffixes().isEmpty()) { // Weapons usually dont have more than one affix but just in case... for (int af : weapon.getAffixes()) { if (af == 0) { @@ -740,7 +740,7 @@ public class Avatar { } public void addToExtraAbilityEmbryos(String openConfig, boolean forceAdd) { - if (openConfig == null || openConfig.length() == 0) { + if (openConfig == null || openConfig.isEmpty()) { return; } @@ -801,7 +801,7 @@ public class Avatar { .filter(Objects::nonNull) .map(AvatarTalentData::getOpenConfig) .filter(Objects::nonNull) - .filter(openConfig -> openConfig.length() > 0) + .filter(openConfig -> !openConfig.isEmpty()) .map(GameData.getOpenConfigEntries()::get) .filter(Objects::nonNull) .forEach(e -> this.calcConstellation(e, false)); @@ -830,7 +830,7 @@ public class Avatar { case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill - case 1 -> (this.skillDepot.getSkills().size() >= 1) + case 1 -> (!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) default -> 0; diff --git a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java index 0d48355a5..f72c00e64 100644 --- a/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java +++ b/src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java @@ -176,7 +176,7 @@ public class BattlePassManager extends BasePlayerDataManager { private void takeRewardsFromSelectChest( ItemData rewardItemData, int index, ItemParamData entry, List rewardItems) { // Sanity checks. - if (rewardItemData.getItemUse().size() < 1) { + if (rewardItemData.getItemUse().isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java index dd86b0568..9bd64ba32 100644 --- a/src/main/java/emu/grasscutter/game/chat/ChatSystem.java +++ b/src/main/java/emu/grasscutter/game/chat/ChatSystem.java @@ -88,7 +88,7 @@ public class ChatSystem implements ChatSystemHandler { ********************/ public void sendPrivateMessageFromServer(int targetUid, String message) { // Sanity checks. - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -123,7 +123,7 @@ public class ChatSystem implements ChatSystemHandler { public void sendPrivateMessage(Player player, int targetUid, String message) { // Sanity checks. - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -146,7 +146,7 @@ public class ChatSystem implements ChatSystemHandler { // Fetch the new message. message = event.getMessage(); - if (message == null || message.length() == 0) return; + if (message == null || message.isEmpty()) return; // Create chat packet. var packet = new PacketPrivateChatNotify(player.getUid(), targetUid, message); @@ -200,7 +200,7 @@ public class ChatSystem implements ChatSystemHandler { public void sendTeamMessage(Player player, int channel, String message) { // Sanity checks - if (message == null || message.length() == 0) { + if (message == null || message.isEmpty()) { return; } @@ -216,7 +216,7 @@ public class ChatSystem implements ChatSystemHandler { // Fetch the new message. message = event.getMessage(); - if (message == null || message.length() == 0) return; + if (message == null || message.isEmpty()) return; // Fetch the new channel. channel = event.getChannel(); if (channel == -1) return; @@ -254,7 +254,7 @@ public class ChatSystem implements ChatSystemHandler { joinOptions.welcomeEmotes[Utils.randomRange(0, joinOptions.welcomeEmotes.length - 1)]); } - if (joinOptions.welcomeMessage != null && joinOptions.welcomeMessage.length() > 0) { + if (joinOptions.welcomeMessage != null && !joinOptions.welcomeMessage.isEmpty()) { this.sendPrivateMessageFromServer(player.getUid(), joinOptions.welcomeMessage); } } diff --git a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java index d0167ab40..00bdfcb45 100644 --- a/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java +++ b/src/main/java/emu/grasscutter/game/drop/DropSystemLegacy.java @@ -31,7 +31,7 @@ public class DropSystemLegacy extends BaseGameSystem { getDropData().clear(); try { List banners = DataLoader.loadList("Drop.json", DropInfo.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (DropInfo di : banners) { getDropData().put(di.getMonsterId(), di.getDropDataList()); } diff --git a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java index ee56a873c..fdfc92378 100644 --- a/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java +++ b/src/main/java/emu/grasscutter/game/dungeons/DungeonSystem.java @@ -68,7 +68,7 @@ public final class DungeonSystem extends BaseGameSystem { // Check if the player has quests with dungeon IDs. var questDungeons = player.getQuestManager().questsForDungeon(entry); - if (questDungeons.size() > 0) { + if (!questDungeons.isEmpty()) { player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData(), questDungeons)); } else { player.sendPacket(new PacketDungeonEntryInfoRsp(entry.getPointData())); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index 2bff768ba..8a4303430 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -363,7 +363,7 @@ public class EntityAvatar extends GameEntity { } } // Add equip abilities - if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) { + if (!this.getAvatar().getExtraAbilityEmbryos().isEmpty()) { for (String skill : this.getAvatar().getExtraAbilityEmbryos()) { AbilityEmbryo emb = AbilityEmbryo.newBuilder() diff --git a/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java b/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java index d58d4cf62..b2fa5916f 100644 --- a/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java +++ b/src/main/java/emu/grasscutter/game/expedition/ExpeditionSystem.java @@ -24,7 +24,7 @@ public class ExpeditionSystem extends BaseGameSystem { try { List banners = DataLoader.loadList("ExpeditionReward.json", ExpeditionRewardInfo.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (ExpeditionRewardInfo di : banners) { getExpeditionRewardDataList().put(di.getExpId(), di.getExpeditionRewardDataList()); } diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index a89f9f30f..239ac8e9f 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -277,9 +277,9 @@ public class GameItem { .setGuid(this.getGuid()) .setLevel(this.getLevel()) .setGadgetId(this.getItemData().getGadgetId()) - .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0)); + .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(!getAffixes().isEmpty())); - if (this.getAffixes() != null && this.getAffixes().size() > 0) { + if (this.getAffixes() != null && !this.getAffixes().isEmpty()) { for (int affix : this.getAffixes()) { weaponInfo.putAffixMap(affix, this.getRefinement()); } @@ -306,7 +306,7 @@ public class GameItem { .setExp(this.getExp()) .setPromoteLevel(this.getPromoteLevel()); - if (this.getAffixes() != null && this.getAffixes().size() > 0) { + if (this.getAffixes() != null && !this.getAffixes().isEmpty()) { for (int affix : this.getAffixes()) { weapon.putAffixMap(affix, this.getRefinement()); } diff --git a/src/main/java/emu/grasscutter/game/inventory/Inventory.java b/src/main/java/emu/grasscutter/game/inventory/Inventory.java index 7967617c1..0a5b99999 100644 --- a/src/main/java/emu/grasscutter/game/inventory/Inventory.java +++ b/src/main/java/emu/grasscutter/game/inventory/Inventory.java @@ -178,7 +178,7 @@ public class Inventory extends BasePlayerManager implements Iterable { changedItems.add(result); } } - if (changedItems.size() == 0) { + if (changedItems.isEmpty()) { return; } if (reason != null) { diff --git a/src/main/java/emu/grasscutter/game/player/InvokeHandler.java b/src/main/java/emu/grasscutter/game/player/InvokeHandler.java index b6e3e4c5a..7bebf19fe 100644 --- a/src/main/java/emu/grasscutter/game/player/InvokeHandler.java +++ b/src/main/java/emu/grasscutter/game/player/InvokeHandler.java @@ -36,13 +36,13 @@ public class InvokeHandler { } try { - if (entryListForwardAll.size() > 0) { + if (!entryListForwardAll.isEmpty()) { BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAll); player.getScene().broadcastPacket(packet); this.entryListForwardAll.clear(); } - if (entryListForwardAllExceptCur.size() > 0) { + if (!entryListForwardAllExceptCur.isEmpty()) { BasePacket packet = packetClass .getDeclaredConstructor(List.class) @@ -50,7 +50,7 @@ public class InvokeHandler { player.getScene().broadcastPacketToOthers(player, packet); this.entryListForwardAllExceptCur.clear(); } - if (entryListForwardHost.size() > 0) { + if (!entryListForwardHost.isEmpty()) { BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardHost); player.getWorld().getHost().sendPacket(packet); diff --git a/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java b/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java index 9fc66d37e..ca7a2dbdd 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerBuffManager.java @@ -178,7 +178,7 @@ public final class PlayerBuffManager extends BasePlayerManager { return true; }); - if (this.pendingBuffs.size() > 0) { + if (!this.pendingBuffs.isEmpty()) { // Send packet getPlayer() .sendPacket( diff --git a/src/main/java/emu/grasscutter/game/player/TeamManager.java b/src/main/java/emu/grasscutter/game/player/TeamManager.java index 86d7a0d45..0e19dfd90 100644 --- a/src/main/java/emu/grasscutter/game/player/TeamManager.java +++ b/src/main/java/emu/grasscutter/game/player/TeamManager.java @@ -98,7 +98,7 @@ public final class TeamManager extends BasePlayerDataManager { } // same as avatar ability hash (add frm levelEntityConfig data) - if (this.getTeamAbilityEmbryos().size() > 0) { + if (!this.getTeamAbilityEmbryos().isEmpty()) { for (String skill : this.getTeamAbilityEmbryos()) { AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder() @@ -495,7 +495,7 @@ public final class TeamManager extends BasePlayerDataManager { public void setupMpTeam(List list) { // Sanity checks - if (list.size() == 0 + if (list.isEmpty() || list.size() > this.getMaxTeamSize() || !this.getPlayer().isInMultiplayer()) { return; @@ -696,7 +696,7 @@ public final class TeamManager extends BasePlayerDataManager { .map( list -> { // Sanity checks - if (list.size() == 0 || list.size() > this.getMaxTeamSize()) { + if (list.isEmpty() || list.size() > this.getMaxTeamSize()) { return null; } @@ -744,7 +744,7 @@ public final class TeamManager extends BasePlayerDataManager { // Get team TeamInfo teamInfo = this.getTeams().get(teamId); - if (teamInfo == null || teamInfo.getAvatars().size() == 0) { + if (teamInfo == null || teamInfo.getAvatars().isEmpty()) { return; } @@ -1054,7 +1054,7 @@ public final class TeamManager extends BasePlayerDataManager { var avatarIds = scene.getSceneData().getSpecifiedAvatarList(); var specifiedAvatarList = this.getActiveTeam(); - if (avatarIds != null && avatarIds.size() > 0) { + if (avatarIds != null && !avatarIds.isEmpty()) { // certain scene could limit specific avatars' entry specifiedAvatarList.clear(); for (int id : avatarIds) { diff --git a/src/main/java/emu/grasscutter/game/quest/GameQuest.java b/src/main/java/emu/grasscutter/game/quest/GameQuest.java index 7888e4701..6ac1d1313 100644 --- a/src/main/java/emu/grasscutter/game/quest/GameQuest.java +++ b/src/main/java/emu/grasscutter/game/quest/GameQuest.java @@ -67,7 +67,7 @@ public class GameQuest { questData.getFinishCond().stream() .filter(p -> p.getType() == QuestContent.QUEST_CONTENT_TRIGGER_FIRE) .toList(); - if (triggerCond.size() > 0) { + if (!triggerCond.isEmpty()) { for (val cond : triggerCond) { var newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]); if (newTrigger != null) { @@ -158,14 +158,14 @@ public class GameQuest { public boolean clearProgress(boolean notifyDelete) { // TODO improve var oldState = state; - if (questData.getAcceptCond() != null && questData.getAcceptCond().size() != 0) { + if (questData.getAcceptCond() != null && !questData.getAcceptCond().isEmpty()) { this.getMainQuest() .getQuestManager() .getAcceptProgressLists() .put(this.getSubQuestId(), new int[questData.getAcceptCond().size()]); } - if (questData.getFinishCond() != null && questData.getFinishCond().size() != 0) { + if (questData.getFinishCond() != null && !questData.getFinishCond().isEmpty()) { for (var condition : questData.getFinishCond()) { if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) { this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr()); @@ -174,7 +174,7 @@ public class GameQuest { this.finishProgressList = new int[questData.getFinishCond().size()]; } - if (questData.getFailCond() != null && questData.getFailCond().size() != 0) { + if (questData.getFailCond() != null && !questData.getFailCond().isEmpty()) { for (var condition : questData.getFailCond()) { if (condition.getType() == QuestContent.QUEST_CONTENT_LUA_NOTIFY) { this.getOwner().getPlayerProgress().resetCurrentProgress(condition.getParamStr()); diff --git a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java index f3ce4679a..613834f45 100644 --- a/src/main/java/emu/grasscutter/game/shop/ShopSystem.java +++ b/src/main/java/emu/grasscutter/game/shop/ShopSystem.java @@ -48,7 +48,7 @@ public class ShopSystem extends BaseGameSystem { getShopData().clear(); try { List banners = DataLoader.loadList("Shop.json", ShopTable.class); - if (banners.size() > 0) { + if (!banners.isEmpty()) { for (ShopTable shopTable : banners) { shopTable.getItems().forEach(ShopInfo::removeVirtualCosts); getShopData().put(shopTable.getShopId(), shopTable.getItems()); diff --git a/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java b/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java index 16bf1b23f..6d21eb052 100644 --- a/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java +++ b/src/main/java/emu/grasscutter/game/systems/AnnouncementSystem.java @@ -44,7 +44,7 @@ public class AnnouncementSystem extends BaseGameSystem { } public void broadcast(List tpl) { - if (tpl == null || tpl.size() == 0) { + if (tpl == null || tpl.isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java index 3072eebab..568872e23 100644 --- a/src/main/java/emu/grasscutter/game/systems/InventorySystem.java +++ b/src/main/java/emu/grasscutter/game/systems/InventorySystem.java @@ -482,7 +482,7 @@ public class InventorySystem extends BaseGameSystem { if (weapon.getRefinement() >= 4 || weapon.getAffixes() == null - || weapon.getAffixes().size() == 0) { + || weapon.getAffixes().isEmpty()) { return; } @@ -818,7 +818,7 @@ public class InventorySystem extends BaseGameSystem { } // Give back items - if (returnMaterialMap.size() > 0) { + if (!returnMaterialMap.isEmpty()) { returnMaterialMap.forEach((id, count) -> inventory.addItem(new GameItem(id, count))); } diff --git a/src/main/java/emu/grasscutter/game/tower/TowerManager.java b/src/main/java/emu/grasscutter/game/tower/TowerManager.java index 505543c12..b81d206ab 100644 --- a/src/main/java/emu/grasscutter/game/tower/TowerManager.java +++ b/src/main/java/emu/grasscutter/game/tower/TowerManager.java @@ -71,7 +71,7 @@ public class TowerManager extends BasePlayerManager { public Map getRecordMap() { Map recordMap = getTowerData().recordMap; - if (recordMap == null || recordMap.size() == 0) { + if (recordMap == null || recordMap.isEmpty()) { recordMap = new HashMap<>(); recordMap.put(1001, new TowerLevelRecord(1001)); getTowerData().recordMap = recordMap; diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 65fedff48..125188838 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -882,12 +882,12 @@ public class Scene { } } - if (toAdd.size() > 0) { + if (!toAdd.isEmpty()) { toAdd.forEach(this::addEntityDirectly); this.broadcastPacket(new PacketSceneEntityAppearNotify(toAdd, VisionType.VISION_TYPE_BORN)); } - if (toRemove.size() > 0) { + if (!toRemove.isEmpty()) { toRemove.forEach(this::removeEntityDirectly); this.broadcastPacket( new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE)); @@ -1110,7 +1110,7 @@ public class Scene { .filter(e -> e != null && (e.getBlockId() == block.id && e.getGroupId() == group_id)) .toList(); - if (toRemove.size() > 0) { + if (!toRemove.isEmpty()) { toRemove.forEach(this::removeEntityDirectly); this.broadcastPacket( new PacketSceneEntityDisappearNotify(toRemove, VisionType.VISION_TYPE_REMOVE)); @@ -1253,7 +1253,7 @@ public class Scene { sceneNpcBornEntries.add(i); }); - if (sceneNpcBornEntries.size() > 0) { + if (!sceneNpcBornEntries.isEmpty()) { this.broadcastPacket(new PacketGroupSuiteNotify(sceneNpcBornEntries)); Grasscutter.getLogger().trace("Loaded Npc Group Suite {}", sceneNpcBornEntries); } diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index f0ca384de..115a57c80 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -296,7 +296,7 @@ public class World implements Iterable { scene.removePlayer(player); // Info packet for other players - if (this.getPlayers().size() > 0) { + if (!this.getPlayers().isEmpty()) { this.updatePlayerInfos(player); } diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 2a9776a1d..ca5113167 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -678,7 +678,7 @@ public class SceneScriptManager { } public void checkRegions() { - if (this.regions.size() == 0) { + if (this.regions.isEmpty()) { return; } diff --git a/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java b/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java index cc7c44556..c3839f2e7 100644 --- a/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java +++ b/src/main/java/emu/grasscutter/scripts/serializer/LuaSerializer.java @@ -239,7 +239,7 @@ public class LuaSerializer implements Serializer { } public String getSetterName(String fieldName) { - if (fieldName == null || fieldName.length() == 0) { + if (fieldName == null || fieldName.isEmpty()) { return null; } if (fieldName.length() == 1) { diff --git a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java index 37e30a6a3..94d1ba60e 100644 --- a/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java +++ b/src/main/java/emu/grasscutter/server/http/dispatch/RegionHandler.java @@ -53,12 +53,12 @@ public final class RegionHandler implements Router { var usedNames = new ArrayList(); // List to check for potential naming conflicts. var configuredRegions = new ArrayList<>(DISPATCH_INFO.regions); - if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.size() == 0) { + if (Grasscutter.getRunMode() != ServerRunMode.HYBRID && configuredRegions.isEmpty()) { Grasscutter.getLogger() .error( "[Dispatch] There are no game servers available. Exiting due to unplayable state."); System.exit(1); - } else if (configuredRegions.size() == 0) + } else if (configuredRegions.isEmpty()) configuredRegions.add( new Region( "os_usa", diff --git a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java index e4de100e0..5b1f406a4 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -26,7 +26,7 @@ public final class HandbookHandler implements Router { */ public HandbookHandler() { this.handbook = new String(FileUtils.readResource("/html/handbook.html")); - this.serve = HANDBOOK.enable && this.handbook.length() > 0; + this.serve = HANDBOOK.enable && !this.handbook.isEmpty(); var server = HANDBOOK.server; if (this.serve && server.enforced) { diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java index 626f8f097..7b794f220 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilitiesInitFinishCombineNotify.java @@ -26,7 +26,7 @@ public class HandlerClientAbilitiesInitFinishCombineNotify extends PacketHandler player.getClientAbilityInitFinishHandler().addEntry(ability.getForwardType(), ability); } - if (entry.getInvokesList().size() > 0) { + if (!entry.getInvokesList().isEmpty()) { session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer()); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java index a9cb1ccdb..f8c80383b 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java @@ -23,7 +23,7 @@ public class HandlerClientAbilityInitFinishNotify extends PacketHandler { player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry); } - if (notif.getInvokesList().size() > 0) { + if (!notif.getInvokesList().isEmpty()) { session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer()); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java index 3bfd7bd17..6b4efa4be 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerQueryPathReq.java @@ -13,7 +13,7 @@ public class HandlerQueryPathReq extends PacketHandler { var req = QueryPathReq.parseFrom(payload); /** It is not the actual work */ - if (req.getDestinationPosList().size() > 0) { + if (!req.getDestinationPosList().isEmpty()) { session.send(new PacketQueryPathRsp(req)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java index 2ceb23653..107cce89a 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerNameReq.java @@ -13,7 +13,7 @@ public class HandlerSetPlayerNameReq extends PacketHandler { // Auto template SetPlayerNameReq req = SetPlayerNameReq.parseFrom(payload); - if (req.getNickName() != null && req.getNickName().length() > 0) { + if (req.getNickName() != null && !req.getNickName().isEmpty()) { session.getPlayer().setNickname(req.getNickName()); session.send(new PacketSetPlayerNameRsp(session.getPlayer())); } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java index 335d63b99..868dd81f7 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerSignatureReq.java @@ -13,7 +13,7 @@ public class HandlerSetPlayerSignatureReq extends PacketHandler { // Auto template SetPlayerSignatureReq req = SetPlayerSignatureReq.parseFrom(payload); - if (req.getSignature() != null && req.getSignature().length() > 0) { + if (req.getSignature() != null && !req.getSignature().isEmpty()) { session.getPlayer().setSignature(req.getSignature()); session.send(new PacketSetPlayerSignatureRsp(session.getPlayer())); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java index 8d1b9a3b1..255c9ff03 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java @@ -12,7 +12,7 @@ public class PacketClientAbilityInitFinishNotify extends BasePacket { int entityId = 0; - if (entries.size() > 0) { + if (!entries.isEmpty()) { AbilityInvokeEntry entry = entries.get(0); entityId = entry.getEntityId(); } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java index 2c6fc2009..cda3a8048 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetAllMailResultNotify.java @@ -23,7 +23,7 @@ public final class PacketGetAllMailResultNotify extends BasePacket { .setPacketNum(1); var inbox = player.getAllMail(); - if (!gifts && inbox.size() > 0) { + if (!gifts && !inbox.isEmpty()) { packet.addAllMailList( inbox.stream() .filter(mail -> mail.stateValue == 1) diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java index ab691f46b..c0ad15beb 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java @@ -15,7 +15,7 @@ public class PacketGetOnlinePlayerListRsp extends BasePacket { GetOnlinePlayerListRsp.Builder proto = GetOnlinePlayerListRsp.newBuilder(); - if (players.size() != 0) { + if (!players.isEmpty()) { for (Player player : players) { if (player.getUid() == session.getUid()) continue; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java b/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java index 609376fb1..8d0c1c57b 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketGetScenePointRsp.java @@ -12,7 +12,7 @@ public class PacketGetScenePointRsp extends BasePacket { GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder().setSceneId(sceneId); - if (GameData.getScenePointIdList().size() == 0) { + if (GameData.getScenePointIdList().isEmpty()) { for (int i = 1; i < 1000; i++) { p.addUnlockedPointList(i); p.addUnhidePointList(i); diff --git a/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java b/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java index 4474cc5cb..6fd7f2f61 100644 --- a/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java +++ b/src/main/java/emu/grasscutter/server/scheduler/ServerTaskScheduler.java @@ -23,7 +23,7 @@ public final class ServerTaskScheduler { */ public void runTasks() { // Skip if there are no tasks. - if (this.tasks.size() == 0) return; + if (this.tasks.isEmpty()) return; // Run all tasks. for (ServerTask task : this.tasks.values()) { diff --git a/src/main/java/emu/grasscutter/tools/Dumpers.java b/src/main/java/emu/grasscutter/tools/Dumpers.java index d3e7b35e5..47c0e663b 100644 --- a/src/main/java/emu/grasscutter/tools/Dumpers.java +++ b/src/main/java/emu/grasscutter/tools/Dumpers.java @@ -169,7 +169,7 @@ public interface Dumpers { Language.getTextMapKey(item.getNameTextMapHash()).get(locale), Quality.from(item.getRankLevel()), item.getItemType(), - item.getIcon().length() > 0 ? item.getIcon().substring(3) : ""))); + !item.getIcon().isEmpty() ? item.getIcon().substring(3) : ""))); // Create a new dump with filtered duplicates. var names = new ArrayList();