mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Simplify some commands for MCPE
This commit is contained in:
parent
56384ebba1
commit
c9eabe04ec
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user