Hello! I keep getting this error in the console ik its a NPE But i dont know why Error: http://imgur.com/a/1aHD2 Code: https://paste.md-5.net/lolivumeje.avrasm Thanks in advace!
Thanks But How do i debug? I did /debug left and came back and stopped it and got this ---- Minecraft Profiler Results ---- // *cracks redstone whip* Time span: 30964 ms Tick span: 619 ticks // This is approximately 19.99 ticks per second. It should be 20 ticks per second --- BEGIN PROFILE DUMP --- --- END PROFILE DUMP ---
is this even how you read from the Config a UUID? Code (Text): if(nick.equals(p.getUniqueId().toString())){ p.setDisplayName("§b§lBEAST " + nick); }
BTW This is my config if i do /Nick <Nickname> Ingame This is what i get in my config Code (Text): 1293f9f3-5908-4534-897b-2881158e6831: Test 4651a4de-09bd-4644-9804-36b6a1489e91: TestA
debugging means you output values for you to see and check their actual contents. ex: Code (Java): int x = plugin.getConfig().getInt("example.path"); //hm my code doesn't seem to be running, let me see the output of x! System.out.println(x); //output: '2' //That's why its not running! if (x == 3) { Bukkit.shutdown(); }
You're looking for "Admin" in the config. Do you have a name assigned to the field "Admin" in your config. If not, that would be your null, because p.getName() contains a value. Also, I honestly have no clue how you would run the debugger on a Spigot server. It's not like Tomcat, where you can run an instance right from Eclipse. :/
Thank you both! I never though of Debugging from Eclipse, I instantly though to go to My Minecraft server and do /debug lol But @VirusBrandon thank makes sense! Admin is not assigned to the config until i do the command /name admin <1010bob> along with the other args[0]'s So do you have an idea how i can fix that? Thank you!
What's your question? maybe a small description instead of posting a small sentence in the post above would be better
I would first change the NameA, NameB, NameC to a Map<String, Runnable> Code (Text): HashMap<String, Runnable> ranks = new HashMap<>(); ranks.put("Admin", new Command() { public void setName(Player p) { p.setDisplayName("§e§lADMIN§4§l " + p.getName()+ "§c") }; }); Then I would read the config with this and check if it's in Code (Text): String rank = plugin.getConfig().getString(p.getUniqueId().toString()); Player p = event.getPlayer(); if (ranks.containsKey(rank)) { ranks.get(rank).setName(p); } EDIT: The reason for your error is because you are asking Owner like Code (Text): owner: 'Name here' And since that doesn't exist in the config it can't check if it equals something since it's null.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scheduler/BukkitTask.html its a task.. what the person added is a runnable
OP, do you know Java properly enough to make plugins? You don't seem like you know what you're doing. If you can't find a method use the javadocs.
Since you assign information to your config at certain times. I would simply suggest adding function that takes as a parameter, the path in the config that you wish to access and then perform a null check within the function, then return the value if it exists, or some other non-null value when the item you request from config does not exist.