summaryrefslogtreecommitdiffstats
path: root/EssentialsXMPP
diff options
context:
space:
mode:
authorpatjense <patjense@cisco.com>2013-10-13 12:59:04 -0700
committerKHobbits <rob@khobbits.co.uk>2013-10-16 20:52:50 +0100
commit27ee5878874639ae84cc6870dd849c04d05ab5a4 (patch)
tree6b4f17a8e94030c82e823c730ef31ad30b0a7152 /EssentialsXMPP
parent601bdbff4643b52f3ae503911bbb241a73e45b4b (diff)
downloadEssentials-27ee5878874639ae84cc6870dd849c04d05ab5a4.tar
Essentials-27ee5878874639ae84cc6870dd849c04d05ab5a4.tar.gz
Essentials-27ee5878874639ae84cc6870dd849c04d05ab5a4.tar.lz
Essentials-27ee5878874639ae84cc6870dd849c04d05ab5a4.tar.xz
Essentials-27ee5878874639ae84cc6870dd849c04d05ab5a4.zip
add delayed task for XMPP presence update
Diffstat (limited to 'EssentialsXMPP')
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java123
1 files changed, 74 insertions, 49 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java
index c0913e6a9..d7e30f7dc 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java
@@ -3,6 +3,9 @@ package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import net.ess3.api.IUser;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -10,64 +13,86 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.Server;
class EssentialsXMPPPlayerListener implements Listener
{
- private final transient IEssentials ess;
+ private final transient IEssentials ess;
- EssentialsXMPPPlayerListener(final IEssentials ess)
- {
- super();
- this.ess = ess;
- }
+ EssentialsXMPPPlayerListener(final IEssentials ess)
+ {
+ super();
+ this.ess = ess;
+ }
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerJoin(final PlayerJoinEvent event)
- {
- final User user = ess.getUser(event.getPlayer());
- sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game");
- }
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerJoin(final PlayerJoinEvent event)
+ {
+ final User user = ess.getUser(event.getPlayer());
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerChat(final AsyncPlayerChatEvent event)
- {
- final User user = ess.getUser(event.getPlayer());
- sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage()));
- }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ EssentialsXMPP.updatePresence();
+ }
+ });
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerQuit(final PlayerQuitEvent event)
- {
- final User user = ess.getUser(event.getPlayer());
- sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game");
- }
+ sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game");
+ }
- private void sendMessageToSpyUsers(final String message)
- {
- try
- {
- List<String> users = EssentialsXMPP.getInstance().getSpyUsers();
- synchronized (users)
- {
- for (final String address : users)
- {
- Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable()
- {
- @Override
- public void run()
- {
- EssentialsXMPP.getInstance().sendMessage(address, message);
- }
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerChat(final AsyncPlayerChatEvent event)
+ {
+ final User user = ess.getUser(event.getPlayer());
+ sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage()));
+ }
- });
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerQuit(final PlayerQuitEvent event)
+ {
+ final User user = ess.getUser(event.getPlayer());
- }
- }
- }
- catch (Exception ex)
- {
- // Ignore exceptions
- }
- }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ EssentialsXMPP.updatePresence();
+ }
+ });
+
+
+ sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game");
+ }
+
+ private void sendMessageToSpyUsers(final String message)
+ {
+ try
+ {
+ List<String> users = EssentialsXMPP.getInstance().getSpyUsers();
+ synchronized (users)
+ {
+ for (final String address : users)
+ {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(ess, new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ EssentialsXMPP.getInstance().sendMessage(address, message);
+ }
+
+ });
+
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ // Ignore exceptions
+ }
+ }
}