Help with PLUGIN and ERRORS

Discussion in 'Plugin Development' started by waco001, Aug 28, 2012.

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

    waco001

    Hi i Really need help but i dont know what im doing wrong... i made a simple plugin to set someone on fire... and it works for the most part..... for example.... if i wanted to set mysoef on fire.. (as player) i would type /light... but i shows an error... but if i choose to light myself by actually specifing a name (like mine) then it works....
    Heres the code:
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player player = (Player)sender;
            if(cmd.getName().equalsIgnoreCase("light")){
                Player target = player.getServer().getPlayer(args[0]); // Gets the player who was typed in the command.
                // For instance, if the command was "/ignite notch", then the player would be just "notch".
                // Note: The first argument starts with [0], not [1]. So arg[0] will get the player typed.
                if (args.length == 0){
                    player.setFireTicks(10000);
                }
                else
                {
                    target.setFireTicks(10000);
                }
     
                if (args[0] == null){
                    sender.sendMessage(args[0] + " is not online!");
                }
     
     
            }
    }
    ... CAn someone please help me? Thx
     
  2. Offline

    ZeusAllMighty11

    What error?
     
  3. Offline

    sternmin8or

    Player target = player.getServer().getPlayer(args[0]);
    If there is no args[0] then it throws an arrayindexoob error. You need to do a if (args.length>0) check.
     
Thread Status:
Not open for further replies.

Share This Page