• RazerRealm (Custom)

      While using Spigot (1.8.8 Snapshot), I've created a scoreboard and it seems to act weird after a while (Flashes more and more till it just simply doesn't look like a scoreboard anymore and crashes). This is what I mean;

      After this, my server just simply crashed and it returned an IOException

      This is my code;

      package com.pr0totype2.razerrealm.holograms;
      
      import org.bukkit.Bukkit;
      import org.bukkit.ChatColor;
      import org.bukkit.entity.Player;
      import org.bukkit.event.Listener;
      import org.bukkit.scoreboard.DisplaySlot;
      import org.bukkit.scoreboard.Objective;
      import org.bukkit.scoreboard.Score;
      import org.bukkit.scoreboard.Scoreboard;
      
      import com.pr0totype2.razerrealm.RazerRealm;
      
      public class ScoreboardManagement implements Listener {
      
          private RazerRealm plugin;
          
          Scoreboard mainBoard;
          Objective objective;
          Score score;
          
          String splitLine = ChatColor.RED + "" + ChatColor.BOLD + ChatColor.STRIKETHROUGH + "-------------";
          
          public ScoreboardManagement(RazerRealm plugin) {
      	this.plugin = plugin;
          }
      
          public Scoreboard mainScoreboard(Player player) {
      	mainBoard = Bukkit.getScoreboardManager().getNewScoreboard();
      	objective = mainBoard.registerNewObjective("rekt", "dummy");
      	objective.setDisplayName(ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "azer" + ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "ealm");
      	objective.setDisplaySlot(DisplaySlot.SIDEBAR);
      	
      	score = objective.getScore(splitLine + ChatColor.RED);
      	score.setScore(99);
      	score = objective.getScore(plugin.rankshandler.getPrefix(player) + " " + player.getDisplayName());
      	score.setScore(98);
      	score = objective.getScore(splitLine + ChatColor.BLUE);
      	score.setScore(97);
      	score = objective.getScore(ChatColor.YELLOW + "    " + ChatColor.BOLD + "WEB");
      	score.setScore(96);
      	score = objective.getScore(ChatColor.AQUA + "websitedotcom");
      	score.setScore(95);
      	score = objective.getScore(ChatColor.YELLOW + "" + ChatColor.BOLD + "TAG: " + ChatColor.DARK_GRAY + "[" + ChatColor.GRAY + plugin.townhandler.getTownTag(player) + ChatColor.DARK_GRAY + "]");
      	score.setScore(94);
      	score = objective.getScore(splitLine + ChatColor.AQUA);
      	score.setScore(93);
      	
      	Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
      	    @Override
      	    public void run() {
      		for (Player aOnline : Bukkit.getOnlinePlayers()) {
      		    aOnline.setScoreboard(mainScoreboard(aOnline));
      		}
      	    }
      	}, 600L, 600L);
      	return mainBoard;
          }
      }
      

      This method is being triggered upon PlayerJoinEvent, PlayerQuitEvent and ofc via this runnable to update the scoreboard every x ticks.
      Nobody's able to currently join my server as it'll simply crash after a few minutes after the first player joined the server.

      What do I do? What's wrong?

      Thanks in advance,
      Pr0totype2

          [SPIGOT-1428] Scoreboard crashes server

          Pangea added a comment -

          The problem isn't within spigot, it's in your code.

          in your mainScoreboard method, you are scheduling a new task to run every 30 seconds but the task contains mainScoreboard (for each player online!!) so you are infinitely scheduling more tasks along with running the rest of the method. Your code is sssso broken..

          Pangea added a comment - The problem isn't within spigot, it's in your code. in your mainScoreboard method, you are scheduling a new task to run every 30 seconds but the task contains mainScoreboard (for each player online!!) so you are infinitely scheduling more tasks along with running the rest of the method. Your code is sssso broken..

          - Pr0totype2 added a comment -

          @Phoenix616
          Tbh I thought this wasn't something that was wrong on my side really, but I started to notice it actually is. My excuses!

          - Pr0totype2 added a comment - @Phoenix616 Tbh I thought this wasn't something that was wrong on my side really, but I started to notice it actually is. My excuses!

          Phoenix616 added a comment -

          That still starts the task everytime you run mainScoreboard(Player player). Start the task outside of the method.

          Also the ticket system is not there for plugin help, you should use the forums or the irc

          Phoenix616 added a comment - That still starts the task everytime you run mainScoreboard(Player player). Start the task outside of the method. Also the ticket system is not there for plugin help, you should use the forums or the irc

          - Pr0totype2 added a comment -

          @Phoenix616
          Method now looks like this;

              public void mainScoreboard(Player player) {
          	mainBoard = Bukkit.getScoreboardManager().getNewScoreboard();
          	objective = mainBoard.registerNewObjective("rekt", "dummy");
          	objective.setDisplayName(ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "azer" + ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "ealm");
          	objective.setDisplaySlot(DisplaySlot.SIDEBAR);
          	
          	score = objective.getScore(splitLine + ChatColor.RED);
          	score.setScore(99);
          	score = objective.getScore(plugin.rankshandler.getPrefix(player) + " " + player.getDisplayName());
          	score.setScore(98);
          	score = objective.getScore(splitLine + ChatColor.BLUE);
          	score.setScore(97);
          	score = objective.getScore(ChatColor.YELLOW + "    " + ChatColor.BOLD + "WEB");
          	score.setScore(96);
          	score = objective.getScore(ChatColor.AQUA + "websitedotcom");
          	score.setScore(95);
          	score = objective.getScore(ChatColor.YELLOW + "" + ChatColor.BOLD + "TAG: " + ChatColor.DARK_GRAY + "[" + ChatColor.GRAY + plugin.townhandler.getTownTag(player) + ChatColor.DARK_GRAY + "]");
          	score.setScore(94);
          	score = objective.getScore(splitLine + ChatColor.AQUA);
          	score.setScore(93);
          	
          	for (Player aOnline : Bukkit.getOnlinePlayers()) {
          	    aOnline.setScoreboard(mainBoard);
          	}
          	
          	Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
          	    @Override
          	    public void run() {
          		for (Player aOnline : Bukkit.getOnlinePlayers()) {
          		    mainScoreboard(aOnline);
          		}
          	    }
          	}, 600L, 600L);
              }
          

          Upon player join and quit, mainScoreboard for all players is being ran.

          - Pr0totype2 added a comment - @Phoenix616 Method now looks like this; public void mainScoreboard(Player player) { mainBoard = Bukkit.getScoreboardManager().getNewScoreboard(); objective = mainBoard.registerNewObjective( "rekt" , "dummy" ); objective.setDisplayName(ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "azer" + ChatColor.DARK_GREEN + "R" + ChatColor.GREEN + "ealm" ); objective.setDisplaySlot(DisplaySlot.SIDEBAR); score = objective.getScore(splitLine + ChatColor.RED); score.setScore(99); score = objective.getScore(plugin.rankshandler.getPrefix(player) + " " + player.getDisplayName()); score.setScore(98); score = objective.getScore(splitLine + ChatColor.BLUE); score.setScore(97); score = objective.getScore(ChatColor.YELLOW + " " + ChatColor.BOLD + "WEB" ); score.setScore(96); score = objective.getScore(ChatColor.AQUA + "websitedotcom" ); score.setScore(95); score = objective.getScore(ChatColor.YELLOW + "" + ChatColor.BOLD + " TAG: " + ChatColor.DARK_GRAY + " [ " + ChatColor.GRAY + plugin.townhandler.getTownTag(player) + ChatColor.DARK_GRAY + " ]"); score.setScore(94); score = objective.getScore(splitLine + ChatColor.AQUA); score.setScore(93); for (Player aOnline : Bukkit.getOnlinePlayers()) { aOnline.setScoreboard(mainBoard); } Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable () { @Override public void run() { for (Player aOnline : Bukkit.getOnlinePlayers()) { mainScoreboard(aOnline); } } }, 600L, 600L); } Upon player join and quit, mainScoreboard for all players is being ran.

          Phoenix616 added a comment - - edited

          Looks like "normal" behavior to me when you use recursion to set more and more scoreboards at the same time until infinity.

          With other words: Fix your code and don't spawn new repeating tasks every time you get your custom scoreboard.

          Phoenix616 added a comment - - edited Looks like "normal" behavior to me when you use recursion to set more and more scoreboards at the same time until infinity. With other words: Fix your code and don't spawn new repeating tasks every time you get your custom scoreboard.

          SpigotMC added a comment -

          Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 0 version(s) behind. CraftBukkit is 3 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

          SpigotMC added a comment - Your build is not the latest and therefore may be the reason you are having this issue. Spigot is 0 version(s) behind. CraftBukkit is 3 version(s) behind. This message was automatically generated and is not guaranteed to be a solution to your issue.

            Assignee:
            Unassigned
            Reporter:
            - Pr0totype2
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: