emu.grasscutter.command.CommandHelpers Maven / Gradle / Ivy
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) {
args.removeIf(arg -> {
var argL = arg.toLowerCase();
boolean deleteArg = false;
for (var entry : map.entrySet()) {
int argNum = matchIntOrNeg(entry.getKey(), argL);
if (argNum != -1) {
entry.getValue().accept(params, argNum);
deleteArg = true;
}
}
return deleteArg;
});
return args;
}
}