Fixes for XMPP: display message on /setxmpp, ignore resource on xmpp addresses, reconnect on reload

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1575 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo 2011-06-03 01:50:40 +00:00
parent f6cedda1e2
commit e8e97e86a0
3 changed files with 8 additions and 4 deletions

View File

@ -22,5 +22,6 @@ public class Commandsetxmpp extends EssentialsCommand
}
EssentialsXMPP.getInstance().setAddress(user, args[0]);
user.sendMessage("XMPP address set to "+args[0]);
}
}

View File

@ -48,6 +48,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
xmpp = new XMPPManager(this);
ess.addReloadListener(users);
ess.addReloadListener(xmpp);
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) {
LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));

View File

@ -26,6 +26,7 @@ import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf
@ -84,7 +85,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
sendCommand(chat, message);
break;
default:
parent.getServer().broadcastMessage("<XMPP:" + chat.getParticipant() + "> " + message);
parent.getServer().broadcastMessage("<XMPP:" + StringUtils.parseBareAddress(chat.getParticipant()) + "> " + message);
}
}
}
@ -138,7 +139,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
if (!createdLocally)
{
chat.addMessageListener(this);
final Chat old = chats.put(chat.getParticipant(), chat);
final Chat old = chats.put(StringUtils.parseBareAddress(chat.getParticipant()), chat);
if (old != null)
{
old.removeMessageListener(this);
@ -259,7 +260,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
{
for (Player p : matches)
{
p.sendMessage("[" + chat.getParticipant() + ">" + p.getDisplayName() + "] " + message);
p.sendMessage("[" +StringUtils.parseBareAddress(chat.getParticipant()) + ">" + p.getDisplayName() + "] " + message);
}
}
}
@ -267,7 +269,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private void sendCommand(final Chat chat, final String message)
{
if (config.getStringList("op-users", new ArrayList<String>()).contains(chat.getParticipant()))
if (config.getStringList("op-users", new ArrayList<String>()).contains(StringUtils.parseBareAddress(chat.getParticipant())))
{
final CraftServer craftServer = (CraftServer)parent.getServer();
if (craftServer != null)