Solved mcMMO skill level

Discussion in 'Plugin Development' started by MrFrozen, Jun 17, 2015.

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

    MrFrozen

    Hey Bukkit,

    I looked up the mcMMO and found in the ExpierenceAPI a way to get the level but I wont work. Can someone help me out?
    Code:
    int lvl = ExperienceAPI.getPlayerRankSkill(p.getUniqueId(), "mining");
    p.sendMessage("Mining Level: " + lvl);
    This is the error I get:
    Code:
    17:11:02] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'dev' in plugin eTeam v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[server.jar:git-Spigot-2f787bd-ea28011]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[server.jar:git-Spigot-2f787bd-ea28011]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1133) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:968) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-2f787bd-ea28011]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_45]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_45]
        at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:710) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [server.jar:git-Spigot-2f787bd-ea28011]
        at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [server.jar:git-Spigot-2f787bd-ea28011]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]
    Caused by: java.lang.NullPointerException
        at com.gmail.nossr50.api.ExperienceAPI.getPlayerRankSkill(ExperienceAPI.java:806) ~[?:?]
        at pw.eteam.server.commands.dev.onCommand(dev.java:26) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-2f787bd-ea28011]
        ... 15 more
    

    And yea I do have depend, plugin in the server etc
     
  2. Offline

    adam753

    NullPointerException is usually pretty straightforward. Most likely p is null. Actually p can't be null because you're getting its UUID before passing it to the method, hmm. Take a look at ExperienceAPI.java (decompile it or see if it's open source) and see what's null on line 806.
     
  3. Offline

    caseif

    Whatever you're passing on line 26 of dev.java (which is a bad name btw, class names should always be capitalized) is most likely null. Debug those objects and figure out why.
     
  4. Offline

    MrFrozen

    it is called dev.java cause the command is /dev either java conf is so far I know is first word lowercase and second word upper. Anyways ill take a look again ty

    Ill check line 806 now but it is not my code
    Code:
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("dev")) {
                if(sender instanceof Player) {
                    Player p = (Player) sender;
                    if(!p.hasPermission("dev.cmd") && p.isOp()) {
                      
                    } else {
                        sender.sendMessage(ChatColor.RED + "I told you, you need some special access");
                        if(args.length == 0) {
                          
                        } else {
                            if(args[0].equalsIgnoreCase("s1")) {
                                int lvl = ExperienceAPI.getPlayerRankSkill(p.getUniqueId(), "mining");
                                p.sendMessage("Mining Level: " + lvl);
                            }
                        }
                    }
                }
                return true;
            }
            return false;
        }
    
    Problem Fixed! I'm using a other method now!

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

    caseif

    Just to clarify on this: camelCase only applies to methods and fields. Class names should always be fully capitalized.
     
Thread Status:
Not open for further replies.

Share This Page