diff options
Diffstat (limited to 'EssentialsXMPP/src/com/earth2me')
8 files changed, 30 insertions, 44 deletions
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java index e0bf9827c..4fe9283df 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java @@ -1,20 +1,14 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.User; +import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.NotEnoughArgumentsException; -import org.bukkit.Server; public class Commandsetxmpp extends EssentialsCommand { - public Commandsetxmpp() - { - super("setxmpp"); - } - @Override - protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws NotEnoughArgumentsException + protected void run(final IUser user, final String commandLabel, final String[] args) throws NotEnoughArgumentsException { if (args.length < 1) { diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java index e7dd01670..23bd34170 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java @@ -3,20 +3,14 @@ package com.earth2me.essentials.xmpp; import com.earth2me.essentials.Console; import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.NotEnoughArgumentsException; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandxmpp extends EssentialsCommand { - public Commandxmpp() - { - super("xmpp"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException + protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException { if (args.length < 2) { @@ -31,7 +25,7 @@ public class Commandxmpp extends EssentialsCommand else { final String message = getFinalArg(args, 1); - final String senderName = sender instanceof Player ? ess.getUser(sender).getDisplayName() : Console.NAME; + final String senderName = sender instanceof Player ? ess.getUser((Player)sender).getDisplayName() : Console.NAME; sender.sendMessage("[" + senderName + ">" + address + "] " + message); if (!EssentialsXMPP.getInstance().sendMessage(address, "[" + senderName + "] " + message)) { diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java index 4f276c3b9..5da4d8f93 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java @@ -3,20 +3,14 @@ package com.earth2me.essentials.xmpp; import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.NotEnoughArgumentsException; import java.util.List; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class Commandxmppspy extends EssentialsCommand { - public Commandxmppspy() - { - super("xmppspy"); - } - @Override - protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException + protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException { if (args.length < 1) { diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java index bcbbfa17d..cf7fb1814 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPP.java @@ -1,8 +1,10 @@ package com.earth2me.essentials.xmpp; +import com.earth2me.essentials.EssentialsCommandHandler; import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.IUser; +import com.earth2me.essentials.api.ICommandHandler; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IUser; import java.util.List; import java.util.Locale; import java.util.logging.Level; @@ -23,6 +25,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP private transient UserManager users; private transient XMPPManager xmpp; private transient IEssentials ess; + private transient ICommandHandler commandHandler; public static IEssentialsXMPP getInstance() { @@ -56,6 +59,8 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP ess.addReloadListener(users); ess.addReloadListener(xmpp); + + commandHandler = new EssentialsCommandHandler(EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", ess); LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); } @@ -73,7 +78,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP @Override public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args) { - return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", null); + return commandHandler.handleCommand(sender, command, commandLabel, args); } @Override diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java index 47966aee0..1bf672515 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/EssentialsXMPPPlayerListener.java @@ -1,7 +1,7 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.IEssentials; -import com.earth2me.essentials.User; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IUser; import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; @@ -21,21 +21,21 @@ class EssentialsXMPPPlayerListener extends PlayerListener @Override public void onPlayerJoin(final PlayerJoinEvent event) { - final User user = ess.getUser(event.getPlayer()); + final IUser user = ess.getUser(event.getPlayer()); sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game"); } @Override public void onPlayerChat(final PlayerChatEvent event) { - final User user = ess.getUser(event.getPlayer()); + final IUser user = ess.getUser(event.getPlayer()); sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage())); } @Override public void onPlayerQuit(final PlayerQuitEvent event) { - final User user = ess.getUser(event.getPlayer()); + final IUser user = ess.getUser(event.getPlayer()); sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game"); } diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java index 0635ca131..83851d055 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/IEssentialsXMPP.java @@ -1,6 +1,6 @@ package com.earth2me.essentials.xmpp; -import com.earth2me.essentials.IUser; +import com.earth2me.essentials.api.IUser; import java.util.List; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java index 85ef50949..c8df2fcb3 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/UserManager.java @@ -1,12 +1,12 @@ package com.earth2me.essentials.xmpp; import com.earth2me.essentials.EssentialsConf; -import com.earth2me.essentials.IConf; +import com.earth2me.essentials.api.IReload; import java.io.File; import java.util.*; -public class UserManager implements IConf +public class UserManager implements IReload { private final transient EssentialsConf users; private final transient List<String> spyusers = new ArrayList<String>(); @@ -16,7 +16,7 @@ public class UserManager implements IConf public UserManager(final File folder) { users = new EssentialsConf(new File(folder, "users.yml")); - reloadConfig(); + onReload(); } public final boolean isSpy(final String username) @@ -65,11 +65,11 @@ public class UserManager implements IConf userdata.put(SPY, spy); users.setProperty(username, userdata); users.save(); - reloadConfig(); + onReload(); } @Override - public final void reloadConfig() + public final void onReload() { users.load(); spyusers.clear(); diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index 72bdb113d..eb321ca81 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -1,9 +1,8 @@ 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 com.earth2me.essentials.api.IReload; +import com.earth2me.essentials.api.IUser; import java.io.File; import java.util.*; import java.util.logging.Handler; @@ -18,7 +17,7 @@ import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.util.StringUtils; -public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf +public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload { private static final Logger LOGGER = Logger.getLogger("Minecraft"); private final transient EssentialsConf config; @@ -39,7 +38,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager this.parent = parent; config = new EssentialsConf(new File(parent.getDataFolder(), "config.yml")); config.setTemplateName("/config.yml", EssentialsXMPP.class); - reloadConfig(); + onReload(); } public boolean sendMessage(final String address, final String message) @@ -166,7 +165,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager } @Override - public final void reloadConfig() + public final void onReload() { LOGGER.removeHandler(this); config.load(); @@ -355,7 +354,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager { try { - parent.getServer().dispatchCommand(Console.getCommandSender(parent.getServer()), message.substring(1)); + parent.getServer().dispatchCommand(parent.getServer().getConsoleSender(), message.substring(1)); } catch (Exception ex) { |