diff options
Diffstat (limited to 'EssentialsXMPP')
3 files changed, 27 insertions, 9 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index c0e56507c..57c692c8c 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.Essentials; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.Util; import java.util.List; @@ -121,4 +120,21 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP { return instance.users.getSpyUsers(); } + + @Override + public void broadcastMessage(final String name, final String message) + { + ess.broadcastMessage(name, message); + try + { + for (String address : EssentialsXMPP.getInstance().getSpyUsers()) + { + EssentialsXMPP.getInstance().sendMessage(address, message); + } + } + catch (Exception ex) + { + // Ignore exceptions + } + } } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java index f5a944e2b..d90bff803 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java @@ -2,17 +2,17 @@ package com.earth2me.essentials.xmpp; import java.util.List; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; -public interface IEssentialsXMPP +public interface IEssentialsXMPP extends Plugin { - String getAddress(final Player user); String getAddress(final String name); List<String> getSpyUsers(); - + String getUserByAddress(final String address); boolean sendMessage(final Player user, final String message); @@ -22,5 +22,6 @@ public interface IEssentialsXMPP void setAddress(final Player user, final String address); boolean toggleSpy(final Player user); - + + void broadcastMessage(final String name, final String message); } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index f33f29416..e43844c5b 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -38,14 +38,14 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager private transient ChatManager chatManager; private final transient Map<String, Chat> chats = Collections.synchronizedMap(new HashMap<String, Chat>()); private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<LogRecord>()); - private final transient JavaPlugin parent; + private final transient IEssentialsXMPP parent; private transient List<String> logUsers; private transient Level logLevel; private transient boolean ignoreLagMessages = true; private transient Thread loggerThread; private transient boolean threadrunning = true; - public XMPPManager(final JavaPlugin parent) + public XMPPManager(final IEssentialsXMPP parent) { super(); this.parent = parent; @@ -101,7 +101,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager sendCommand(chat, message); break; default: - parent.getServer().broadcastMessage("<X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + "> " + message); + final String name = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())); + parent.broadcastMessage(name, "="+name+": "+ message); } } } @@ -350,7 +351,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } else { - final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">"; + final String from = "[" + parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">"; for (Player p : matches) { p.sendMessage(from + p.getDisplayName() + "] " + message); |