Minecraft Java插件 - 重置和设置记分板的麻烦

时间:2018-03-31 21:19:37

标签: java minecraft

我制作了一个插件,在整个开发过程中,我遇到了一些记分牌问题。这次我真的碰到了墙,而我不知道自己将如何解决这个问题。我需要一些帮助。

我可以引导你朝着正确的方向前进。在查看错误消息并稍微更改我的代码之后,我发现问题在于我重置分数的方式(在方法SetScoreBoard()第726行中)。

我的代码: https://pastebin.com/M5kFr2Lr(阅读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);
}

错误:

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

0 个答案:

没有答案