Solved Nullpointer with scoreboard code

Discussion in 'Spigot Plugin Development' started by HockeyFreak062, Jun 20, 2018.

  1. Hey! I'm trying to make a scoreboard for a server where im playing on with my friends but i get a nullpointer exception with the scoreboard. This is the code:
    Code (Java):

        static Scoreboard board;

     
    @EventHandler
        public void onMove(PlayerMoveEvent event) {
            Player p = event.getPlayer();

            ScoreboardManager manager = Bukkit.getScoreboardManager();
            board = manager.getNewScoreboard();

            Objective objective = board.registerNewObjective("Test", "Test2");
            objective.setDisplayName(Main.cc("&b&lFactions Board"));
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);

            Score score1 = objective.getScore(ChatColor.WHITE + "" + ChatColor.STRIKETHROUGH + "-----------------");
            score1.setScore(11);

            Score score34 = objective.getScore(Main.cc("&4&lRED:"));
            score34.setScore(7);

            Score score21 = objective.getScore(ChatColor.RED + Main.cc("&c" + Main.config.getInt("Faction1.Bal")));
            score21.setScore(6);

            Score score341 = objective.getScore(Main.cc("&1&lBLUE:"));
            score341.setScore(5);

            Score score211 = objective.getScore(Main.cc("&c" + Main.config.getInt("Faction2.Bal")));
            score211.setScore(4);

            Score score4 = objective.getScore(Main.cc("&b&lSpawner Level:"));
            score4.setScore(3);

            Score score5 = objective.getScore(Main.cc("&cComing Soon!"));
            score5.setScore(2);

            Score score6 = objective.getScore(Main.cc("&f&lLocatie:"));
            score6.setScore(1);

            if (event.getPlayer().getLocation().getBlock().getBiome().equals(Biome.JUNGLE)) {
                Score score7 = objective.getScore(Main.cc("&1&lBlue"));
                score7.setScore(0);
            } else if (event.getPlayer().getLocation().getBlock().getBiome().equals(Biome.DESERT_HILLS)) {
                Score score7 = objective.getScore(Main.cc("&8&lWarZone"));
                score7.setScore(0);
            } else if (event.getPlayer().getLocation().getBlock().getBiome().equals(Biome.PLAINS)) {
                Score score7 = objective.getScore(Main.cc("&4&lRED"));
                score7.setScore(0);
            } else if (event.getPlayer().getLocation().getBlock().getBiome().equals(Biome.BEACH)) {
                Score score7 = objective.getScore(Main.cc("&e&lSafeZone"));
                score7.setScore(0);
            } else {
                Score score7 = objective.getScore(Main.cc("&e&l TEst"));
                score7.setScore(0);
               
            }
            p.setScoreboard(board);
        }
     
    And here is the Error
    Code (Java):
     20.06 19:16:10 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:10 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:10 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:10 [Server] INFO org.bukkit.event.EventException 20.06 19:16:10 [Server] ERROR Could not pass event PlayerMoveEvent to Fuckers v0.0.01 20.06 19:16:09 [Server] INFO ... 15 more 20.06 19:16:09 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151] 20.06 19:16:09 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151] 20.06 19:16:09 [Server] INFO at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source) ~[?:?] 20.06 19:16:09 [Server] INFO at com.hockey.main.ScoreBoard.Join.onMove(Join.java:94) ~[?:?] 20.06 19:16:09 [Server] INFO Caused by: java.lang.NullPointerException 20.06 19:16:09 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:537) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:629) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:335) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:673) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_151] 20.06 19:16:09 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_151] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInFlying$PacketPlayInPosition.a(SourceFile:57) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInFlying.a(SourceFile:126) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:257) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[craftbukkit8.jar:git-Bukkit-e1ebe52] 20.06 19:16:09 [Server] INFO org.bukkit.event.EventException
    Can someone help me?
     
    #1 HockeyFreak062, Jun 20, 2018
    Last edited: Jun 20, 2018
  2. Optic_Fusion1

    Resource Staff

    the error complains about the PlayerMoveEvent not the join event
     
  3. I changed it now
     
  4. I fixed it i miss typed a string for the config sorry!