package emu.grasscutter.command; import javax.annotation.Nonnull; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CommandHelpers { public static final Pattern lvlRegex = Pattern.compile("(? List parseIntParameters(List args, @Nonnull T params, Map> map) { for (int i = args.size() - 1; i >= 0; i--) { String arg = args.get(i).toLowerCase(); boolean deleteArg = false; int argNum; for (var entry : map.entrySet()) { if ((argNum = matchIntOrNeg(entry.getKey(), arg)) != -1) { entry.getValue().accept(params, argNum); deleteArg = true; break; } } if (deleteArg) { args.remove(i); } } return args; } }