Solved Scoreboard score 9 keeps dissapearing

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

  1. Hey Im making a scoreboard but my Score 9 keeps dissapearing why is that?

    this is the code:
    Code (Java):


        @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(20);

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

            Score score341 = objective.getScore(Main.cc(ChatColor.RED + ""));
            score341.setScore(17);

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

            Score score342 = objective.getScore(Main.cc("" +ChatColor.BLUE +  ""));
            score342.setScore(14);

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

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

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

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

            Score score343 = objective.getScore(Main.cc("" + "" + ""));
            score343.setScore(11);

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

            if (event.getFrom().getBlock().getBiome() != Biome.JUNGLE && event.getTo().getBlock().getBiome() == Biome.JUNGLE) {
                Score score7 = objective.getScore(Main.cc("&1&lBlue"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.DESERT_HILLS && event.getTo().getBlock().getBiome() == Biome.DESERT_HILLS) {
                Score score7 = objective.getScore(Main.cc("&8&lWarZone"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.PLAINS && event.getTo().getBlock().getBiome() == Biome.PLAINS) {
                Score score7 = objective.getScore(Main.cc("&4&lRED"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.BEACH && event.getTo().getBlock().getBiome() == Biome.BEACH) {
                Score score7 = objective.getScore(Main.cc("&e&lSafeZone"));
                score7.setScore(9);
            }
            p.setScoreboard(board);
        }
     
  2. Try doing this

    Code (Text):

            if (event.getFrom().getBlock().getBiome() != Biome.JUNGLE && event.getTo().getBlock().getBiome() == Biome.JUNGLE) {
                Score score7 = objective.getScore(Main.cc("&1&lBlue"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.DESERT_HILLS && event.getTo().getBlock().getBiome() == Biome.DESERT_HILLS) {
                Score score7 = objective.getScore(Main.cc("&8&lWarZone"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.PLAINS && event.getTo().getBlock().getBiome() == Biome.PLAINS) {
                Score score7 = objective.getScore(Main.cc("&4&lRED"));
                score7.setScore(9);
            } else if (event.getFrom().getBlock().getBiome() != Biome.BEACH && event.getTo().getBlock().getBiome() == Biome.BEACH) {
                Score score7 = objective.getScore(Main.cc("&e&lSafeZone"));
                score7.setScore(9);
            }else{
                Score score7 = objective.getScore(Main.cc("&e&lUnknown"));
                score7.setScore(9);
            }
     
    Also there's probably a better way of handling and creating the scoreboard.