mirror of
https://github.com/nikdoof/bukkitxmpp.git
synced 2025-12-14 01:52:16 +00:00
XMPP join/parts are now replicated to MC.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user