improve flag checking in FilterCommand
This commit is contained in:
parent
e56fc19ab3
commit
e8ef3adf3b
1 changed files with 10 additions and 18 deletions
|
@ -47,21 +47,15 @@ public class FilterCommand extends Command {
|
||||||
|
|
||||||
String action = context.getString(false, true);
|
String action = context.getString(false, true);
|
||||||
|
|
||||||
// this is a mess
|
// run 2 times. for example `*filter -ignorecase -regex add test` will be both accepted
|
||||||
if (action.equals("-ignorecase")) {
|
for (int i = 0; i < 2; i++) {
|
||||||
ignoreCase = true;
|
if (action.equals("-ignorecase")) {
|
||||||
action = context.getString(false, true);
|
ignoreCase = true;
|
||||||
} else if (action.equals("-regex")) {
|
action = context.getString(false, true);
|
||||||
regex = true;
|
} else if (action.equals("-regex")) {
|
||||||
action = context.getString(false, true);
|
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();
|
final Gson gson = new Gson();
|
||||||
|
@ -128,9 +122,7 @@ public class FilterCommand extends Command {
|
||||||
Component.join(JoinConfiguration.newlines(), filtersComponents)
|
Component.join(JoinConfiguration.newlines(), filtersComponents)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
default -> {
|
default -> throw new CommandException(Component.text("Invalid action"));
|
||||||
throw new CommandException(Component.text("Invalid action"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue