Hello, when running a command with the dependency of the player being op: Code: }else if(event.getMessage().toLowerCase().contains("helper") && event.getMessage().toLowerCase().contains("me") && event.getMessage().toLowerCase().contains("creative") && Bukkit.getPlayer(Bukkit.getConsoleSender().getName()).isOp()){ I get an error in the console: http://prntscr.com/19u4pg I am unsure both what the error means and how to fix it, though I have tried multiple things, it seems it simply wont work. Any assistance is much appreciated.
mitchb The player you are getting returns null. Also, it's better to define the message as a variable instead of getting it multiple times.
mitchb The problem is not the way you are getting it, but the string you are trying to get a player with is either not online or is invalid. Thus, returning null, thus giving you an NPE.
The code you're running isn't getting the player anyway. It would always return a static result, if it worked. Just check the CommandSender variable you define in the parameters of your method and check .isOp() slayr288 "the string you are trying to get the player with" is not a player's name. He's using the ConsoleCommandSender every time to check if it's op.
Literally Code: public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){ if(sender.isOp()){ return true; } return false; }
Gravity Though as you can see it isn't a command, this code will still work? Sorry, first time using Chat events.