Solved Need help with Array out of Bounds Error

Discussion in 'Plugin Development' started by dakoslug, Mar 14, 2013.

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

    dakoslug

    Error Message:

    Code:
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
        at me.dakoslug.EmergencyDowntime.EmergencyDowntime.onCommand(EmergencyDowntime.java:88)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 8 more
    Code:
    else if(args[0].equalsIgnoreCase("build"))
                {
                  if (sender.hasPermission("emergencydowntime.build"))
                        {
                        if (args.length == 1)  //This is Line 88
                            {
                            if (args[1].equalsIgnoreCase("off"))
                                {
                                downtimebuild = false;
                                this.log.info("[EmergencyDowntime] "+sender.getName()+" has re-enabled building and destroying.");   
                                }   
                            }
                        else if (args.length == 0)
                            {
                            downtimebuild = true;
                            this.log.info("[EmergencyDowntime] "+sender.getName()+" has disabled building and destroying.");
                            sender.sendMessage(ChatColor.GOLD+"You have disabled building and destroying.");
                            }
                        }
                    else
                        {
                        sender.sendMessage(ChatColor.RED + "You do not have permission to use this!");
                        }
    I don't understand what is wrong. I do /ed build and it gives me the error.
     
  2. Offline

    RainoBoy97

    if(args.length == 2)
     
  3. Offline

    GodzOfMadness

    dakoslug args[1] is referring to the 2nd argument example:
    /build args[0] args[1] args[2]
     
  4. Offline

    dakoslug

    What? NOOOO. I can't believe I got confused with the actual call to the array value and the length of it.

    Thanks so much..face palm.
     
    RainoBoy97 likes this.
Thread Status:
Not open for further replies.

Share This Page