mirror of
https://github.com/TotalFreedomMC/BukkitTelnet.git
synced 2024-12-27 18:44:20 +00:00
Prevent flood of player list messages by only allowing 1 update every 2 seconds.
This commit is contained in:
parent
6a9d5c9acb
commit
b355edb37b
1 changed files with 10 additions and 2 deletions
|
@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
|
@ -37,9 +38,16 @@ public class PlayerEventListener implements Listener
|
|||
triggerPlayerListUpdates();
|
||||
}
|
||||
|
||||
private static BukkitTask updateTask = null;
|
||||
|
||||
private static void triggerPlayerListUpdates()
|
||||
{
|
||||
new BukkitRunnable()
|
||||
if (updateTask != null)
|
||||
{
|
||||
updateTask.cancel();
|
||||
}
|
||||
|
||||
updateTask = new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -50,7 +58,7 @@ public class PlayerEventListener implements Listener
|
|||
socketListener.triggerPlayerListUpdates(generatePlayerList());
|
||||
}
|
||||
}
|
||||
}.runTaskLater(BukkitTelnet.plugin, 20L);
|
||||
}.runTaskLater(BukkitTelnet.plugin, 20L * 2L);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
Loading…
Reference in a new issue