mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-11-19 01:40:00 +00:00
Add listener for ServerListPingEvent and remove any vanished players. Also refactored EssentialsPluginListener serverListener to pluginListener
This commit is contained in:
parent
3c0424226e
commit
ee64f7c4ff
2 changed files with 36 additions and 3 deletions
|
@ -282,9 +282,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||
LOGGER.log(Level.INFO, "Registering Listeners");
|
||||
}
|
||||
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvents(serverListener, this);
|
||||
confList.add(serverListener);
|
||||
final EssentialsPluginListener pluginListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvents(pluginListener, this);
|
||||
confList.add(pluginListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvents(playerListener, this);
|
||||
|
@ -307,6 +307,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
final EssentialsServerListener serverListener = new EssentialsServerListener(this);
|
||||
pm.registerEvents(serverListener, this);
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
jails.resetListener();
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.earth2me.essentials;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
public class EssentialsServerListener implements Listener {
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsServerListener(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onServerListPing(final ServerListPingEvent event) {
|
||||
Iterator<Player> iterator = event.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Player player = iterator.next();
|
||||
if (ess.getUser(player).isVanished()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue