Hello, I'm making a kitpvp plugin for my server and I'm currently setting up the scoreboard to allow players a look at their stats a bit easier, but I keep running into a weird bug, I'm trying to make the scoreboard like mineplex but it keeps messing up and glitching. Please help me. Code Code (Move your mouse to reveal the content) Code (open) Code (close) Code: @SuppressWarnings("deprecation") public static void ScoreBoard(Player p){ int kst = Main.getInstance().getConfig().getInt(p.getUniqueId() + ".streak"); int k = Main.getInstance().getConfig().getInt(p.getUniqueId() + ".kills"); int d = Main.getInstance().getConfig().getInt(p.getUniqueId() + ".deaths"); int tokens = Main.getInstance().getConfig().getInt(p.getUniqueId() + ".tokens"); ScoreboardManager sbm = Bukkit.getScoreboardManager(); org.bukkit.scoreboard.Scoreboard ingame = sbm.getNewScoreboard(); Objective stats = ingame.registerNewObjective("stats", "dummy"); stats.setDisplaySlot(DisplaySlot.SIDEBAR); stats.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "SHOCKMC"); Score kills = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.GREEN + "Kills")); Score kills1 = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + k)); Score deaths = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.RED + "Deaths")); Score deaths1 = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + d)); Score streak = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.YELLOW + "Killstreak")); Score streak1 = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + kst)); Score t = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.DARK_GREEN + "Tokens")); Score t1 = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + tokens)); Score kit = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.GREEN + "Kit")); Score kit1 = stats.getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" + Main.getInstance().player.get(p))); kills.setScore(14); kills1.setScore(13); deaths.setScore(11); deaths1.setScore(10); streak.setScore(8); streak1.setScore(7); t.setScore(5); t1.setScore(4); kit.setScore(2); kit1.setScore(1); p.setScoreboard(ingame); }
The problem is probably that when you set a score, and then get a new score but with the same name, you get the old score. So you get the Kills with the variable k, and then the Deaths with d, but when you convert it all to a String and print it out, you get the same thing. So you would need to add extra characters that doesn't actually display anything (like ChatColor codes at the end or the very beginning in the String) to make this work.
Could you give me an example on a little bit of my code? @Bram0101 EDIT: Ok it works now! Thanks so much!