diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-06-02 13:24:26 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-06-02 13:24:26 +0000 |
commit | a235f350ccfa53c48a0a3655aa6c0bf1ea382a04 (patch) | |
tree | e7bc836b7584e7d2f4901b3f9baf256cc76728cb /EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java | |
parent | 395f65dc4a81fc8985f7852b4e783ab18959351d (diff) | |
download | Essentials-a235f350ccfa53c48a0a3655aa6c0bf1ea382a04.tar Essentials-a235f350ccfa53c48a0a3655aa6c0bf1ea382a04.tar.gz Essentials-a235f350ccfa53c48a0a3655aa6c0bf1ea382a04.tar.lz Essentials-a235f350ccfa53c48a0a3655aa6c0bf1ea382a04.tar.xz Essentials-a235f350ccfa53c48a0a3655aa6c0bf1ea382a04.zip |
Added EssentialsXMPP from newplugins branch.
Updated to work with trunk.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1564 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java')
-rw-r--r-- | EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java new file mode 100644 index 000000000..a64bd17af --- /dev/null +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java @@ -0,0 +1,55 @@ +package com.earth2me.essentials.xmpp; + +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.User; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerQuitEvent; + + +class EssentialsXMPPPlayerListener extends PlayerListener +{ + private final transient IEssentials ess; + + EssentialsXMPPPlayerListener(final IEssentials ess) + { + super(); + this.ess = ess; + } + + @Override + public void onPlayerJoin(final PlayerJoinEvent event) + { + final User user = ess.getUser(event.getPlayer()); + sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game"); + } + + @Override + public void onPlayerChat(final PlayerChatEvent event) + { + final User user = ess.getUser(event.getPlayer()); + sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage())); + } + + @Override + public void onPlayerQuit(final PlayerQuitEvent event) + { + final User user = ess.getUser(event.getPlayer()); + sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game"); + } + + private void sendMessageToSpyUsers(final String message) + { + try + { + for (String address : EssentialsXMPP.getInstance().getSpyUsers()) + { + EssentialsXMPP.getInstance().sendMessage(address, message); + } + } + catch (Exception ex) + { + } + } +} |