1

I made a plugin and throughout development I have had some troubles with scoreboard. This time I really hit a wall whereas I don't know how I'm going to solve this on my own. I need some help.

I can steer you in the right direction though. After looking at the Error message and changing my code a little I figured out that the problem lies in the way that I reset score (in method SetScoreBoard() Line 726).

My code: https://pastebin.com/M5kFr2Lr (Read the pastebin)

public void SetScoreBoard(Player p) {
    scoreboard = boardMap.get(p.getUniqueId());

    scoreboard.resetScores(score15.get(p.getUniqueId()));
    scoreboard.resetScores(score14.get(p.getUniqueId()));
    scoreboard.resetScores(score13.get(p.getUniqueId()));
    scoreboard.resetScores(score12.get(p.getUniqueId()));
    scoreboard.resetScores(score11.get(p.getUniqueId()));
    scoreboard.resetScores(score10.get(p.getUniqueId()));
    scoreboard.resetScores(score9.get(p.getUniqueId()));
    scoreboard.resetScores(score8.get(p.getUniqueId()));
    scoreboard.resetScores(score7.get(p.getUniqueId()));
    scoreboard.resetScores(score6.get(p.getUniqueId()));
    scoreboard.resetScores(score5.get(p.getUniqueId()));
    scoreboard.resetScores(score4.get(p.getUniqueId()));
    scoreboard.resetScores(score3.get(p.getUniqueId()));
    scoreboard.resetScores(score2.get(p.getUniqueId()));
    scoreboard.resetScores(score1.get(p.getUniqueId()));

    boardMap.put(p.getUniqueId(), scoreboard);

    updateScoreBoard(p);
}

The error:

Caused by: java.lang.NullPointerException
    at pillars.EssemCSH.main.Main.SetScoreBoard(Main.java:729) ~[?:?]
    at pillars.EssemCSH.main.Main.onPlayerLeave(Main.java:1046) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_161]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
    ... 12 more
Jacob G.
  • 28,856
  • 5
  • 62
  • 116
EssemCSH
  • 103
  • 1
  • 2
  • 13
  • Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – Jacob G. Mar 31 '18 at 21:22
  • No it isn't. Theres something wrong with the way that I reset my scores. It's what the error tracks back to. I don't know what is wrong though. – EssemCSH Mar 31 '18 at 21:25
  • It is... either `scoreboard` or `score15` is `null`. – Jacob G. Mar 31 '18 at 21:26
  • Yup!!! Sorry to waste your time! I've been blind and the problem was that I reset score15 and all the others before I got to set them... – EssemCSH Mar 31 '18 at 21:40

0 Answers0