diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 19 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 22 |
2 files changed, 21 insertions, 20 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 243971f07..c44e0480a 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -176,6 +176,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this); pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this); + pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this); if (getSettings().getNetherPortalsEnabled()) { pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this); @@ -375,23 +376,7 @@ public class Essentials extends JavaPlugin implements IEssentials } public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix) - { - if (("msg".equals(commandLabel.toLowerCase()) || "r".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase())) && sender instanceof Player) - { - StringBuilder str = new StringBuilder(); - str.append(commandLabel).append(" "); - for (String a : args) - { - str.append(a).append(" "); - } - for (Player player : getServer().getOnlinePlayers()) - { - if (getUser(player).isSocialSpyEnabled()) - { - player.sendMessage(getUser(sender).getDisplayName() + " : " + str); - } - } - } + { // Allow plugins to override the command via onCommand if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e")) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 56a90dc44..044560bfe 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -4,21 +4,19 @@ import java.util.Iterator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import net.minecraft.server.InventoryPlayer; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Sign; -import org.bukkit.craftbukkit.block.CraftSign; -import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationType; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; @@ -614,4 +612,22 @@ public class EssentialsPlayerListener extends PlayerListener user.getServer().dispatchCommand(user, command); } } + + @Override + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) + { + if (event.isCancelled()) return; + Player commandUser = event.getPlayer(); + String cmd = event.getMessage().toLowerCase(); + if (("msg".equals(cmd) || "r".equals(cmd) || "mail".equals(cmd))) + { + for (Player player : ess.getServer().getOnlinePlayers()) + { + if (ess.getUser(player).isSocialSpyEnabled()) + { + player.sendMessage(ess.getUser(commandUser).getDisplayName() + " : " + cmd); + } + } + } + } } |