Fix logic error in remove command

This commit is contained in:
AnimeGitB 2022-05-15 17:26:54 +09:30 committed by Melledy
parent efd7467a71
commit f5cdedcc88

View File

@ -8,7 +8,6 @@ import emu.grasscutter.server.packet.send.PacketChangeMpTeamAvatarRsp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
import static emu.grasscutter.utils.Language.translate; import static emu.grasscutter.utils.Language.translate;
@ -28,7 +27,9 @@ public class RemoveCommand implements CommandHandler {
for (String arg : args) { for (String arg : args) {
try { try {
int avatarIndex = Integer.parseInt(arg); int avatarIndex = Integer.parseInt(arg);
if (!avatarIndexList.contains(avatarIndex)) {
avatarIndexList.add(avatarIndex); avatarIndexList.add(avatarIndex);
}
} catch (Exception ignored) { } catch (Exception ignored) {
ignored.printStackTrace(); ignored.printStackTrace();
CommandHandler.sendMessage(sender, translate("commands.remove.invalid_index")); 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++) { for (int i = 0; i < avatarIndexList.size(); i++) {
if (avatarIndexList.get(i) > targetPlayer.getTeamManager().getCurrentTeamInfo().getAvatars().size() || avatarIndexList.get(i) <= 0) { if (avatarIndexList.get(i) > targetPlayer.getTeamManager().getCurrentTeamInfo().getAvatars().size() || avatarIndexList.get(i) <= 0) {