Lag spikes on Join & Leave events.

Discussion in 'Plugin Development' started by DiamondXF, May 5, 2014.

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

    DiamondXF

    After many hours of been unable to find a viable solution to our issues we have not been able to come to conclusion or a fix on how or why these lag spikes are happening. I would just like to say in advance thanks for any time put into reading and responding to this message.


    http://paste.ubuntu.com/7400764/ - http://aikar.co/timings.php?url=7400764
    http://paste.ubuntu.com/7400783/ - http://aikar.co/timings.php?url=7400783
    http://paste.ubuntu.com/7400818/ - http://aikar.co/timings.php?url=7400818


    You can see above there are different tests taken at different times. The timings from Aikar will give a different perspective from the ubuntu pastes, the issues that are occurring are from ChromaHillsRPG. Maintenance on the PlayerJoinEvent and PlayerQuitEvent.

    Have a look below at what happens on these events.

    Code:
     Player player = event.getPlayer();
    Main.getInstance().setUpData(player);
    
    Group group = Main.getInstance().getTitle(player);
    if(group == null){
         return;
    }
    player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
    PlayerSkill pSkills = Main.getInstance().pSkills.get(player.getUniqueId().toString());
    int mainLevel = pSkills.getLevelHandler().getLevel();
    String gName = group.getPrefix();
    String prefix = Main.getInstance().getConfig().getString("name-format-1");
    String level = Main.getInstance().getConfig().getString("name-format-2").replace("%level%", String.valueOf(mainLevel));
    prefix = prefix.replace("%Group-Pre%", gName);
    prefix = prefix.replace("%GroupPre%", gName);
    prefix = ChatColor.translateAlternateColorCodes('&', prefix);
    if(prefix.length() > 16){
         Bukkit.getLogger().severe("HEYO! Too long there for the prefix...." + prefix.length());
         return;
    }
    level = ChatColor.translateAlternateColorCodes('&', level);
    if(!player.hasPermission("rpg.noshow")){
         NametagAPI.setPrefix(player.getName(), prefix);
         NametagAPI.setSuffix(player.getName(), level);
    }
    Again, thanks in advance for any responses and I can provide more information if needed.
    Our in-house developer and no one on our team can work out how the CPU keeps spiking around 15-40% each time a player leaves. We believe it is to do with the plugin accessing the files.

    Thanks,
    Luke.
     
  2. You could use the bukkitschedular to spread the things you do over several ticks.
     
Thread Status:
Not open for further replies.

Share This Page