Solved Internal Error help

Discussion in 'Plugin Development' started by DutchChris, Aug 13, 2020.

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


    So I was trying to get back into coding, but ran into an issue. Upon running the givecash command in my localhost server with an argument behind it, it gives me an internal error. Just /givecash works fine and returns the message, but as soon as I add an argument it turns into an error. Would like to know why adding an argument such as 1 or 2 causes an error. Thanks!

        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (cmd.getName().equalsIgnoreCase("balance")) {
                sender.sendMessage("Your balance is " + balance);
                return true;
            } else if(cmd.getName().equalsIgnoreCase("store")) {
                balance += cash;
                sender.sendMessage("You stored " + cash + "! Your new balance is " + balance);
                cash = 0;
            } else if(cmd.getName().equalsIgnoreCase("givecash")) {
                if(args.length < 1) {
                    sender.sendMessage("Please enter a valid amount of cash");
                else if(isInt(args[1])) {
                         int money = Integer.parseInt(args[1]);
                         sender.sendMessage("You received " + money + " money");
                         balance += money;
            return false;

    [18:15:07 INFO]: DutchChris_ issued server command: /givecash 1
    [18:15:07 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'givecash' in plugin fuckinghell v1.12.2
    at org.bukkit.command.PluginCommand.execute( ~[craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at org.bukkit.command.SimpleCommandMap.dispatch( ~[craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand( ~[craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand( [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a( [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(SourceFile:37) [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(SourceFile:9) [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$ [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at java.util.concurrent.Executors$ Source) [?:1.8.0_241]
    at Source) [?:1.8.0_241]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D( [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D( [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C( [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at [craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    at Source) [?:1.8.0_241]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at fuckinghell.Main.onCommand( ~[?:?]
    at org.bukkit.command.PluginCommand.execute( ~[craftbukkit-1.12.2.jar:git-Bukkit-e60fc34]
    ... 15 more
  2. Offline

    timtower Moderator Moderator

    @DutchChris Java starts counting at 0, not at 1 like you are doing.
  3. Offline


    Ah that solved it. Thanks for the help!
Thread Status:
Not open for further replies.

Share This Page