Solved Plugin Main Command returns an error

Discussion in 'Plugin Development' started by jonasXDD, Dec 24, 2012.

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

    jonasXDD

    Hallo,
    In my Plugin works all Commands, the main command works, but it returns an error.

    The Code:
    Code:
                if(cmd.getName().equalsIgnoreCase("vip"))
                {
                    if(args.length == 0)
                    {
                        sender.sendMessage(this.plugin.Messages.vip_prefix.replaceAll("&", "§") + this.plugin.Messages.error_wrong_arguments.replaceAll("&", "§"));
                    }
               
               
               
               
               
                        // Reload Command
                        if(args[0].equalsIgnoreCase("reload"))         /*this is Line 42:*/
                        {
                            if(sender.hasPermission("vip.reload"))
                            {
                                if(args.length == 1)
                                {
                                    this.plugin.Config.loadConfig();
                                    this.plugin.Messages.loadMessages();
                                    this.plugin.Speicher.loadSpeicher();
                                    sender.sendMessage(this.plugin.Messages.vip_prefix.replaceAll("&", "§") + this.plugin.Messages.command_reload.replaceAll("&", "§"));
                                }else
                                    {
                                        sender.sendMessage(this.plugin.Messages.vip_prefix.replaceAll("&", "§") + this.plugin.Messages.error_wrong_arguments.replaceAll("&", "§"));
                                    }
                            }else
                                {
                                    sender.sendMessage(this.plugin.Messages.vip_prefix.replaceAll("&", "§") + this.plugin.Messages.error_no_permissions.replaceAll("&", "§"));
                                }
                        }
                   
                        // More commands, example: /vip help
                   
                   
                return true;
                }
    What is wrong?
     
  2. Offline

    Shiny Quagsire

    It would help if you posted the error. Also, work on your formatting, it's a mess. You should have your else's either on a separate line, or before the bracket like this:
    Code:
    else {
    ...
    }
    
    Or, you can do it the way you have. I'm just saying that I've never seen it like that and it's a bit hard to read.
     
  3. Offline

    drtshock

    I would suggest posting the error.
     
  4. Offline

    jonasXDD

    Here is the error:
    Code:
    2012-12-24 18:44:39 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'vip' in plugin VIP v1.4.6a
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:186)
        at org.bukkit.craftbukkit.v1_4_6.CraftServer.dispatchCommand(CraftServer.java:510)
        at net.minecraft.server.v1_4_6.PlayerConnection.handleCommand(PlayerConnection.java:980)
        at net.minecraft.server.v1_4_6.PlayerConnection.chat(PlayerConnection.java:898)
        at net.minecraft.server.v1_4_6.PlayerConnection.a(PlayerConnection.java:853)
        at net.minecraft.server.v1_4_6.Packet3Chat.handle(Packet3Chat.java:44)
        at net.minecraft.server.v1_4_6.NetworkManager.b(NetworkManager.java:290)
        at net.minecraft.server.v1_4_6.PlayerConnection.d(PlayerConnection.java:112)
        at net.minecraft.server.v1_4_6.ServerConnection.b(SourceFile:39)
        at net.minecraft.server.v1_4_6.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_4_6.MinecraftServer.r(MinecraftServer.java:598)
        at net.minecraft.server.v1_4_6.DedicatedServer.r(DedicatedServer.java:224)
        at net.minecraft.server.v1_4_6.MinecraftServer.q(MinecraftServer.java:494)
        at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:427)
        at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        at de.jonasXDD.VIP.Commands.VIP_Command.onCommand(VIP_Command.java:42)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
    Line 42: see above, I have markered the line
     
  5. Offline

    fireblast709

    in the if(args.length == 0) do a return true;
     
    jonasXDD likes this.
  6. Offline

    jonasXDD

    Thanks :D it works
     
Thread Status:
Not open for further replies.

Share This Page