Solved Command not executing

Discussion in 'Plugin Help/Development/Requests' started by xxPatterson, Apr 12, 2015.

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


    This is the stacktrace I got:

    [13:16:00 INFO]: MrBurnham issued server command: /claimthrone
    [13:16:00 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'clai
    mthrone' in plugin UHCPVP v1.0
            at org.bukkit.command.PluginCommand.execute( ~[min
            at org.bukkit.command.SimpleCommandMap.dispatch(
    0) ~[minecraft_server.jar:git-Bukkit-262c777]
            at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServe ~[minecraft_server.jar:git-Bukkit-262c777]
            at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerCon [minecraft_server.jar:git-Bukkit-262c777]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a(
    :919) [minecraft_server.jar:git-Bukkit-262c777]
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(SourceFile:37) [minec
            at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(SourceFile:9) [minecr
            at [min
            at java.util.concurrent.Executors$ Source) [
            at Source) [?:1.8.0_31]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z(
    43) [minecraft_server.jar:git-Bukkit-262c777]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z(
    84) [minecraft_server.jar:git-Bukkit-262c777]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y(
    98) [minecraft_server.jar:git-Bukkit-262c777]
    :506) [minecraft_server.jar:git-Bukkit-262c777]
            at Source) [?:1.8.0_31]
    Caused by: java.lang.NullPointerException
            at me.patterson.uhc.Events.King.ClaimThrone.onCommand(
    7) ~[?:?]
            at org.bukkit.command.PluginCommand.execute( ~[min
            ... 14 more

    And this is the code, any idea whats wrong? I put the command in the plugin.yml and implemented it into main class:
    public class ClaimThrone
    implements CommandExecutor
          private Main plugin;
          public ClaimThrone()
            this.plugin = plugin;
    public boolean onCommand(CommandSender sender, Command command, String cmd, String[] args)
          if (cmd.equalsIgnoreCase("claimthrone")) {
              Player p = (Player)sender;
                  plugin.getConfig().set("King", p.getUniqueId());
                  plugin.getConfig().set("KingName", p.getDisplayName());
                  p.sendMessage("§e§lCongratulations, you have been crowned king of the land!");
                  Bukkit.broadcastMessage("§e§lWe have a new King, all hail " + plugin.getConfig().getString("KingName") + "!");
        return true;
  2. @xxPatterson Check sender before casting. Use ChatColor not end code. Also do you have a config.yml in your plugin folder?
  3. Offline


    I have checked for sender before casting, and I do not have the config.yml in my plugin folder, I have it in my eclipse project but it won't load up into the plugin folder but it still isn't working@bwfcwalshy
  4. Offline


    At line 12 you need to have 'cmd.getName().equalsIgnoreCase("claimthrone")'
  5. @xxPatterson from that code I see no checks, you need to load the config so in onEnable add #saveDefaultConfig. Also
Thread Status:
Not open for further replies.

Share This Page