mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Fixes for XMPP: display minecraft username for players that have set their address using /setxmpp, others will have the jabber address next to the message
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1576 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
e8e97e86a0
commit
991a5cb24c
4 changed files with 24 additions and 3 deletions
|
@ -80,6 +80,12 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
|
||||||
{
|
{
|
||||||
return instance.users.getAddress(name);
|
return instance.users.getAddress(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserByAddress(final String address)
|
||||||
|
{
|
||||||
|
return instance.users.getUserByAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean toggleSpy(final Player user)
|
public boolean toggleSpy(final Player user)
|
||||||
|
|
|
@ -12,6 +12,8 @@ public interface IEssentialsXMPP
|
||||||
String getAddress(final String name);
|
String getAddress(final String name);
|
||||||
|
|
||||||
List<String> getSpyUsers();
|
List<String> getSpyUsers();
|
||||||
|
|
||||||
|
String getUserByAddress(final String address);
|
||||||
|
|
||||||
void sendMessage(final Player user, final String message);
|
void sendMessage(final Player user, final String message);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,19 @@ public class UserManager implements IConf
|
||||||
{
|
{
|
||||||
return users.getString(username.toLowerCase() + "." + ADDRESS, null);
|
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)
|
public void setAddress(final String username, final String address)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
|
||||||
sendCommand(chat, message);
|
sendCommand(chat, message);
|
||||||
break;
|
break;
|
||||||
default:
|
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
|
else
|
||||||
{
|
{
|
||||||
|
final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
|
||||||
for (Player p : matches)
|
for (Player p : matches)
|
||||||
{
|
{
|
||||||
|
p.sendMessage(from + p.getDisplayName() + "] " + message);
|
||||||
p.sendMessage("[" +StringUtils.parseBareAddress(chat.getParticipant()) + ">" + p.getDisplayName() + "] " + message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue