Hi everyone, I'm trying to write a plugin that executes code when the base command /f is run by a player but only when it has 0 arguments (e.g /f who should still pass through to FactionsUUID). Right now I'm using the following (with PlayerCommandPreprocessEvent: public void onPreCommand(PlayerCommandPreprocessEvent event) { if (event.getMessage().split("\\s+")[0].equalsIgnoreCase("/f") || event.getMessage().split("\\s+")[0].equalsIgnoreCase("/factions")) { Currently, this calls it whenever /f or /factions is run, but it also calls it when there are arguments. What can I do to prevent it from executing whenever there is more than 0 arguments?
Can't you just check whether the command is exactly "/f" or "/factions"? (Also, splitting is expensive, rather use substring with indexOf)
If you're splitting it anyways assign the split to a variable. If the split message 's length is > 1 it has arguments Sent from my iPhone using Tapatalk