Solved Lag problem

Discussion in 'Plugin Development' started by CaptainUniverse, Aug 20, 2014.

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

    CaptainUniverse

    Hi there I am making a plugin for a server with tons of people on every day It does use multiverse and the owner wanted me to work on the scoreboards for it. So I'm also going to give him a per world tablist and per player scoreboards and teams. But the problem is that I don't know how to apply it on join. I was thinking
    for (Player p : Bukkit.getOnlinePlayers()) {
    if (p.getWorld() == e.getPlayer().getWorld()) {
    //do stuff
    }else{
    p.hidePlayer(e.getPlayer));
    e.getPlayer().hidePlayer(P)):
    But the problem is that if this is a server with so many people joining all the time won't these for statements lag out the server? If it does lag it out a lot can someone give me another way thanks!
     
  2. Offline

    Tecno_Wizard

    CaptainUniverse ,
    Yes, that will likely cause some lag with a large server. I would try to see if it does first, and if it does, I would change it to check for players on the spawn point of each world instead.
     
  3. Offline

    CaptainUniverse

    how would you check on the spawn point of each world Tecno_Wizard?
     
  4. Offline

    Tecno_Wizard

    CaptainUniverse, Great question. I have no idea. Let me look, XD

    UPDATE: I think the best way to do it would be to check whether the player onJoin is in the spawn location, and update as necessary depending on the player's location.
     
  5. Offline

    CaptainUniverse

  6. Offline

    xTigerRebornx

    CaptainUniverse Have you actually done any debug that shows that these statements "lag" the server?
     
  7. Offline

    BillyGalbreath

    Imo, it shouldnt have any noticeable lag. Unless //do stuff is heavy. They rest is not so heavy for an onjoin event (it doesnt happen as often as you think, unlike a loop every tick).
     
  8. Offline

    fireblast709

    CaptainUniverse no need to hide players which are in different worlds, is there now :p
     
  9. Offline

    CaptainUniverse

    fireblast709 what do you mean? I mean his server s big with minigames the tablist will be too crowded and it will be more efficient for the players playing the minigames.

    and BillyGalbreath But my frineds server is getting big he might have people joining and leaving every second wouldn't that cause lag?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  10. Offline

    BillyGalbreath

    Not necessarily, no. If a player joins every second, you still have 19 cycles (ticks) in between that are idle (20 ticks per second).

    Edit: Now, if you have a piece of code that makes that single cycle (tick) lag, then you dont have a problem on large servers, you have a problem on ALL servers, big and small.
     
  11. Offline

    CaptainUniverse

Thread Status:
Not open for further replies.

Share This Page