Solved Scoreboard is making server lagging.

Discussion in 'Plugin Development' started by PlayFriik, Dec 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    PlayFriik

    Hello.
    I was wondering what would be better: one big timer or just many small ones?
     
  2. Offline

    Rocoty

    No clue...what is this for? You've given us no context to answer your question.
     
  3. Offline

    PlayFriik

    My server is just lagging with my minigame plugin sometimes, so I thought the timers are making lag and I would fix it with many small timers. I have very big ones atm....
    @Rocoty
     
  4. Offline

    Rocoty

    Okay. The amount of timers you have shouldn't pose a problem. It's what you do in the timers that makes a difference. You may be performing slow operations.
     
  5. Offline

    PlayFriik

    Yes, I am checking in a timer that is a player in cuboid area, I think this is making the lag, because it is calculating many things, but okay, I am gonna work on it then.
    @Rocoty
     
  6. Offline

    Gamesareme

    @PlayFriik Can you give us your timer code, so we can see if it may be causing lagg?
     
  7. Offline

    PlayFriik

    @Gamesareme
    Ok, I was testing for a longggg time, but I know now what is the problem at least: Scoreboard.
    Pretty much is it sending scoreboard to every player, who is online.
    Anyone can give me advice what to do? How I would fix this?

    Code:
                        for (Player player : Bukkit.getOnlinePlayers() {
                           ScoreboardManager manager = Bukkit.getScoreboardManager();
                           board = manager.getNewScoreboard();
                           Objective objective = board2.registerNewObjective("Test", "dummy");
                           objective.setDisplayName("┬žaDisplay┬ž4Name");
                           objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                           Score score1 = objective.getScore(Bukkit.getOfflinePlayer("Online"));
                           score1.setScore(Bukkit.getOnlinePlayers().size());
                           player.setScoreboard(board2);
                        }

    // FIXED!
    I just replaced:
    Score score1 = objective.getScore(Bukkit.getOfflinePlayer("Online"));
    with:
    Score score1 = objective.getScore("Online");
     
    Last edited: Dec 29, 2014
  8. Offline

    Gamesareme

    @PlayFriik Ok, it is good that you fixed it. I was wondering, how often do you send all the players online the Scoreboard? Because running that for loop every tick would be drawing a bit from the server.
     
    PlayFriik likes this.
Thread Status:
Not open for further replies.

Share This Page