XMPP join/parts are now replicated to MC.

This commit is contained in:
2011-04-30 00:57:14 +01:00
parent 75eb6cfda7
commit a3e84aceb5
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
package com.pleaseignore.BukkitXMPP;
import org.bukkit.ChatColor;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.muc.DefaultParticipantStatusListener;
public class BukkitParticipantStatusListener extends DefaultParticipantStatusListener {
private final BukkitXMPP plugin;
public BukkitParticipantStatusListener(BukkitXMPP instance) {
plugin = instance;
}
@Override
public void joined(String participant) {
plugin.sendMCMessage(ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "XMPP" + ChatColor.GRAY + "] " + ChatColor.WHITE + StringUtils.parseResource(participant) + " has joined the channel");
}
@Override
public void left(String participant) {
plugin.sendMCMessage(ChatColor.GRAY + "[" + ChatColor.DARK_GREEN + "XMPP" + ChatColor.GRAY + "] " + ChatColor.WHITE + StringUtils.parseResource(participant) + " has left the channel");
}
@Override
public void kicked(String participant, String actor, String reason) {
left(participant);
}
@Override
public void banned(String participant, String actor, String reason) {
left(participant);
}
}

View File

@@ -27,6 +27,7 @@ import org.jivesoftware.smackx.muc.MultiUserChat;
*/
public class BukkitXMPP extends JavaPlugin implements PacketListener {
private final BukkitXMPPPlayerListener playerListener = new BukkitXMPPPlayerListener(this);
private final BukkitParticipantStatusListener participantListener = new BukkitParticipantStatusListener(this);
private Logger log;
@@ -75,6 +76,7 @@ public class BukkitXMPP extends JavaPlugin implements PacketListener {
muc.join(nickname, "", history, 2000);
muc.addMessageListener(this);
muc.addParticipantStatusListener(participantListener);
} catch (Exception e) {
log.warning("Error connecting to XMPP server " + server);
}