summaryrefslogtreecommitdiffstats
path: root/EssentialsXMPP/src/com/earth2me/essentials
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsXMPP/src/com/earth2me/essentials')
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java6
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java2
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java13
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java6
4 files changed, 24 insertions, 3 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
index 861e8fc02..a2ee7bed1 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java
@@ -80,6 +80,12 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
{
return instance.users.getAddress(name);
}
+
+ @Override
+ public String getUserByAddress(final String address)
+ {
+ return instance.users.getUserByAddress(address);
+ }
@Override
public boolean toggleSpy(final Player user)
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
index c3509827f..c95520357 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java
@@ -12,6 +12,8 @@ public interface IEssentialsXMPP
String getAddress(final String name);
List<String> getSpyUsers();
+
+ String getUserByAddress(final String address);
void sendMessage(final Player user, final String message);
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java
index bce2277d5..6a2a6e80a 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java
@@ -36,6 +36,19 @@ public class UserManager implements IConf
{
return users.getString(username.toLowerCase() + "." + ADDRESS, null);
}
+
+ public final String getUserByAddress(final String search)
+ {
+ final List<String> usernames = users.getKeys(null);
+ for (String username : usernames)
+ {
+ final String address = users.getString(username + "." + ADDRESS, null);
+ if (address != null && search.equalsIgnoreCase(address)) {
+ return username;
+ }
+ }
+ return search;
+ }
public void setAddress(final String username, final String address)
{
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
index 9ce9d72e0..f750e83ed 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java
@@ -85,7 +85,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
sendCommand(chat, message);
break;
default:
- parent.getServer().broadcastMessage("<XMPP:" + StringUtils.parseBareAddress(chat.getParticipant()) + "> " + message);
+ parent.getServer().broadcastMessage("<X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + "> " + message);
}
}
}
@@ -258,10 +258,10 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
}
else
{
+ final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
for (Player p : matches)
{
-
- p.sendMessage("[" +StringUtils.parseBareAddress(chat.getParticipant()) + ">" + p.getDisplayName() + "] " + message);
+ p.sendMessage(from + p.getDisplayName() + "] " + message);
}
}
}