Weird bug?

Discussion in 'Plugin Development' started by Chrisdamonster, Mar 30, 2014.

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

    Chrisdamonster

    Ok, let me try to explain this. So, today, I was making my plugin, everything was going good, until I got an error in my console and in game. I looked around in my java project, and I couldn't figure out what the problem was. The error in game: "An internal error occurred while attempting to perform this command!" And then the error in console was something no one can decipher :p. But anyways, here is my code:
    Code:
    Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("cc")){
                if(args.length == 0){
                    player.sendMessage("");
                }
                if (args[1].equalsIgnoreCase("all")) {
                if (sender.hasPermission("stopchat.clean")) {
                for (int x = 0; x < 120; x++) {
                Bukkit.broadcastMessage("");
                }
                Bukkit.broadcastMessage(ChatColor.GRAY + "Your chat has been cleared by: " + sender.getName());
                sender.sendMessage(ChatColor.GRAY + "You cleared everybody's chat.");
                System.out.println("chat cleared for everybody.");
                } else {
                sender.sendMessage(ChatColor.WHITE + "Unknown command. Type \"help\" for help.");
                    }
                }
    
     
  2. Offline

    Rocoty

    Chrisdamonster post the so called indecipherable console error. I am inclined to believe you are mistaken in that regard.
     
  3. Offline

    Minnymin3

  4. Offline

    Chrisdamonster

    Rocoty Your wish is my command :p

    [17:25:16 INFO]: MrChrisdamonster issued server command: /cc
    [17:25:16 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'cc' in plugin CC v0.0.1
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:196) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:542) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:932) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    at me.Chris.CC.main.onCommand(main.java:24) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2978jnks]
    ... 13 more
     
  5. Offline

    Rocoty

    I think you should follow the link by Minnymin3
     
    Minnymin3 likes this.
  6. Offline

    Minnymin3

    The issue is that you are checking to see if the argument length is 0 but the code continues afterwards. You should put a return statement in that if bracket. To avoid future easily debuggable questions please read that link that I sent.
     
    Rocoty likes this.
  7. Offline

    Chrisdamonster

    Rocoty The weirdest part about this is that it happened when I made the smallest change ever. When I undid the change, the error still popped up. Oh well, ill just figure out what the gibberish means.
     
  8. Offline

    Fred12i12i

    if you want the command to be /cc all, replace
    if (args[1].equalsIgnoreCase("all")){ with if (args[0].equalsIgnoreCase("all")){

    args[1] check the 2 arg (eg. /cc hey hi, args[0] = hey, args[1] = hi)
     
Thread Status:
Not open for further replies.

Share This Page