Trespo / WitherPoop

haha wither go poooooop
0 stars 0 forks source link

Moses pointers 1 - cast exception #1

Closed mosemister closed 3 years ago

mosemister commented 3 years ago

        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.