mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Changed command pipeline to use Actor over LocalPlayer.
This commit is contained in:
@ -19,17 +19,29 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.PlayerNeededException;
|
||||
import com.sk89q.worldedit.WorldEditPermissionException;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BukkitCommandSender extends LocalPlayer {
|
||||
import java.io.File;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
class BukkitCommandSender implements Actor {
|
||||
|
||||
private CommandSender sender;
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||
BukkitCommandSender(WorldEditPlugin plugin, CommandSender sender) {
|
||||
checkNotNull(plugin);
|
||||
checkNotNull(sender);
|
||||
checkArgument(!(sender instanceof Player), "Cannot wrap a player");
|
||||
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
@ -67,6 +79,11 @@ public class BukkitCommandSender extends LocalPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDestroyBedrock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[0];
|
||||
@ -74,31 +91,30 @@ public class BukkitCommandSender extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
if (!plugin.getLocalConfiguration().noOpPermissions && sender.isOp()) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return plugin.getPermissionsResolver().hasPermission(null, sender.getName(), perm);
|
||||
@Override
|
||||
public void checkPermission(String permission) throws WorldEditPermissionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
throw new PlayerNeededException();
|
||||
public File openFileOpenDialog(String[] extensions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
throw new PlayerNeededException();
|
||||
public File openFileSaveDialog(String[] extensions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
throw new PlayerNeededException();
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -106,28 +122,4 @@ public class BukkitCommandSender extends LocalPlayer {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,9 @@ import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.CylinderSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
import org.bukkit.World;
|
||||
@ -214,20 +216,16 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on WorldEdit command.
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd,
|
||||
String commandLabel, String[] args) {
|
||||
|
||||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command cmd, String commandLabel, String[] args) {
|
||||
// Add the command to the array because the underlying command handling
|
||||
// code of WorldEdit expects it
|
||||
String[] split = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, split, 1, args.length);
|
||||
split[0] = "/" + cmd.getName();
|
||||
|
||||
controller.handleCommand(wrapCommandSender(sender), split);
|
||||
CommandEvent event = new CommandEvent(wrapCommandSender(sender), split);
|
||||
getWorldEdit().getEventBus().post(event);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -334,7 +332,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
return new BukkitPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
public LocalPlayer wrapCommandSender(CommandSender sender) {
|
||||
public Actor wrapCommandSender(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
Reference in New Issue
Block a user