Solved Error with kill oneself command

Discussion in 'Plugin Development' started by AguilaAudaz, Sep 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    AguilaAudaz

    Hello i got an error with my code, when people do /spy they dont die, they get a red message saying an error on the console

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("spy")){
    3. Player target = sender.getServer().getPlayer(args[0]);
    4. target.setHealth(0);
    5. }
    6. return false;


    I dont know what to do please help
     
  2. Offline

    chasechocolate

    Make target = (Player) sender. Also, you will need to do an instanceof check if you want to remove a ClassCastException if the console runs it.
     
  3. Offline

    AguilaAudaz

    Thanks! It works! really thanks for helping me, im new with this :)
     
Thread Status:
Not open for further replies.

Share This Page