HUGE Scoreboard lagg (Fix includes) (MORE LAGG BUGS)
LadyCailinBot opened this issue ยท 23 comments
CMDHELPER-3060 - Reported by Mac.Niv
I love CommandHelper and am making all my minigames out of it. I did run into a big issue lately. Whenever you would use set_pscore(), get_pscore() or reset_all_pscores() with an Offline or Fake player this would cause a big server freeze.
FIX: This is caused by Bukkit.getOfflinePlayer() contacting mojang servers. The Bukkit.getOfflinePlayer() can be replaced by a String (player name). That will fix the huge lagg
EDIT: STILL NOT FIXED FOR TEAMS! See comment section below!
Comment by PseudoKnight
I feel like this was fixed twice already, but apparently this was missed:
https://github.com/sk89q/CommandHelper/blob/master/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCScore.java#L22
Comment by Mac.Niv
Woulden't this be able to be fixed as this is realy something that me (and alot of people) will realy find handy. I need to display the minigame statistics in the sidebar, and this isn't possible if it freezes the server for ~5s every time :(
Comment by PseudoKnight
So I looked into this. This was already fixed. The method I mentioned above is actually unused. So either you're using an old build of CH or an older Minecraft. Which is it?
Comment by Mac.Niv
I just downloaded the latest build (#2883) and the bug is still happening for me. I am using Minecraft 1.8.4 Vanilla. If I would use set_pscore(objective, 'Test name #1', 1). The server would freeze for 1-2 seconds before the function would return void. If I use a name of a player who is currently on the server there is no lagg. Would this be caused by something else you think?
EDIT: If I use the /scoreboard command to give an offline player a score, there is no lagg so this should be caused by CommandHelper (Or Spigot). I am running Spigot build git-Spigot-4c7d0c0-7d020a7 (MC 1.8.3)
Comment by PseudoKnight
Just setup a test on my server. Took 317ms for set_pscore and 166ms for get_pscore. That's no where near 1-2 seconds, but it still indicates it's fetching from Mojang. I'll take a look at the code again.
Comment by PseudoKnight
Just so you're aware, CH already uses strings for scores. However, for backwards compatibility it first checks using reflection that the new method exists, otherwise it falls back to using offline players. The only thing I can think of is that the reflection isn't finding the class, which would be a big issue. I'm testing for that now just in case.
Comment by PseudoKnight
So ya, turns out reflection isn't working there. It's using the old style. I'm not sure why. I'm asking for help on the problem.
Comment by PseudoKnight
Comment by Mac.Niv
yay thanks a lot! Now I can finally make sidebars again :P
Comment by PseudoKnight
I accidentally typed getMethod instead of hasMethod in the commit message (grr), but it works and was pulled.
Comment by Mac.Niv
Uhm, I still have the feeling something is wrong...
When I add a fake player to a team it still laggs, just like it used to do for set_pscore, althrough set_pscore() is fixed now.
After some more research I found out that it happens for team_add_player() and reset_all_pscores()
Another things is removing scoreboard with remove_scoreboard() when I try to remove a scoreboard that has fake players in it it will also lagg. I have a sidebar with 15 'fake players', when I use remove_scoreboard() it takes about 3 seconds to process. I have no idea if this has to do with the same bug but I still hope it can be fixed!
NOTE: I am indeed on a build where set_pscore() is fixed
EDIT: Might this also be why get_teams() sometimes laggs too?
Comment by PseudoKnight
Ah, so there were two bugs. I'll look more.
BTW, the word is "lag". I've finally hit my limit on that misspelling.
Comment by PseudoKnight
Oh, I think I see it. Someone did the method check the wrong way around and so it uses the deprecated method that still exists in new bukkit builds.
Comment by PseudoKnight
It looks like teams cannot have string entries. You can only use players in teams. Make sure you're not doing this and report back. I suspect all these issues might be because you're assigning fake players to teams.
Comment by PseudoKnight
I just checked the API and it appears there's more methods for teams than was indicated in my IDE. I think my IDE might be decompiling an old build.
Comment by PseudoKnight
Oh, it's Spigot specific methods. No wonder. We can use reflection there to avoid the offlineplayer lag.
Comment by Mac.Niv
So would this also be the fix for the remove_scoreboard() function that removes a scoreboard containing fake players?
Comment by PseudoKnight
Yes.
This fixes the team abtracted methods that were using OfflinePlayers by using the Spigot-only methods if they're available, because they use string entries instead. It also fixes some abstracted methods that were using the old OfflinePlayer methods because of another bug in ReflectionUtils.hasMethod(). (the "set" methods with void return types, like resetScores())