Skip to content
Permalink
Browse files

BukkitAdapter: Add Bukkit CommandSender --> WorldEdit Actor (#539)

* BukkitAdapter: Added Bukkit CommandSender --> WorldEdit Actor

* Add a reverse adapter

Co-authored-by: Matthew Miller <mnmiller1@me.com>
  • Loading branch information
JOO200 and me4502 committed Jan 4, 2020
1 parent 5fb91c6 commit 3ed02aa1a831cc960346c9400ac85c37d1580add
@@ -28,6 +28,7 @@
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@@ -51,6 +52,7 @@
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

@@ -119,6 +121,16 @@ public static World adapt(org.bukkit.World world) {
return new BukkitWorld(world);
}

/**
* Create a WorldEdit Actor from a Bukkit CommandSender
*
* @param sender The Bukkit CommandSender
* @return The WorldEdit Actor
*/
public static Actor adapt(CommandSender sender) {
return WorldEditPlugin.getInstance().wrapCommandSender(sender);
}

/**
* Create a WorldEdit Player from a Bukkit Player.
*
@@ -129,6 +141,16 @@ public static BukkitPlayer adapt(Player player) {
return WorldEditPlugin.getInstance().wrapPlayer(player);
}

/**
* Create a Bukkit CommandSender from a WorldEdit Actor.
*
* @param actor The WorldEdit actor
* @return The Bukkit command sender
*/
public static CommandSender adapt(Actor actor) {
return ((BukkitCommandSender) actor).getSender();
}

/**
* Create a Bukkit Player from a WorldEdit Player.
*
@@ -118,6 +118,10 @@ public Locale getLocale() {
return WorldEdit.getInstance().getConfiguration().defaultLocale;
}

public CommandSender getSender() {
return this.sender;
}

@Override
public SessionKey getSessionKey() {
return new SessionKey() {

0 comments on commit 3ed02aa

Please sign in to comment.
You can’t perform that action at this time.