From f5cdedcc88d906d45c8d19c4209c3f565c7d230a Mon Sep 17 00:00:00 2001 From: AnimeGitB Date: Sun, 15 May 2022 17:26:54 +0930 Subject: [PATCH] Fix logic error in remove command --- .../emu/grasscutter/command/commands/RemoveCommand.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/RemoveCommand.java b/src/main/java/emu/grasscutter/command/commands/RemoveCommand.java index c30bad4b3..f39b6da24 100644 --- a/src/main/java/emu/grasscutter/command/commands/RemoveCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/RemoveCommand.java @@ -8,7 +8,6 @@ import emu.grasscutter.server.packet.send.PacketChangeMpTeamAvatarRsp; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.List; import static emu.grasscutter.utils.Language.translate; @@ -28,7 +27,9 @@ public class RemoveCommand implements CommandHandler { for (String arg : args) { try { int avatarIndex = Integer.parseInt(arg); - avatarIndexList.add(avatarIndex); + if (!avatarIndexList.contains(avatarIndex)) { + avatarIndexList.add(avatarIndex); + } } catch (Exception ignored) { ignored.printStackTrace(); CommandHandler.sendMessage(sender, translate("commands.remove.invalid_index")); @@ -36,7 +37,7 @@ public class RemoveCommand implements CommandHandler { } } - Collections.reverse(avatarIndexList); + Collections.sort(avatarIndexList, Collections.reverseOrder()); for (int i = 0; i < avatarIndexList.size(); i++) { if (avatarIndexList.get(i) > targetPlayer.getTeamManager().getCurrentTeamInfo().getAvatars().size() || avatarIndexList.get(i) <= 0) {