diff options
author | snowleo <schneeleo@gmail.com> | 2011-09-02 16:15:57 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-09-02 16:16:15 +0200 |
commit | 83177972748dc8ce84703b464a4db70016bce620 (patch) | |
tree | 3ce5909a99c09ce454f2c660bb47ff53eaa115ef /EssentialsXMPP | |
parent | 61a377bc261f4b5822730311617946d41d02c80f (diff) | |
download | Essentials-83177972748dc8ce84703b464a4db70016bce620.tar Essentials-83177972748dc8ce84703b464a4db70016bce620.tar.gz Essentials-83177972748dc8ce84703b464a4db70016bce620.tar.lz Essentials-83177972748dc8ce84703b464a4db70016bce620.tar.xz Essentials-83177972748dc8ce84703b464a4db70016bce620.zip |
Prevent that hidden players broadcast afk messages
Prevent that moving players triggers unafk too early, they can now move within a radius of 3 blocks from the position where they went afk.
Diffstat (limited to 'EssentialsXMPP')
4 files changed, 13 insertions, 9 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index 8ab62cd4d..34f862627 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -1,6 +1,7 @@ package com.earth2me.essentials.xmpp; import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.IUser; import com.earth2me.essentials.Util; import java.util.List; import java.util.logging.Level; @@ -83,9 +84,10 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP } @Override - public String getUserByAddress(final String address) + public IUser getUserByAddress(final String address) { - return instance.users.getUserByAddress(address); + String username = instance.users.getUserByAddress(address); + return username == null ? null : ess.getUser(username); } @Override @@ -122,9 +124,9 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP } @Override - public void broadcastMessage(final String name, final String message) + public void broadcastMessage(final IUser sender, final String message) { - ess.broadcastMessage(name, message); + ess.broadcastMessage(sender, message); try { for (String address : getSpyUsers()) diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java index d90bff803..1ed9fa732 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.xmpp; +import com.earth2me.essentials.IUser; import java.util.List; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -13,7 +14,7 @@ public interface IEssentialsXMPP extends Plugin List<String> getSpyUsers(); - String getUserByAddress(final String address); + IUser getUserByAddress(final String address); boolean sendMessage(final Player user, final String message); @@ -23,5 +24,5 @@ public interface IEssentialsXMPP extends Plugin boolean toggleSpy(final Player user); - void broadcastMessage(final String name, final String message); + void broadcastMessage(final IUser sender, final String message); } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java index 6a2a6e80a..9734444ad 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java @@ -47,7 +47,7 @@ public class UserManager implements IConf return username; } } - return search; + return null; } 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 e43844c5b..d7aedb9f4 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.xmpp; import com.earth2me.essentials.Console; import com.earth2me.essentials.EssentialsConf; import com.earth2me.essentials.IConf; +import com.earth2me.essentials.IUser; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -101,8 +102,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager sendCommand(chat, message); break; default: - final String name = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())); - parent.broadcastMessage(name, "="+name+": "+ message); + final IUser sender = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())); + parent.broadcastMessage(sender, "="+sender.getDisplayName()+": "+ message); } } } |