improve flag checking in FilterCommand

This commit is contained in:
Chayapak 2024-10-22 15:15:35 +07:00
parent e56fc19ab3
commit e8ef3adf3b

View file

@ -47,7 +47,8 @@ public class FilterCommand extends Command {
String action = context.getString(false, true);
// this is a mess
// run 2 times. for example `*filter -ignorecase -regex add test` will be both accepted
for (int i = 0; i < 2; i++) {
if (action.equals("-ignorecase")) {
ignoreCase = true;
action = context.getString(false, true);
@ -55,13 +56,6 @@ public class FilterCommand extends Command {
regex = true;
action = context.getString(false, true);
}
if (action.equals("-ignorecase")) {
ignoreCase = true;
action = context.getString(false, true);
} else if (action.equals("-regex")) {
regex = true;
action = context.getString(false, true);
}
final Gson gson = new Gson();
@ -128,9 +122,7 @@ public class FilterCommand extends Command {
Component.join(JoinConfiguration.newlines(), filtersComponents)
);
}
default -> {
throw new CommandException(Component.text("Invalid action"));
}
default -> throw new CommandException(Component.text("Invalid action"));
}
}
}