my problem is i made a scoreboard but when i run the plugin the scoreboard timer is lagging like this 0:01 0:02 and lag something for second and continue 0:03 also i've problem with the scoreboard , it appears and gone for very small time , here is my code @EventHandler public void PlayerJoin(PlayerJoinEvent events) { final Player p = events.getPlayer(); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { public void run() { if (Main.this.times) { Main.this.getConfig().set("Seconds", Integer.valueOf(Main.this.getConfig().getInt("Seconds") + 1)); Main.this.saveConfig(); if (Main.this.getConfig().getInt("Seconds") >= 60) { Main.this.getConfig().set("Seconds", Integer.valueOf(0)); Main.this.getConfig().set("Minutes", Integer.valueOf(Main.this.getConfig().getInt("Minutes") + 1)); Main.this.saveConfig(); } } } } , 0L, 20L); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { public void run() { Main.this.board = Bukkit.getServer().getScoreboardManager().getNewScoreboard(); Main.this.o = Main.this.board.registerNewObjective("test", "dummy"); Main.this.o.setDisplayName("§bBlocksSG §4" + Main.this.time(0)); Main.this.o.setDisplaySlot(DisplaySlot.SIDEBAR); Score s11 = Main.this.o.getScore("§cKills:"); s11.setScore(11); Score s10 = Main.this.o.getScore(ChatColor.YELLOW + Main.this.getConfig().getString("Kills")); s10.setScore(10); Score s9 = Main.this.o.getScore(" "); s9.setScore(9); Score s8 = Main.this.o.getScore("§bRemaining:"); s8.setScore(8); Score s7 = Main.this.o.getScore(ChatColor.YELLOW + Main.this.getConfig().getString("Remaining")); s7.setScore(7); Score s6 = Main.this.o.getScore(" "); s6.setScore(6); Score s5 = Main.this.o.getScore("§bSpectators:"); s5.setScore(5); Score s4 = Main.this.o.getScore(ChatColor.YELLOW + Main.this.getConfig().getString("Spectators")); s4.setScore(4); Score s3 = Main.this.o.getScore(" "); s3.setScore(3); Score s2 = Main.this.o.getScore("§bServer:"); s2.setScore(2); Score s1 = Main.this.o.getScore("§eSG" + ChatColor.YELLOW + Main.this.getConfig().getString("Server")); s1.setScore(1); p.setScoreboard(Main.this.board); } } , 0L, 9L); } ------------------- i need help please , i'm not english so sorry for my bad English . ty <3
@tvtad202020 The reason your server is lagging is because you are setting the scoreboard twice a second. Do not call setScoreboard unless you are creating a new scoreboard instance. To add onto #1, if the player already has a scoreboard, get that player's scoreboard instead of creating a new scoreboard. After that, only change the scores if something has changed. If nothing changed, so not update the scoreboard. Side note: scores with the same name (such as s9,s6,ands3) cannot exist in the same scoreboard. Make sure there is atleast one difference between each score. Stop the static abuse! You should never need to use static. If you need the main class's instance, pass the instance through this class's constructor. Do not create a static variable called "this".
okay but im new at bukkit coding can you learn me how to do that like can you edit this code by yourself so it shows that please <3? but this is time so i need to update it every second to update the time also if i removed the runnable it run correctly without any problems @Zombie_Striker I need it important for my server please dude EDIT by Moderator: merged posts, please use the edit button instead of double posting.