hey all, should I do this: Code (Text): if (cmd.getName().equalsIgnoreCase("happyhour")) { if (sender.hasPermission("hi.there")) { if (args.length == 0) { OR Code (Text): if (cmd.getName().equalsIgnoreCase("happyhour")) { if (args.length == 0) { if (sender.hasPermission("hi.there")) { { OR Code (Text): if (sender.hasPermission("hi.there")) { if (args[0].equalsIgnoreCase("start")) { and What do I do for else statements here? Code (Text): if (args[0].equalsIgnoreCase("start") && sender.hasPermission("happyhour.start")) {
Uh well.. What do you mean? EDIT: This is usually how I check my permissions. PHP: if(cmd.getName().equalsIgnoreCase("access")) { if(!sender.hasPermission("access.use")) { sender.sendMessage("No permissions."); }else { //Do allowed functions. //Check arguments. } }
Checking form permission(s), with commands and arguments really depends on how many commands you're having. I normally check the argument value, then permission.
@IPv420 generally, do the fastest check first, unless you can't (ex. you generally want to group code for a single command together - even though you could just use a separate executor). Checking array length is faster than checking permissions, thus check array length first.