Player p = (Player) sender;
if (!(sender instanceof Player)){
sender.sendMessage("Only Players may execute this command");
return true;
}
The cast of sender to Player should happen after the check.
If a command sender is the console or command block, your code will attempt to cast a console sender or command block to a player .... Which wont work and then crash.
The cast of sender to Player should happen after the check.
If a command sender is the console or command block, your code will attempt to cast a console sender or command block to a player .... Which wont work and then crash.