diff --git a/core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index ce3149e2..7f335762 100644 --- a/core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -76,7 +76,7 @@ public class SelectionCommands { } @Command( - aliases = { "/pos1" }, + aliases = { "/pos1", "posa" }, usage = "[coordinates]", desc = "Set position 1", min = 0, @@ -110,7 +110,7 @@ public class SelectionCommands { } @Command( - aliases = { "/pos2" }, + aliases = { "/pos2", "posb" }, usage = "[coordinates]", desc = "Set position 2", min = 0, diff --git a/nukkit/src/main/java/com/boydti/fawe/nukkit/core/NukkitWorldEdit.java b/nukkit/src/main/java/com/boydti/fawe/nukkit/core/NukkitWorldEdit.java index 03a337fe..4ecce879 100644 --- a/nukkit/src/main/java/com/boydti/fawe/nukkit/core/NukkitWorldEdit.java +++ b/nukkit/src/main/java/com/boydti/fawe/nukkit/core/NukkitWorldEdit.java @@ -142,7 +142,6 @@ public class NukkitWorldEdit extends PluginBase { String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); split[0] = cmd.getName(); - CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(Arrays.asList(split))); WorldEdit.getInstance().getEventBus().post(event); diff --git a/nukkit/src/main/java/com/boydti/fawe/nukkit/core/WorldEditListener.java b/nukkit/src/main/java/com/boydti/fawe/nukkit/core/WorldEditListener.java index f800a1b5..2972e00f 100644 --- a/nukkit/src/main/java/com/boydti/fawe/nukkit/core/WorldEditListener.java +++ b/nukkit/src/main/java/com/boydti/fawe/nukkit/core/WorldEditListener.java @@ -27,15 +27,20 @@ import cn.nukkit.event.EventHandler; import cn.nukkit.event.EventPriority; import cn.nukkit.event.Listener; import cn.nukkit.event.block.BlockBreakEvent; +import cn.nukkit.event.player.PlayerChatEvent; import cn.nukkit.event.player.PlayerCommandPreprocessEvent; import cn.nukkit.event.player.PlayerGameModeChangeEvent; import cn.nukkit.event.player.PlayerInteractEvent; +import com.google.common.base.Joiner; import com.sk89q.util.StringUtil; import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldVector; +import com.sk89q.worldedit.event.platform.CommandEvent; +import com.sk89q.worldedit.extension.platform.CommandManager; import com.sk89q.worldedit.internal.LocalWorldAdapter; import com.sk89q.worldedit.world.World; +import java.util.Arrays; /** * Handles all events thrown in relation to a Player @@ -83,7 +88,6 @@ public class WorldEditListener implements Listener { if (!newMessage.equals(event.getMessage())) { event.setMessage(newMessage); plugin.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { if (!event.getMessage().isEmpty()) { plugin.getServer().dispatchCommand(event.getPlayer(), event.getMessage().substring(1)); @@ -94,6 +98,24 @@ public class WorldEditListener implements Listener { } } + @EventHandler(ignoreCancelled = true,priority = EventPriority.LOWEST) + public void onPlayerChat(PlayerChatEvent event) { + String message = event.getMessage(); + if (message.charAt(0) == '.') { + String[] split = event.getMessage().split(" "); + if (split.length > 0) { + split[0] = split[0].substring(1).replace('.', '/'); + CommandManager cmdMan = WorldEdit.getInstance().getPlatformManager().getCommandManager(); + split = cmdMan.commandDetection(split); + CommandEvent cmdEvent = new CommandEvent(plugin.wrapCommandSender(event.getPlayer()), Joiner.on(" ").join(Arrays.asList(split))); + if (cmdMan.getDispatcher().contains(split[0])) { + WorldEdit.getInstance().getEventBus().post(cmdEvent); + event.setCancelled(true); + } + } + } + } + @EventHandler(priority = EventPriority.MONITOR) public void onBlockBreak(BlockBreakEvent event) { final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());