[Scoreboard] Get player name by score

Discussion in 'Plugin Development' started by Mindfulhacker, Oct 19, 2014.

Thread Status:
Not open for further replies.
  1. Hi,
    In an attempt to reduce severe lag caused by my custom plugin for a server, I have decided to add a if statement that will stop a "Dummy Player" from refreshing it's value and causing lag.

    But, in this if statement, I need something to compare it to.

    Code:java
    1.  
    2. Score PlayerText = objective.getScore(ChatColor.GOLD+""+ChatColor.BOLD+"Online:");
    3. PlayerText.setScore(10);
    4. Score PlayerValue = objective.getScore("" + Bukkit.getOnlinePlayers().length);
    5. PlayerValue.setScore(9);
    6.  


    What happens here a dummy player called "Online:" is called and after it, another dummy player is called representing the amount of players in the game.

    This is what the scoreboard looks like.

    To reduce the lag, how would I find the dummy name using its score.

    eg. get the text using the number 9.
     
  2. Offline

    tcvs

    Mindfulhacker One thing you could do is get all the things on the scoreboard(There is a method) and go through them and see if there value equals what you are looking for.
     
    Mindfulhacker likes this.
Thread Status:
Not open for further replies.

Share This Page