From 99bf740ff6d9112d3a3c1d4cf75d2db5caf6e7ce Mon Sep 17 00:00:00 2001 From: cnaude Date: Fri, 25 Dec 2015 12:27:58 -0700 Subject: [PATCH] Join and quit delay should probably be the same and configurable. --- .../GameListeners/GamePlayerJoinListener.java | 5 ++--- .../GameListeners/GamePlayerQuitListener.java | 21 ++++++++++++------- .../java/com/cnaude/purpleirc/PurpleIRC.java | 4 ++++ src/main/resources/config.yml | 5 +++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java index 5fc1f42..c430c57 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java @@ -45,8 +45,7 @@ public class GamePlayerJoinListener implements Listener { */ @EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoinEvent(final PlayerJoinEvent event) { - plugin.logDebug("PlayerJoinEvent: " + event.getPlayer().getDisplayName() - + ": " + event.getPlayer().getCustomName()); + plugin.logDebug("onPlayerJoinEvent [" + plugin.joinDelay + "]: " + event.getPlayer().getName()); if (plugin.kickedPlayers.contains(event.getPlayer().getName())) { plugin.kickedPlayers.remove(event.getPlayer().getName()); plugin.logDebug("Removing player " + event.getPlayer().getName() + " from the recently kicked list."); @@ -65,6 +64,6 @@ public class GamePlayerJoinListener implements Listener { plugin.updateDisplayNameCache(event.getPlayer()); plugin.updateUuidCache(event.getPlayer()); } - }, 20); + }, plugin.joinDelay); } } diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java index 6e0e142..b835b19 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java @@ -44,8 +44,8 @@ public class GamePlayerQuitListener implements Listener { * @param event */ @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerQuitEvent(PlayerQuitEvent event) { - plugin.logDebug("QUIT: " + event.getPlayer().getName()); + public void onPlayerQuitEvent(final PlayerQuitEvent event) { + plugin.logDebug("onPlayerQuitEvent [" + plugin.quitDelay + "]: " + event.getPlayer().getName()); if (plugin.kickedPlayers.contains(event.getPlayer().getName())) { plugin.kickedPlayers.remove(event.getPlayer().getName()); plugin.logDebug("Player " @@ -53,12 +53,17 @@ public class GamePlayerQuitListener implements Listener { + " was in the recently kicked list. Not sending quit message."); return; } - for (PurpleBot ircBot : plugin.ircBots.values()) { - ircBot.gameQuit(event.getPlayer(), event.getQuitMessage()); - if (plugin.netPackets != null) { - plugin.netPackets.updateTabList(event.getPlayer()); + plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { + @Override + public void run() { + for (PurpleBot ircBot : plugin.ircBots.values()) { + ircBot.gameQuit(event.getPlayer(), event.getQuitMessage()); + if (plugin.netPackets != null) { + plugin.netPackets.updateTabList(event.getPlayer()); + } + ircBot.sendRemotePlayerInfo(); + } } - ircBot.sendRemotePlayerInfo(); - } + }, plugin.quitDelay); } } diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index 26b5e38..e5e83b9 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -178,6 +178,8 @@ public class PurpleIRC extends JavaPlugin { public boolean mineverseChatEnabled; public Long ircConnCheckInterval; public Long ircChannelCheckInterval; + public Long joinDelay; + public long quitDelay; public ChannelWatcher channelWatcher; public LinkUpdater linkUpdater; public ColorConverter colorConverter; @@ -698,6 +700,8 @@ public class PurpleIRC extends JavaPlugin { ircConnCheckInterval = getConfig().getLong("conn-check-interval"); reconnectSuppression = getConfig().getInt("reconnect-fail-message-count", 10); ircChannelCheckInterval = getConfig().getLong("channel-check-interval"); + joinDelay = getConfig().getLong("join-delay", 20); + quitDelay = getConfig().getLong("quit-delay", 20); customTabGamemode = getConfig().getString("custom-tab-gamemode", "SPECTATOR"); customTabList = getConfig().getBoolean("custom-tab-list", false); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 23f0683..d1b0a4b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -16,6 +16,10 @@ enable-ident-server: false channel-check-interval: 100 # Alias /irc smsg to /msg override-msg-cmd: false +# Number of ticks after join event fires to process and send to IRC +join-delay: 20 +# Number of ticks after quit event fires to process and send to IRC +quit-delay: 20 # Alias for /irc smsg smsg-alias: '/m' # Alias for /irc smsg @@ -182,6 +186,7 @@ message-format: # Invalid IRC command message invalid-irc-command: "I'm sorry '%NICK%' I can't do that. Type '%CMDPREFIX%help' for a list of commands I might respond to." no-perm-for-irc-command: "I'm sorry '%NICK%' you are not authorized to do that. Type '%CMDPREFIX%help' for a list of commands I might respond to." + # ReportRTS tempates rts-notify: '[RTS:New] #%TICKETNUMBER% <%NAME%> %MESSAGE%' rts-complete: '[RTS:Complete] #%TICKETNUMBER% <%NAME%> %MESSAGE%' rts-claim: '[RTS:Claim] #%TICKETNUMBER% <%NAME%> %MESSAGE%'