Solved Internal Error Message?

Discussion in 'Plugin Development' started by BJCxMC, Jun 27, 2014.

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

    BJCxMC

    Hello, I am working on a customized rewrite of essentials with commands and functions that I'd like to see with it. My problem is with my help menu. Usually when you type /help you get all the commands available to you but I kind of wanted a menu format to it so I made a command /help. When I use my /help command all my text shows up, but, I get an error saying, "An internal error occurred while attempting to perform this command" I know this is because its trying to override a default bukkit / minecraft command but I want to get rid of this message. I will include the code and the error log. Any help is greatly appreciated! Thanks in advance!
    Code:
    Code:java
    1. package com.MrBJC412.Basic;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.Player;
    8.  
    9. public class Help implements CommandExecutor {
    10. Main plugin;
    11.  
    12. public Help(Main passedPlugin)
    13. {
    14. this.plugin = passedPlugin;
    15. }
    16.  
    17. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String [] args ) {
    18. Player p = (Player) sender;
    19. if(cmd.getName().equalsIgnoreCase("help")) {
    20. p.sendMessage(" " + ChatColor.RED + "Help Pages" + ChatColor.WHITE + " ");
    21. p.sendMessage(ChatColor.RED + "Invalid usage. Please use " + ChatColor.GREEN + "/help <page>");
    22. p.sendMessage(ChatColor.RED + "Pages:");
    23. p.sendMessage(ChatColor.GREEN + "Beginner");
    24. p.sendMessage(ChatColor.GREEN + "Mod");
    25. p.sendMessage(ChatColor.GREEN + "Admin");
    26. p.sendMessage(ChatColor.GREEN + "Owner");
    27. }
    28. if(args[0].equalsIgnoreCase("beginner")) {
    29. p.sendMessage(ChatColor.RED + "You have chosen the " + ChatColor.GREEN + "Beginner" + ChatColor.RED + " help page.");
    30. p.sendMessage(ChatColor.GRAY + "For starters, welcome to the Internal Network! The Internal Network is a network of various servers and an amazing community. You are currently connected to the teams/hardcore section of our network. The server is all about making teams and having epic fights to the death, choose your teammates wisely, they can turn on friendly fire at any point in time and turn their back on you!");
    31. p.sendMessage(ChatColor.RED + "Your Commands:");
    32. p.sendMessage(ChatColor.GREEN + "/report" + ChatColor.WHITE + "- Report a bug/hacker. Inappropriate use will result in a " + ChatColor.RED + "" + ChatColor.BOLD + "" + "BAN!");
    33. p.sendMessage(ChatColor.GREEN + "/track" + ChatColor.WHITE + "- Find where players are.");
    34. p.sendMessage(ChatColor.GREEN + "Enjoy your stay!");
    35. }
    36. if(args[0].equalsIgnoreCase("mod")) {
    37. if(p.hasPermission("Basic.help.mod")) {
    38. p.sendMessage(ChatColor.RED + "You have chosen the " + ChatColor.GREEN + "Mod" + ChatColor.RED + " help page.");
    39. p.sendMessage(ChatColor.GREEN + "/kick {k}" + ChatColor.WHITE + " - Kick a player.");
    40. p.sendMessage(ChatColor.GREEN + "/ban {b}" + ChatColor.WHITE + " - Ban a player.");
    41. p.sendMessage(ChatColor.GREEN + "/warn {w}" + ChatColor.WHITE + " - Warn a player.");
    42. p.sendMessage(ChatColor.GREEN + "/mute {m}" + ChatColor.WHITE + " - Mute a player.");
    43. p.sendMessage(ChatColor.GREEN + "/adminchat {ac}" + ChatColor.WHITE + " - Speak in Admin-Chat.");
    44. p.sendMessage(ChatColor.GREEN + "/clearchat {cc}" + ChatColor.WHITE + " - Clear the server's chat.");
    45. p.sendMessage(ChatColor.GREEN + "/fly" + ChatColor.WHITE + " - Toggle flying.");
    46. p.sendMessage(ChatColor.GREEN + "/vanish {v}" + ChatColor.WHITE + " - Toggle being vanished.");
    47. } else {
    48. p.sendMessage(ChatColor.RED + "You don't have permission to view the " + ChatColor.GREEN + "Mod" + ChatColor.RED + " help page.");
    49. }
    50. }
    51. if(args[0].equalsIgnoreCase("admin")) {
    52. if(p.hasPermission("Basic.help.admin")) {
    53. p.sendMessage(ChatColor.RED + "You have chosen the " + ChatColor.GREEN + "Admin" + ChatColor.RED + " help page.");
    54. p.sendMessage(ChatColor.GREEN + "/creative {gms}" + ChatColor.WHITE + " - Change to creative mode.");
    55. p.sendMessage(ChatColor.GREEN + "/survival {gms}" + ChatColor.WHITE + " - Change to survival mode.");
    56. p.sendMessage(ChatColor.GREEN + "/feed" + ChatColor.WHITE + " - Fill your hunger.");
    57. p.sendMessage(ChatColor.GREEN + "/heal" + ChatColor.WHITE + " - Fill your health.");
    58. p.sendMessage(ChatColor.GREEN + "/done" + ChatColor.WHITE + " - Remove your potion effects.");
    59. p.sendMessage(ChatColor.GREEN + "/potions" + ChatColor.WHITE + " - Cheat on some potions ;)");
    60. p.sendMessage(ChatColor.GREEN + "/rx" + ChatColor.WHITE + " - Check players for Xray.");
    61. p.sendMessage(ChatColor.GREEN + "/co inspect" + ChatColor.WHITE + " - Check for Xray.");
    62. } else {
    63. p.sendMessage(ChatColor.RED + "You don't have permission to view the " + ChatColor.GREEN + "Admin" + ChatColor.RED + " help page.");
    64. }
    65. }
    66. if(args[0].equalsIgnoreCase("Owner")) {
    67. if(p.hasPermission("Basic.help.owner")) {
    68. p.sendMessage(ChatColor.GREEN + "add stuff later.");
    69. }
    70. }
    71. return false;
    72. }
    73. }


    Error Log:
    [00:19:54 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'help
    ' in plugin Basic v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:19
    6) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:542) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:932) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    .java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    at com.MrBJC412.Basic.Help.onCommand(Help.java:28) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2979jnks]
    ... 13 more
     
  2. Offline

    Seadragon91

    You have an array index out ouf range exception.The problem is the if statements after the command are not inside of the command bloc, they are outside and then java tries to check if the args[0] equals beginner, mod, ... .But there is no argument and this will cause an error.
     
  3. Offline

    BJCxMC

    Hmm, command block? Could you show like an example, it's a stupid thing to ask but I'm just not understanding whats wrong with the if statements, all the commands are working fine, but yeah please post an example of what you're saying so I can actually understand haha
     
  4. Offline

    Seadragon91

    command {
    }

    arguments {
    }

    That is what you have...
    The arguments should be inside of the command block

    command {
    arguments {
    }
    }

    Edit:
    Change
    Code:
     if(cmd.getName().equalsIgnoreCase("help")) {
    to
    Code:
    if(cmd.getName().equalsIgnoreCase("help") && args.length == 0) {
    Add add a return true at the end of every block.
     
  5. Offline

    BJCxMC

    Okay, I will try this tomorrow seeing as that it is 1:23 a.m. for me ATM, I will tag you in a reply tomorrow to let you know how it goes, but once again, thanks in advance! :p

    Seadragon91 You sir are a genius thanks for the help!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page