Internal errors after calling a command without args[]

Discussion in 'Plugin Development' started by MrRump, Jun 18, 2011.

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

    MrRump

    Hey guys, another question :)

    I have a small problem. In my plugin, I use 2 commands, "/ibooks" and "/ibooks create". The last one works, but the first one, without any things in args[] doesn't work.

    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player player = (Player)sender;
    
            if (cmd.getName().equalsIgnoreCase("ibooks") && player != null) {
                if(args[0].equalsIgnoreCase("create"))
                {
                    player.sendMessage("Right-click on a bookshelf to create a book.");
                    mode.put(player, 1);
                }
                else if(args[0].isEmpty())
                {
                     player.sendMessage("Welcome to iBooks");
                }
            }
            return true;
        }
        
    Thanks for every help :)
     
  2. Offline

    wwsean08

    I'm pretty sure. That for just regular ibooks you should check if the args are null, so
    Code:
    Else if(args == null){
        Player.sendmessage("welcome to ibooks")
    }
    
    (As for any syntax errors that was sent from my phone so fix them yourself lol :p)
     
Thread Status:
Not open for further replies.

Share This Page