diff --git a/src/main/java/emu/grasscutter/command/CommandHelpers.java b/src/main/java/emu/grasscutter/command/CommandHelpers.java index ff1ea386f..b5cf92972 100644 --- a/src/main/java/emu/grasscutter/command/CommandHelpers.java +++ b/src/main/java/emu/grasscutter/command/CommandHelpers.java @@ -33,21 +33,18 @@ public class CommandHelpers { } public static List parseIntParameters(List args, @Nonnull T params, Map> map) { - for (int i = args.size() - 1; i >= 0; i--) { - String arg = args.get(i).toLowerCase(); + args.removeIf(arg -> { + var argL = arg.toLowerCase(); boolean deleteArg = false; - int argNum; for (var entry : map.entrySet()) { - if ((argNum = matchIntOrNeg(entry.getKey(), arg)) != -1) { + int argNum = matchIntOrNeg(entry.getKey(), argL); + if (argNum != -1) { entry.getValue().accept(params, argNum); deleteArg = true; - break; } } - if (deleteArg) { - args.remove(i); - } - } + return deleteArg; + }); return args; } }