Solved Command Help

Discussion in 'Plugin Development' started by badboysteee98, Feb 28, 2014.

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

    badboysteee98

    So I've made an RankUp plugin and every time I do the command I get In-Game Error
    'An internal error occurred while attempting to perform this command'

    and then Console error
    Code:
    [19:54:53 INFO]: badboysteee98 issued server command: /rankup
    [19:54:53 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'rank
    up' in plugin Ranks v1.0
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:17
    5) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServe
    r.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat
    .java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NullPointerException
            at com.ste.Ranks.Utils.RankingHandler.onRankUp(RankingHandler.java:63) ~
    [?:?]
            at com.ste.Ranks.Listeners.Commands.onCommand(Commands.java:31) ~[?:?]
            at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[cra
    ftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 13 more
    Any help I'm very Thankful
     
  2. Offline

    Chinwe

    Look at this post to find what's causing it, we can't do anything without seeing any code (particularly line 63 in RankingHander c:)
     
    badboysteee98 and Jhtzb like this.
  3. Offline

    badboysteee98

    Okay I'll get the code sorry

    Line 63 Of RankingHandler
    Code:java
    1. Set<String> Rankedup = this.plugin.config.configYaml.getConfigurationSection("RankedUp").getKeys(false);


    Line 74 Of RankingHandler (The Other Error)
    Code:java
    1. Set<String> RanksList = this.plugin.config.configYaml.getConfigurationSection("RanksList").getKeys(false);


    Whats 63 Is Inside Of
    Code:java
    1. @SuppressWarnings("unused")
    2. public void onRankUp(CommandSender sender, String[] args) throws NullPointerException {
    3. Player player = (Player)sender;
    4. Set<String> Ranks = this.plugin.config.configYaml.getConfigurationSection("Ranks").getKeys(false);
    5. String rank = this.plugin.config.usersYaml.getString("users." + player.getName());String newRank = "";
    6. for (String classes : Ranks) {
    7. if (classes.equals(Ranks)) {
    8. newRank = "1";
    9. } else if (newRank.equals("1")) {
    10. newRank = classes;
    11. break;
    12. }
    13. }
    14. if (newRank == "1") {
    15. Set<String> HighestRank = this.plugin.config.configYaml.getConfigurationSection("HighestRank").getKeys(false);
    16. player.sendRawMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.config.configYaml.getString("HighestRank")));
    17. return;
    18. }
    19. if ((!this.plugin.economy.isEnabled()) || (this.plugin.economy == null)) {
    20. player.sendRawMessage(ChatColor.RED + "No Economy Plugin is wroking? Make sure it supports Vault! This could be an Error");
    21. return;
    22. }
    23. int price = this.plugin.config.configYaml.getInt("Ranks." + newRank + ".Price");
    24. if (!this.plugin.economy.has(player.getName(), price)) {
    25. Set<String> NotEnoughMoney = this.plugin.config.configYaml.getConfigurationSection("NotEnoughMoney").getKeys(false);
    26. player.sendRawMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.config.configYaml.getString("NotEnoughMoney")));
    27. return;
    28. }
    29. Set<String> Rankedup = this.plugin.config.configYaml.getConfigurationSection("RankedUp").getKeys(false);
    30. player.sendRawMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.config.configYaml.getString("RankedUp")));
    31. this.plugin.economy.withdrawPlayer(player.getName(), price);
    32. this.plugin.config.setGroup(player.getName(), newRank);
    33. updateChat(player, newRank);
    34. updateGroup(player, rank, newRank);
    35. }


    Whats 74 Is Inside Of
    Code:java
    1. @SuppressWarnings("unused")
    2. public void onRanksList(CommandSender sender, String[] args) {
    3. Player player = (Player) sender;
    4. Set<String> RanksList = this.plugin.config.configYaml.getConfigurationSection("RanksList").getKeys(false);
    5. player.sendRawMessage(ChatColor.translateAlternateColorCodes('&', this.plugin.config.configYaml.getString("RanksList")));
    6. }


    @Chinwe

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Chinwe

    You should do some debugging by printing out the value of each variable to the console to see which, if any, is null.
    That could be plugin, plugin.config, plugin.config.configYaml, or sections named "RankedUp" ou "RanksList" don't exist in the config file - you should check the file/configuration section exists before using .getKeys(false)
     
    badboysteee98 likes this.
  5. Offline

    badboysteee98


    Okay Thank You :)


    Don't Worry I Changed Set<String> To List<String> and it worked but thank you for your help :)

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

Share This Page