Continue the great purge

This commit is contained in:
Matthew Miller 2018-06-16 15:29:48 +10:00
parent c537a2e948
commit 20bf6e079b
63 changed files with 313 additions and 2190 deletions

View File

@ -20,32 +20,31 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
public class BukkitPlayer extends LocalPlayer { import javax.annotation.Nullable;
public class BukkitPlayer extends AbstractPlayerActor {
private Player player; private Player player;
private WorldEditPlugin plugin; private WorldEditPlugin plugin;
public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) { public BukkitPlayer(WorldEditPlugin plugin, Player player) {
this.plugin = plugin; this.plugin = plugin;
this.player = player; this.player = player;
} }
@ -73,9 +72,9 @@ public class BukkitPlayer extends LocalPlayer {
} }
@Override @Override
public WorldVector getPosition() { public com.sk89q.worldedit.util.Location getPosition() {
Location loc = player.getLocation(); Location loc = player.getLocation();
return new WorldVector(BukkitUtil.getLocalWorld(loc.getWorld()), return new com.sk89q.worldedit.util.Location(BukkitUtil.getWorld(loc.getWorld()),
loc.getX(), loc.getY(), loc.getZ()); loc.getX(), loc.getY(), loc.getZ());
} }
@ -146,8 +145,8 @@ public class BukkitPlayer extends LocalPlayer {
} }
@Override @Override
public LocalWorld getWorld() { public World getWorld() {
return BukkitUtil.getLocalWorld(player.getWorld()); return BukkitUtil.getWorld(player.getWorld());
} }
@Override @Override

View File

@ -19,14 +19,17 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.WorldVector;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.sk89q.worldedit.extent.inventory.*;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.ItemType; import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.BlockBagException;
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
import com.sk89q.worldedit.util.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class BukkitPlayerBlockBag extends BlockBag { public class BukkitPlayerBlockBag extends BlockBag {
@ -191,11 +194,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
} }
@Override @Override
public void addSourcePosition(WorldVector pos) { public void addSourcePosition(Location pos) {
} }
@Override @Override
public void addSingleSourcePosition(WorldVector pos) { public void addSingleSourcePosition(Location pos) {
} }
} }

View File

@ -22,8 +22,6 @@ package com.sk89q.worldedit.bukkit;
import com.sk89q.bukkit.util.CommandInfo; import com.sk89q.bukkit.util.CommandInfo;
import com.sk89q.bukkit.util.CommandRegistration; import com.sk89q.bukkit.util.CommandRegistration;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
@ -38,14 +36,15 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class BukkitServerInterface extends ServerInterface implements MultiUserPlatform { import javax.annotation.Nullable;
public class BukkitServerInterface implements MultiUserPlatform {
public Server server; public Server server;
public WorldEditPlugin plugin; public WorldEditPlugin plugin;
private CommandRegistration dynamicCommands; private CommandRegistration dynamicCommands;
@ -86,12 +85,12 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
} }
@Override @Override
public List<LocalWorld> getWorlds() { public List<com.sk89q.worldedit.world.World> getWorlds() {
List<World> worlds = server.getWorlds(); List<World> worlds = server.getWorlds();
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size()); List<com.sk89q.worldedit.world.World> ret = new ArrayList<>(worlds.size());
for (World world : worlds) { for (World world : worlds) {
ret.add(BukkitUtil.getLocalWorld(world)); ret.add(BukkitUtil.getWorld(world));
} }
return ret; return ret;
@ -104,7 +103,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
return player; return player;
} else { } else {
org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName()); org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName());
return bukkitPlayer != null ? new BukkitPlayer(plugin, this, bukkitPlayer) : null; return bukkitPlayer != null ? new BukkitPlayer(plugin, bukkitPlayer) : null;
} }
} }
@ -181,7 +180,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
public Collection<Actor> getConnectedUsers() { public Collection<Actor> getConnectedUsers() {
List<Actor> users = new ArrayList<Actor>(); List<Actor> users = new ArrayList<Actor>();
for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) { for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) {
users.add(new BukkitPlayer(plugin, this, player)); users.add(new BukkitPlayer(plugin, player));
} }
return users; return users;
} }

View File

@ -19,45 +19,34 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import java.util.List; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemID; import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.blocks.SkullBlock; import com.sk89q.worldedit.blocks.SkullBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Item;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockWorldVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.bukkit.entity.BukkitEntity;
import com.sk89q.worldedit.bukkit.entity.BukkitExpOrb;
import com.sk89q.worldedit.bukkit.entity.BukkitItem;
import com.sk89q.worldedit.bukkit.entity.BukkitPainting;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Dye; import org.bukkit.material.Dye;
import java.util.List;
public final class BukkitUtil { public final class BukkitUtil {
private BukkitUtil() { private BukkitUtil() {
} }
public static LocalWorld getLocalWorld(World w) { public static com.sk89q.worldedit.world.World getWorld(World w) {
return new BukkitWorld(w); return new BukkitWorld(w);
} }
@ -69,17 +58,13 @@ public final class BukkitUtil {
return new BlockVector(face.getModX(), face.getModY(), face.getModZ()); return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
} }
public static BlockWorldVector toWorldVector(Block block) {
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
}
public static Vector toVector(org.bukkit.Location loc) { public static Vector toVector(org.bukkit.Location loc) {
return new Vector(loc.getX(), loc.getY(), loc.getZ()); return new Vector(loc.getX(), loc.getY(), loc.getZ());
} }
public static Location toLocation(org.bukkit.Location loc) { public static Location toLocation(org.bukkit.Location loc) {
return new Location( return new Location(
getLocalWorld(loc.getWorld()), getWorld(loc.getWorld()),
new Vector(loc.getX(), loc.getY(), loc.getZ()), new Vector(loc.getX(), loc.getY(), loc.getZ()),
loc.getYaw(), loc.getPitch() loc.getYaw(), loc.getPitch()
); );
@ -89,10 +74,6 @@ public final class BukkitUtil {
return new Vector(vector.getX(), vector.getY(), vector.getZ()); return new Vector(vector.getX(), vector.getY(), vector.getZ());
} }
public static org.bukkit.Location toLocation(WorldVector pt) {
return new org.bukkit.Location(toWorld(pt), pt.getX(), pt.getY(), pt.getZ());
}
public static org.bukkit.Location toLocation(World world, Vector pt) { public static org.bukkit.Location toLocation(World world, Vector pt) {
return new org.bukkit.Location(world, pt.getX(), pt.getY(), pt.getZ()); return new org.bukkit.Location(world, pt.getX(), pt.getY(), pt.getZ());
} }
@ -116,14 +97,6 @@ public final class BukkitUtil {
return players.get(0); return players.get(0);
} }
public static Block toBlock(BlockWorldVector pt) {
return toWorld(pt).getBlockAt(toLocation(pt));
}
public static World toWorld(WorldVector pt) {
return ((BukkitWorld) pt.getWorld()).getWorld();
}
/** /**
* Bukkit's Location class has serious problems with floating point * Bukkit's Location class has serious problems with floating point
* precision. * precision.
@ -139,33 +112,19 @@ public final class BukkitUtil {
public static final double EQUALS_PRECISION = 0.0001; public static final double EQUALS_PRECISION = 0.0001;
public static org.bukkit.Location toLocation(Location location) { public static org.bukkit.Location toLocation(Location location) {
Vector pt = location.getPosition(); Vector pt = location.toVector();
return new org.bukkit.Location( return new org.bukkit.Location(
toWorld(location.getWorld()), toWorld(location.getExtent()),
pt.getX(), pt.getY(), pt.getZ(), pt.getX(), pt.getY(), pt.getZ(),
location.getYaw(), location.getPitch() location.getYaw(), location.getPitch()
); );
} }
public static World toWorld(final LocalWorld world) { public static World toWorld(final Extent world) {
return ((BukkitWorld) world).getWorld(); return ((BukkitWorld) world).getWorld();
} }
public static BukkitEntity toLocalEntity(Entity e) { public static BaseBlock toBlock(com.sk89q.worldedit.world.World world, ItemStack itemStack) throws WorldEditException {
switch (e.getType()) {
case EXPERIENCE_ORB:
return new BukkitExpOrb(toLocation(e.getLocation()), e.getUniqueId(), ((ExperienceOrb)e).getExperience());
case PAINTING:
Painting paint = (Painting) e;
return new BukkitPainting(toLocation(e.getLocation()), paint.getArt(), paint.getFacing(), e.getUniqueId());
case DROPPED_ITEM:
return new BukkitItem(toLocation(e.getLocation()), ((Item)e).getItemStack(), e.getUniqueId());
default:
return new BukkitEntity(toLocation(e.getLocation()), e.getType(), e.getUniqueId());
}
}
public static BaseBlock toBlock(LocalWorld world, ItemStack itemStack) throws WorldEditException {
final int typeId = itemStack.getTypeId(); final int typeId = itemStack.getTypeId();
switch (typeId) { switch (typeId) {

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -33,6 +34,7 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData; import com.sk89q.worldedit.world.registry.WorldData;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -48,7 +50,6 @@ import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
@ -58,13 +59,13 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
public class BukkitWorld extends LocalWorld { public class BukkitWorld extends AbstractWorld {
private static final Logger logger = WorldEdit.logger; private static final Logger logger = WorldEdit.logger;
private static final Map<Integer, Effect> effects = new HashMap<Integer, Effect>(); private static final Map<Integer, Effect> effects = new HashMap<>();
static { static {
for (Effect effect : Effect.values()) { for (Effect effect : Effect.values()) {
effects.put(effect.getId(), effect); effects.put(effect.getId(), effect);
@ -80,7 +81,7 @@ public class BukkitWorld extends LocalWorld {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public BukkitWorld(World world) { public BukkitWorld(World world) {
this.worldRef = new WeakReference<World>(world); this.worldRef = new WeakReference<>(world);
} }
@Override @Override
@ -88,7 +89,7 @@ public class BukkitWorld extends LocalWorld {
World world = getWorld(); World world = getWorld();
List<Entity> ents = world.getEntities(); List<Entity> ents = world.getEntities();
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>(); List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
for (Entity ent : ents) { for (Entity ent : ents) {
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) { if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
entities.add(BukkitAdapter.adapt(ent)); entities.add(BukkitAdapter.adapt(ent));
@ -99,7 +100,7 @@ public class BukkitWorld extends LocalWorld {
@Override @Override
public List<com.sk89q.worldedit.entity.Entity> getEntities() { public List<com.sk89q.worldedit.entity.Entity> getEntities() {
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<com.sk89q.worldedit.entity.Entity>(); List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
for (Entity entity : getWorld().getEntities()) { for (Entity entity : getWorld().getEntities()) {
list.add(BukkitAdapter.adapt(entity)); list.add(BukkitAdapter.adapt(entity));
} }
@ -282,7 +283,7 @@ public class BukkitWorld extends LocalWorld {
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes * An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
*/ */
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping = private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
new EnumMap<TreeGenerator.TreeType, TreeType>(TreeGenerator.TreeType.class); new EnumMap<>(TreeGenerator.TreeType.class);
static { static {
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {

View File

@ -1,48 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.LocalSession;
/**
* @deprecated use the regular API
*/
@Deprecated
public class WorldEditAPI {
private WorldEditPlugin plugin;
public WorldEditAPI(WorldEditPlugin plugin) {
this.plugin = plugin;
}
/**
* Get the session for a player.
*
* @param player the player
* @return a session
*/
public LocalSession getSession(Player player) {
return plugin.getWorldEdit().getSession(
new BukkitPlayer(plugin, plugin.getServerInterface(), player));
}
}

View File

@ -22,10 +22,9 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldVector; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.internal.LocalWorldAdapter; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Event.Result; import org.bukkit.event.Event.Result;
@ -120,18 +119,17 @@ public class WorldEditListener implements Listener {
return; // TODO api needs to be able to get either hand depending on event return; // TODO api needs to be able to get either hand depending on event
// for now just ignore all off hand interacts // for now just ignore all off hand interacts
} }
} catch (NoSuchMethodError ignored) { } catch (NoSuchMethodError | NoSuchFieldError ignored) {
} catch (NoSuchFieldError ignored) {
} }
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer()); final Player player = plugin.wrapPlayer(event.getPlayer());
final World world = player.getWorld(); final World world = player.getWorld();
final WorldEdit we = plugin.getWorldEdit(); final WorldEdit we = plugin.getWorldEdit();
Action action = event.getAction(); Action action = event.getAction();
if (action == Action.LEFT_CLICK_BLOCK) { if (action == Action.LEFT_CLICK_BLOCK) {
final Block clickedBlock = event.getClickedBlock(); final Block clickedBlock = event.getClickedBlock();
final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); final Location pos = new Location(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
if (we.handleBlockLeftClick(player, pos)) { if (we.handleBlockLeftClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);
@ -150,8 +148,7 @@ public class WorldEditListener implements Listener {
} else if (action == Action.RIGHT_CLICK_BLOCK) { } else if (action == Action.RIGHT_CLICK_BLOCK) {
final Block clickedBlock = event.getClickedBlock(); final Block clickedBlock = event.getClickedBlock();
final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(), final Location pos = new Location(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
clickedBlock.getY(), clickedBlock.getZ());
if (we.handleBlockRightClick(player, pos)) { if (we.handleBlockRightClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -19,16 +19,15 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.wepif.PermissionsResolverManager; import com.sk89q.wepif.PermissionsResolverManager;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditOperation;
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException; import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
@ -49,7 +48,6 @@ import com.sk89q.worldedit.regions.Polygonal2DRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Java7Detector; import com.sk89q.worldedit.util.Java7Detector;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -57,7 +55,6 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -69,12 +66,11 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
/** /**
* Plugin for Bukkit. * Plugin for Bukkit.
*/ */
@SuppressWarnings("deprecation")
public class WorldEditPlugin extends JavaPlugin implements TabCompleter { public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName()); private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName());
@ -83,7 +79,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
private BukkitImplAdapter bukkitAdapter; private BukkitImplAdapter bukkitAdapter;
private BukkitServerInterface server; private BukkitServerInterface server;
private final WorldEditAPI api = new WorldEditAPI(this);
private BukkitConfiguration config; private BukkitConfiguration config;
/** /**
@ -279,8 +274,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
* @return a session * @return a session
*/ */
public EditSession createEditSession(Player player) { public EditSession createEditSession(Player player) {
LocalPlayer wePlayer = wrapPlayer(player); com.sk89q.worldedit.entity.Player wePlayer = wrapPlayer(player);
LocalSession session = WorldEdit.getInstance().getSession(wePlayer); LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
@ -297,8 +292,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
* @param editSession an edit session * @param editSession an edit session
*/ */
public void remember(Player player, EditSession editSession) { public void remember(Player player, EditSession editSession) {
LocalPlayer wePlayer = wrapPlayer(player); com.sk89q.worldedit.entity.Player wePlayer = wrapPlayer(player);
LocalSession session = WorldEdit.getInstance().getSession(wePlayer); LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
session.remember(editSession); session.remember(editSession);
editSession.flushQueue(); editSession.flushQueue();
@ -306,38 +301,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
WorldEdit.getInstance().flushBlockBag(wePlayer, editSession); WorldEdit.getInstance().flushBlockBag(wePlayer, editSession);
} }
/**
* Wrap an operation into an EditSession.
*
* @param player a player
* @param op the operation
* @throws Throwable on any error
* @deprecated use the regular API
*/
@Deprecated
public void perform(Player player, WorldEditOperation op) throws Throwable {
LocalPlayer wePlayer = wrapPlayer(player);
LocalSession session = WorldEdit.getInstance().getSession(wePlayer);
EditSession editSession = createEditSession(player);
try {
op.run(session, wePlayer, editSession);
} finally {
remember(player, editSession);
}
}
/**
* Get the API.
*
* @return the API
* @deprecated use the regular API
*/
@Deprecated
public WorldEditAPI getAPI() {
return api;
}
/** /**
* Returns the configuration used by WorldEdit. * Returns the configuration used by WorldEdit.
* *
@ -357,13 +320,13 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
} }
/** /**
* Used to wrap a Bukkit Player as a LocalPlayer. * Used to wrap a Bukkit Player as a WorldEdit Player.
* *
* @param player a player * @param player a player
* @return a wrapped player * @return a wrapped player
*/ */
public BukkitPlayer wrapPlayer(Player player) { public BukkitPlayer wrapPlayer(Player player) {
return new BukkitPlayer(this, this.server, player); return new BukkitPlayer(this, player);
} }
public Actor wrapCommandSender(CommandSender sender) { public Actor wrapCommandSender(CommandSender sender) {
@ -374,15 +337,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
return new BukkitCommandSender(this, sender); return new BukkitCommandSender(this, sender);
} }
/**
* Get the server interface.
*
* @return the server interface
*/
public ServerInterface getServerInterface() {
return server;
}
BukkitServerInterface getInternalPlatform() { BukkitServerInterface getInternalPlatform() {
return server; return server;
} }
@ -411,7 +365,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
} }
LocalSession session = WorldEdit.getInstance().getSession(wrapPlayer(player)); LocalSession session = WorldEdit.getInstance().getSession(wrapPlayer(player));
RegionSelector selector = session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld())); RegionSelector selector = session.getRegionSelector(BukkitUtil.getWorld(player.getWorld()));
try { try {
Region region = selector.getRegion(); Region region = selector.getRegion();
@ -450,7 +404,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
LocalSession session = WorldEdit.getInstance().getSession(wrapPlayer(player)); LocalSession session = WorldEdit.getInstance().getSession(wrapPlayer(player));
RegionSelector sel = selection.getRegionSelector(); RegionSelector sel = selection.getRegionSelector();
session.setRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()), sel); session.setRegionSelector(BukkitUtil.getWorld(player.getWorld()), sel);
session.dispatchCUISelection(wrapPlayer(player)); session.dispatchCUISelection(wrapPlayer(player));
} }

View File

@ -1,50 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit.entity;
import com.sk89q.worldedit.LocalEntity;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import org.bukkit.entity.EntityType;
import java.util.UUID;
public class BukkitEntity extends LocalEntity {
private final EntityType type;
private final UUID entityId;
public BukkitEntity(Location loc, EntityType type, UUID entityId) {
super(loc);
this.type = type;
this.entityId = entityId;
}
public UUID getEntityId() {
return entityId;
}
@Override
public boolean spawn(Location weLoc) {
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
return loc.getWorld().spawn(loc, type.getEntityClass()) != null;
}
}

View File

@ -1,49 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit.entity;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
import java.util.UUID;
public class BukkitExpOrb extends BukkitEntity {
private final int amount;
public BukkitExpOrb(Location loc, UUID entityId, int amount) {
super(loc, EntityType.EXPERIENCE_ORB, entityId);
this.amount = amount;
}
@Override
public boolean spawn(Location weLoc) {
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
ExperienceOrb orb = loc.getWorld().spawn(loc, ExperienceOrb.class);
if (orb != null) {
orb.setExperience(amount);
return true;
}
return false;
}
}

View File

@ -1,43 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit.entity;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
public class BukkitItem extends BukkitEntity {
private final ItemStack stack;
public BukkitItem(Location loc, ItemStack stack, UUID entityId) {
super(loc, EntityType.DROPPED_ITEM, entityId);
this.stack = stack;
}
@Override
public boolean spawn(Location weLoc) {
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
return loc.getWorld().dropItem(loc, stack) != null;
}
}

View File

@ -1,110 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit.entity;
import com.sk89q.worldedit.Location;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import org.bukkit.Art;
import org.bukkit.Bukkit;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Painting;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
public class BukkitPainting extends BukkitEntity {
private static final Logger log = Logger.getLogger(BukkitPainting.class.getCanonicalName());
private static int spawnTask = -1;
private static final Deque<QueuedPaintingSpawn> spawnQueue = new ArrayDeque<QueuedPaintingSpawn>();
private class QueuedPaintingSpawn {
private final Location weLoc;
private QueuedPaintingSpawn(Location weLoc) {
this.weLoc = weLoc;
}
public void spawn() {
spawnRaw(weLoc);
}
}
private static class PaintingSpawnRunnable implements Runnable {
@Override
public void run() {
synchronized (spawnQueue) {
QueuedPaintingSpawn spawn;
while ((spawn = spawnQueue.poll()) != null) {
try {
spawn.spawn();
} catch (Throwable t) {
log.log(Level.WARNING, "Failed to spawn painting", t);
continue;
}
}
spawnTask = -1;
}
}
}
private final Art art;
private final BlockFace facingDirection;
public BukkitPainting(Location loc, Art art, BlockFace facingDirection, UUID entityId) {
super(loc, EntityType.PAINTING, entityId);
this.art = art;
this.facingDirection = facingDirection;
}
/**
* Queue the painting to be spawned at the specified location.
* This operation is delayed so that the block changes that may be applied can be applied before the painting spawn is attempted.
*
* @param weLoc The WorldEdit location
* @return Whether the spawn as successful
*/
@Override
public boolean spawn(Location weLoc) {
synchronized (spawnQueue) {
spawnQueue.add(new QueuedPaintingSpawn(weLoc));
if (spawnTask == -1) {
spawnTask = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), new PaintingSpawnRunnable(), 1L);
}
}
return true;
}
public boolean spawnRaw(Location weLoc) {
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
Painting paint = loc.getWorld().spawn(loc, Painting.class);
if (paint != null) {
paint.setFacingDirection(facingDirection, true);
paint.setArt(art, true);
return true;
}
return false;
}
}

View File

@ -49,7 +49,7 @@ public class CuboidSelection extends RegionSelection {
} }
// Create new selector // Create new selector
CuboidRegionSelector sel = new CuboidRegionSelector(BukkitUtil.getLocalWorld(world)); CuboidRegionSelector sel = new CuboidRegionSelector(BukkitUtil.getWorld(world));
// set up selector // set up selector
sel.selectPrimary(pt1, PermissiveSelectorLimits.getInstance()); sel.selectPrimary(pt1, PermissiveSelectorLimits.getInstance());

View File

@ -23,7 +23,6 @@ import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
import org.bukkit.World; import org.bukkit.World;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.regions.CylinderRegion; import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
@ -42,7 +41,7 @@ public class CylinderSelection extends RegionSelection {
public CylinderSelection(World world, BlockVector2D center, BlockVector2D radius, int minY, int maxY) { public CylinderSelection(World world, BlockVector2D center, BlockVector2D radius, int minY, int maxY) {
super(world); super(world);
LocalWorld lWorld = BukkitUtil.getLocalWorld(world); com.sk89q.worldedit.world.World lWorld = BukkitUtil.getWorld(world);
// Validate input // Validate input
minY = Math.min(Math.max(0, minY), world.getMaxHeight()); minY = Math.min(Math.max(0, minY), world.getMaxHeight());

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.bukkit.selections;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector; import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
import org.bukkit.World; import org.bukkit.World;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
@ -40,7 +39,7 @@ public class Polygonal2DSelection extends RegionSelection {
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) { public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
super(world); super(world);
LocalWorld lWorld = BukkitUtil.getLocalWorld(world); com.sk89q.worldedit.world.World lWorld = BukkitUtil.getWorld(world);
// Validate input // Validate input
minY = Math.min(Math.max(0, minY), world.getMaxHeight()); minY = Math.min(Math.max(0, minY), world.getMaxHeight());

View File

@ -1,124 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector extends WorldVector {
/**
* Construct an instance from another instance.
*
* @param position the position to copy
*/
public BlockWorldVector(WorldVector position) {
super(position.getWorld(), position);
}
/**
* Construct an instance from another instance.
*
* @param world the world
* @param position the position to copy
*/
public BlockWorldVector(LocalWorld world, Vector position) {
super(world, position);
}
/**
* Construct a new instance.
*
* @param world another instance
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(WorldVector world, int x, int y, int z) {
super(world.getWorld(), x, y, z);
}
/**
* Construct a new instance.
*
* @param world another instance
* @param v the other vector
*/
public BlockWorldVector(WorldVector world, Vector v) {
super(world.getWorld(), v.getX(), v.getY(), v.getZ());
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, int x, int y, int z) {
super(world, x, y, z);
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, float x, float y, float z) {
super(world, x, y, z);
}
/**
* Construct a new instance.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public BlockWorldVector(LocalWorld world, double x, double y, double z) {
super(world, x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return (int) other.getX() == (int) this.x && (int) other.getY() == (int) this.y
&& (int) other.getZ() == (int) this.z;
}
@Override
public int hashCode() {
return (Integer.valueOf((int) x).hashCode() << 19) ^
(Integer.valueOf((int) y).hashCode() << 12) ^
Integer.valueOf((int) z).hashCode();
}
}

View File

@ -1,105 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* @deprecated Replace all uses of {@link WorldVector}s with {@link Location}s
*/
@SuppressWarnings("deprecation")
@Deprecated
public class BlockWorldVector2D extends WorldVector2D {
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, double x, double z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, float x, float z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param x the X coordinate
* @param z the Z coordinate
*/
public BlockWorldVector2D(LocalWorld world, int x, int z) {
super(world, x, z);
}
/**
* Construct a new instance.
*
* @param world the world
* @param position a position
*/
public BlockWorldVector2D(LocalWorld world, Vector2D position) {
super(world, position);
}
/**
* Construct a new instance with X and Z set to (0, 0).
*
* @param world the world
*/
public BlockWorldVector2D(LocalWorld world) {
super(world);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {
return false;
}
WorldVector2D other = (WorldVector2D) obj;
return other.getWorld().equals(world)
&& (int) other.getX() == (int) this.x
&& (int) other.getZ() == (int) this.z;
}
@Override
public int hashCode() {
int result = super.hashCode();
long temp;
result = 31 * result + world.hashCode();
temp = Double.doubleToLongBits(x);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}

View File

@ -23,6 +23,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.command.ClipboardCommands; import com.sk89q.worldedit.command.ClipboardCommands;
import com.sk89q.worldedit.command.SchematicCommands; import com.sk89q.worldedit.command.SchematicCommands;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
@ -74,7 +75,7 @@ public class CuboidClipboard {
private Vector offset; private Vector offset;
private Vector origin; private Vector origin;
private Vector size; private Vector size;
private List<CopiedEntity> entities = new ArrayList<CopiedEntity>(); private List<CopiedEntity> entities = new ArrayList<>();
/** /**
* Constructs the clipboard. * Constructs the clipboard.
@ -448,11 +449,14 @@ public class CuboidClipboard {
* @param newOrigin the new origin * @param newOrigin the new origin
* @return a list of entities that were pasted * @return a list of entities that were pasted
*/ */
public LocalEntity[] pasteEntities(Vector newOrigin) { public Entity[] pasteEntities(Vector newOrigin) {
LocalEntity[] entities = new LocalEntity[this.entities.size()]; Entity[] entities = new Entity[this.entities.size()];
for (int i = 0; i < this.entities.size(); ++i) { for (int i = 0; i < this.entities.size(); ++i) {
CopiedEntity copied = this.entities.get(i); CopiedEntity copied = this.entities.get(i);
if (copied.entity.spawn(copied.entity.getPosition().setPosition(copied.relativePosition.add(newOrigin)))) { if (copied.entity.getExtent().createEntity(
copied.entity.getLocation().setPosition(copied.relativePosition.add(newOrigin)),
copied.entity.getState()
) != null) {
entities[i] = copied.entity; entities[i] = copied.entity;
} }
} }
@ -464,7 +468,7 @@ public class CuboidClipboard {
* *
* @param entity the entity * @param entity the entity
*/ */
public void storeEntity(LocalEntity entity) { public void storeEntity(Entity entity) {
this.entities.add(new CopiedEntity(entity)); this.entities.add(new CopiedEntity(entity));
} }
@ -683,12 +687,12 @@ public class CuboidClipboard {
* Stores a copied entity. * Stores a copied entity.
*/ */
private class CopiedEntity { private class CopiedEntity {
private final LocalEntity entity; private final Entity entity;
private final Vector relativePosition; private final Vector relativePosition;
private CopiedEntity(LocalEntity entity) { private CopiedEntity(Entity entity) {
this.entity = entity; this.entity = entity;
this.relativePosition = entity.getPosition().getPosition().subtract(getOrigin()); this.relativePosition = entity.getLocation().toVector().subtract(getOrigin());
} }
} }

View File

@ -132,31 +132,6 @@ public class EditSession implements Extent {
private Mask oldMask; private Mask oldMask;
/**
* Create a new instance.
*
* @param world a world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
*/
@Deprecated
public EditSession(LocalWorld world, int maxBlocks) {
this(world, maxBlocks, null);
}
/**
* Create a new instance.
*
* @param world a world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag the block bag to set, or null to use none
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
*/
@Deprecated
public EditSession(LocalWorld world, int maxBlocks, @Nullable BlockBag blockBag) {
this(WorldEdit.getInstance().getEventBus(), world, maxBlocks, blockBag, new EditSessionEvent(world, null, maxBlocks, null));
}
/** /**
* Construct the object with a maximum number of blocks and a block bag. * Construct the object with a maximum number of blocks and a block bag.
* *

View File

@ -133,66 +133,6 @@ public class EditSessionFactory {
throw new RuntimeException("Method needs to be implemented"); throw new RuntimeException("Method needs to be implemented");
} }
// ------------------------------------------------------------------------
// Methods being deprecated
// ------------------------------------------------------------------------
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks) {
return getEditSession((World) world, maxBlocks);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param player the player that the {@link EditSession} is for
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, Player)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
return getEditSession((World) world, maxBlocks, player);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag an optional {@link BlockBag} to use, otherwise null
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, BlockBag)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) {
return getEditSession((World) world, maxBlocks, blockBag);
}
/**
* Construct an edit session.
*
* @param world the world
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
* @param blockBag an optional {@link BlockBag} to use, otherwise null
* @param player the player that the {@link EditSession} is for
* @return an instance
* @deprecated We are replacing {@link LocalWorld} with {@link World}, so use {@link #getEditSession(World, int, BlockBag, Player)} instead
*/
@Deprecated
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
return getEditSession((World) world, maxBlocks, blockBag, player);
}
/** /**
* Internal factory for {@link EditSession}s. * Internal factory for {@link EditSession}s.
*/ */

View File

@ -1,49 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
/**
* Holds an entity.
*
* @deprecated replaced with the new entity API using {@link Entity} and {@link BaseEntity}
*/
@Deprecated
public abstract class LocalEntity {
private final Location position;
protected LocalEntity(Location position) {
this.position = position;
}
public Location getPosition() {
return position;
}
public boolean spawn() {
return spawn(getPosition());
}
public abstract boolean spawn(Location loc);
}

View File

@ -1,34 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extension.platform.Actor;
/**
* Represents a player that uses WorldEdit.
*
* @deprecated use {@link Actor} (or {@link Player}, etc.) instead (and {@link AbstractPlayerActor} to extend)
*/
@Deprecated
public abstract class LocalPlayer extends AbstractPlayerActor {
}

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.jchronic.Chronic; import com.sk89q.jchronic.Chronic;
import com.sk89q.jchronic.Options; import com.sk89q.jchronic.Options;
import com.sk89q.jchronic.utils.Span; import com.sk89q.jchronic.utils.Span;
@ -32,7 +34,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.internal.cui.CUIRegion; import com.sk89q.worldedit.internal.cui.CUIRegion;
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent; import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
@ -45,7 +46,6 @@ import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.snapshot.Snapshot;
import javax.annotation.Nullable;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
@ -53,7 +53,7 @@ import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
/** /**
* Stores session information. * Stores session information.
@ -70,13 +70,13 @@ public class LocalSession {
// Session related // Session related
private transient RegionSelector selector = new CuboidRegionSelector(); private transient RegionSelector selector = new CuboidRegionSelector();
private transient boolean placeAtPos1 = false; private transient boolean placeAtPos1 = false;
private transient LinkedList<EditSession> history = new LinkedList<EditSession>(); private transient LinkedList<EditSession> history = new LinkedList<>();
private transient int historyPointer = 0; private transient int historyPointer = 0;
private transient ClipboardHolder clipboard; private transient ClipboardHolder clipboard;
private transient boolean toolControl = true; private transient boolean toolControl = true;
private transient boolean superPickaxe = false; private transient boolean superPickaxe = false;
private transient BlockTool pickaxeMode = new SinglePickaxe(); private transient BlockTool pickaxeMode = new SinglePickaxe();
private transient Map<Integer, Tool> tools = new HashMap<Integer, Tool>(); private transient Map<Integer, Tool> tools = new HashMap<>();
private transient int maxBlocksChanged = -1; private transient int maxBlocksChanged = -1;
private transient boolean useInventory; private transient boolean useInventory;
private transient Snapshot snapshot; private transient Snapshot snapshot;
@ -204,17 +204,6 @@ public class LocalSession {
historyPointer = history.size(); historyPointer = history.size();
} }
/**
* Performs an undo.
*
* @param newBlockBag a new block bag
* @param player the player
* @return whether anything was undone
*/
public EditSession undo(@Nullable BlockBag newBlockBag, LocalPlayer player) {
return undo(newBlockBag, (Player) player);
}
/** /**
* Performs an undo. * Performs an undo.
* *
@ -239,17 +228,6 @@ public class LocalSession {
} }
} }
/**
* Performs a redo
*
* @param newBlockBag a new block bag
* @param player the player
* @return whether anything was redone
*/
public EditSession redo(@Nullable BlockBag newBlockBag, LocalPlayer player) {
return redo(newBlockBag, (Player) player);
}
/** /**
* Performs a redo * Performs a redo
* *
@ -293,14 +271,6 @@ public class LocalSession {
setDirty(); setDirty();
} }
/**
* @deprecated Use {@link #getRegionSelector(World)}
*/
@Deprecated
public RegionSelector getRegionSelector(LocalWorld world) {
return getRegionSelector((World) world);
}
/** /**
* Get the region selector for defining the selection. If the selection * Get the region selector for defining the selection. If the selection
* was defined for a different world, the old selection will be discarded. * was defined for a different world, the old selection will be discarded.
@ -317,22 +287,6 @@ public class LocalSession {
return selector; return selector;
} }
/**
* @deprecated use {@link #getRegionSelector(World)}
*/
@Deprecated
public RegionSelector getRegionSelector() {
return selector;
}
/**
* @deprecated use {@link #setRegionSelector(World, RegionSelector)}
*/
@Deprecated
public void setRegionSelector(LocalWorld world, RegionSelector selector) {
setRegionSelector((World) world, selector);
}
/** /**
* Set the region selector. * Set the region selector.
* *
@ -346,24 +300,6 @@ public class LocalSession {
this.selector = selector; this.selector = selector;
} }
/**
* Returns true if the region is fully defined.
*
* @return true if a region selection is defined
*/
@Deprecated
public boolean isRegionDefined() {
return selector.isDefined();
}
/**
* @deprecated use {@link #isSelectionDefined(World)}
*/
@Deprecated
public boolean isSelectionDefined(LocalWorld world) {
return isSelectionDefined((World) world);
}
/** /**
* Returns true if the region is fully defined for the specified world. * Returns true if the region is fully defined for the specified world.
* *
@ -378,22 +314,6 @@ public class LocalSession {
return selector.isDefined(); return selector.isDefined();
} }
/**
* @deprecated use {@link #getSelection(World)}
*/
@Deprecated
public Region getRegion() throws IncompleteRegionException {
return selector.getRegion();
}
/**
* @deprecated use {@link #getSelection(World)}
*/
@Deprecated
public Region getSelection(LocalWorld world) throws IncompleteRegionException {
return getSelection((World) world);
}
/** /**
* Get the selection region. If you change the region, you should * Get the selection region. If you change the region, you should
* call learnRegionChanges(). If the selection is defined in * call learnRegionChanges(). If the selection is defined in
@ -525,7 +445,7 @@ public class LocalSession {
public Vector getPlacementPosition(Player player) throws IncompleteRegionException { public Vector getPlacementPosition(Player player) throws IncompleteRegionException {
checkNotNull(player); checkNotNull(player);
if (!placeAtPos1) { if (!placeAtPos1) {
return player.getBlockIn(); return player.getBlockIn().toVector();
} }
return selector.getPrimaryPosition(); return selector.getPrimaryPosition();
@ -850,21 +770,12 @@ public class LocalSession {
} }
} }
/**
* @deprecated use {@link #createEditSession(Player)}
*/
@Deprecated
public EditSession createEditSession(LocalPlayer player) {
return createEditSession((Player) player);
}
/** /**
* Construct a new edit session. * Construct a new edit session.
* *
* @param player the player * @param player the player
* @return an edit session * @return an edit session
*/ */
@SuppressWarnings("deprecation")
public EditSession createEditSession(Player player) { public EditSession createEditSession(Player player) {
checkNotNull(player); checkNotNull(player);

View File

@ -1,83 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World;
/**
* A legacy abstract implementation of {@link World}. New implementations
* should use {@link AbstractWorld} when possible.
*
* @deprecated Replace with {@link World} wherever appropriate
*/
@Deprecated
public abstract class LocalWorld extends AbstractWorld {
@Override
public BaseBlock getLazyBlock(Vector position) {
return getBlock(position);
}
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) throws MaxChangedBlocksException {
switch (type) {
case BIG_TREE:
return generateBigTree(editSession, pt);
case BIRCH:
return generateBirchTree(editSession, pt);
case REDWOOD:
return generateRedwoodTree(editSession, pt);
case TALL_REDWOOD:
return generateTallRedwoodTree(editSession, pt);
default:
case TREE:
return generateTree(editSession, pt);
}
}
@Override
public boolean generateTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateBigTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateBirchTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
@Override
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return false;
}
}

View File

@ -1,129 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class Location {
private final LocalWorld world;
private final Vector position;
private final float yaw;
private final float pitch;
public Location(LocalWorld world, Vector position) {
this(world, position, 0, 0);
}
public Location(LocalWorld world, Vector position, float yaw, float pitch) {
this.world = world;
this.position = position;
this.yaw = yaw;
this.pitch = pitch;
}
public LocalWorld getWorld() {
return world;
}
public Vector getPosition() {
return position;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
public Location setAngles(float yaw, float pitch) {
return new Location(world, position, yaw, pitch);
}
public Location setPosition(Vector position) {
return new Location(world, position, yaw, pitch);
}
public Location add(Vector other) {
return setPosition(position.add(other));
}
public Location add(double x, double y, double z) {
return setPosition(position.add(x, y, z));
}
public Vector getDirection() {
final double yawRadians = Math.toRadians(yaw);
final double pitchRadians = Math.toRadians(pitch);
final double y = -Math.sin(pitchRadians);
final double h = Math.cos(pitchRadians);
final double x = -h * Math.sin(yawRadians);
final double z = h * Math.cos(yawRadians);
return new Vector(x, y, z);
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Location))
return false;
Location location = (Location) obj;
if (!world.equals(location.world))
return false;
if (!position.equals(location.position))
return false;
return true;
}
@Override
public int hashCode() {
return position.hashCode() + 19 * world.hashCode();
}
@Override
public String toString() {
return "World: " + world.getName() + ", Coordinates: " + position
+ ", Yaw: " + yaw + ", Pitch: " + pitch;
}
public static Location fromLookAt(LocalWorld world, Vector start, Vector lookAt) {
final Vector diff = lookAt.subtract(start);
return fromEye(world, start, diff);
}
public static Location fromEye(LocalWorld world, Vector start, Vector eye) {
final double eyeX = eye.getX();
final double eyeZ = eye.getZ();
final float yaw = (float) Math.toDegrees(Math.atan2(-eyeX, eyeZ));
final double length = Math.sqrt(eyeX * eyeX + eyeZ * eyeZ);
final float pitch = (float) Math.toDegrees(Math.atan2(-eye.getY(), length));
return new Location(world, start, yaw, pitch);
}
}

View File

@ -1,90 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.util.Direction;
/**
* Represents the adjacency of one vector to another. Works similarly to
* Bukkit's BlockFace class.
*
* @deprecated to be replaced with {@link Direction}
*/
@Deprecated
public enum VectorFace {
NORTH(-1, 0, 0),
EAST(0, 0, -1),
SOUTH(1, 0, 0),
WEST(0, 0, 1),
UP(0, 1, 0),
DOWN(0, -1, 0),
NORTH_EAST(NORTH, EAST),
NORTH_WEST(NORTH, WEST),
SOUTH_EAST(SOUTH, EAST),
SOUTH_WEST(SOUTH, WEST),
ABOVE_NORTH(UP, NORTH),
BELOW_NORTH(DOWN, NORTH),
ABOVE_SOUTH(UP, SOUTH),
BELOW_SOUTH(DOWN, SOUTH),
ABOVE_WEST(UP, WEST),
BELOW_WEST(DOWN, WEST),
ABOVE_EAST(UP, EAST),
BELOW_EAST(DOWN, EAST),
SELF(0, 0, 0);
private final int modX;
private final int modY;
private final int modZ;
private VectorFace(final int modX, final int modY, final int modZ) {
this.modX = modX;
this.modY = modY;
this.modZ = modZ;
}
private VectorFace(VectorFace face1, VectorFace face2) {
this.modX = face1.getModX() + face2.getModX();
this.modY = face1.getModY() + face2.getModY();
this.modZ = face1.getModZ() + face2.getModZ();
}
public int getModX() {
return modX;
}
public int getModZ() {
return modZ;
}
public int getModY() {
return modY;
}
public static VectorFace fromMods(int modX2, int modY2, int modZ2) {
for (VectorFace face : values()) {
if (face.getModX() == modX2
&& face.getModY() == modY2
&& face.getModZ() == modZ2) {
return face;
}
}
return VectorFace.SELF;
}
}

View File

@ -42,6 +42,7 @@ import com.sk89q.worldedit.scripting.CraftScriptEngine;
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine; import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException; import com.sk89q.worldedit.util.io.file.FileSelectionAbortedException;
import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.util.io.file.FilenameException;
@ -655,8 +656,8 @@ public class WorldEdit {
* @param clicked the clicked block * @param clicked the clicked block
* @return false if you want the action to go through * @return false if you want the action to go through
*/ */
public boolean handleBlockRightClick(Player player, WorldVector clicked) { public boolean handleBlockRightClick(Player player, Location clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), OPEN); BlockInteractEvent event = new BlockInteractEvent(player, clicked, OPEN);
getEventBus().post(event); getEventBus().post(event);
return event.isCancelled(); return event.isCancelled();
} }
@ -668,8 +669,8 @@ public class WorldEdit {
* @param clicked the clicked block * @param clicked the clicked block
* @return false if you want the action to go through * @return false if you want the action to go through
*/ */
public boolean handleBlockLeftClick(Player player, WorldVector clicked) { public boolean handleBlockLeftClick(Player player, Location clicked) {
BlockInteractEvent event = new BlockInteractEvent(player, clicked.toLocation(), HIT); BlockInteractEvent event = new BlockInteractEvent(player, clicked, HIT);
getEventBus().post(event); getEventBus().post(event);
return event.isCancelled(); return event.isCancelled();
} }

View File

@ -1,33 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* Represents a WorldEdit operation.
*
* @deprecated This will be removed with no direct replacement. Please use the
* WorldEdit API.
*/
@Deprecated
public abstract class WorldEditOperation {
public abstract void run(LocalSession session, LocalPlayer player, EditSession editSession) throws Throwable;
}

View File

@ -1,146 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.world.World;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVector extends Vector {
private LocalWorld world;
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, double x, double y, double z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, int x, int y, int z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
*/
public WorldVector(LocalWorld world, float x, float y, float z) {
super(x, y, z);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
* @param other the position to copy
*/
public WorldVector(LocalWorld world, Vector other) {
super(other);
this.world = world;
}
/**
* Construct the Vector object.
*
* @param world a world
*/
public WorldVector(LocalWorld world) {
super();
this.world = world;
}
/**
* Construct the Vector object.
*
* @param location the location
*/
public WorldVector(com.sk89q.worldedit.util.Location location) {
this(LocalWorldAdapter.adapt((World) location.getExtent()), location.getX(), location.getY(), location.getZ());
}
/**
* Get the world.
*
* @return the world
*/
public LocalWorld getWorld() {
return world;
}
/**
* Get a block point from a point.
*
* @param world a world
* @param x the X coordinate
* @param y the Y coordinate
* @param z the Z coordinate
* @return point
*/
public static WorldVector toBlockPoint(LocalWorld world, double x, double y,
double z) {
return new WorldVector(world, (int) Math.floor(x),
(int) Math.floor(y),
(int) Math.floor(z));
}
/**
* Gets a BlockVector version.
*
* @return BlockWorldVector
*/
public BlockWorldVector toWorldBlockVector() {
return new BlockWorldVector(this);
}
/**
* Return this object as a new preferred {@code Location}
* object.
*
* @return a new location object
*/
public com.sk89q.worldedit.util.Location toLocation() {
return new com.sk89q.worldedit.util.Location(getWorld(), this);
}
}

View File

@ -1,81 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVector2D extends Vector2D {
protected LocalWorld world;
public WorldVector2D(LocalWorld world) {
super();
this.world = world;
}
public WorldVector2D(LocalWorld world, double x, double z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, float x, float z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, int x, int z) {
super(x, z);
this.world = world;
}
public WorldVector2D(LocalWorld world, Vector2D pt) {
super(pt);
this.world = world;
}
public LocalWorld getWorld() {
return world;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof WorldVector2D)) {
return false;
}
WorldVector2D other = (WorldVector2D) obj;
return other.world.equals(world) && other.x == this.x
&& other.z == this.z;
}
/**
* Gets the hash code.
*
* @return hash code
*/
@Override
public int hashCode() {
return (world.hashCode() >> 7) ^
((int) (Double.doubleToLongBits(x) ^ (Double.doubleToLongBits(x) >>> 32)) >> 13) ^
(int) (Double.doubleToLongBits(z) ^ (Double.doubleToLongBits(z) >>> 32));
}
}

View File

@ -1,107 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
/**
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
*/
@Deprecated
public class WorldVectorFace extends WorldVector {
private VectorFace face;
public WorldVectorFace(LocalWorld world, double x, double y, double z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, int x, int y, int z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, float x, float y, float z, VectorFace face) {
super(world, x, y, z);
this.face = face;
}
public WorldVectorFace(LocalWorld world, Vector pt, VectorFace face) {
super(world, pt);
this.face = face;
}
public WorldVectorFace(LocalWorld world, VectorFace face) {
super(world);
this.face = face;
}
/**
* Get the face.
*
* @return the face
*/
public VectorFace getFace() {
return face;
}
/**
* Get the WorldVector adjacent to this WorldVectorFace.
*
* @return the face vector
*/
public WorldVector getFaceVector() {
return new WorldVector(getWorld(),
getBlockX() - face.getModX(),
getBlockY() - face.getModY(),
getBlockZ() - face.getModZ());
}
/**
* Get a WorldVectorFace by comparing two vectors. Note that they need not be
* adjacent, as only the directions, not distance, will be taken into account.
*
* @param world the world in which the resulting vector should lie
* @param vector the original vector
* @param face the direction in which the face should lie
* @return a face
*/
public static WorldVectorFace getWorldVectorFace(LocalWorld world, Vector vector, Vector face) {
if (vector == null || face == null) return null;
// check which direction the face is from the vector
final int x1 = vector.getBlockX();
final int y1 = vector.getBlockY();
final int z1 = vector.getBlockZ();
int modX = x1 - face.getBlockX();
int modY = y1 - face.getBlockY();
int modZ = z1 - face.getBlockZ();
if (modX > 0) modX = 1;
else if (modX < 0) modX = -1;
else modX = 0;
if (modY > 0) modY = 1;
else if (modY < 0) modY = -1;
else modY = 0;
if (modZ > 0) modZ = 1;
else if (modZ < 0) modZ = -1;
else modZ = 0;
// construct new vector
return new WorldVectorFace(world, x1, y1, z1, VectorFace.fromMods(modX, modY, modZ));
}
}

View File

@ -54,11 +54,6 @@ public class ItemType {
} }
} }
@Deprecated
public com.sk89q.worldedit.blocks.ItemType getLegacyType() {
return com.sk89q.worldedit.blocks.ItemType.fromID(getLegacyId());
}
@Override @Override
public int hashCode() { public int hashCode() {
return this.id.hashCode(); return this.id.hashCode();

View File

@ -41,6 +41,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.FlatRegion; import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions; import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
@ -125,22 +126,22 @@ public class BiomeCommands {
@CommandPermissions("worldedit.biome.info") @CommandPermissions("worldedit.biome.info")
public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void biomeInfo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry(); BiomeRegistry biomeRegistry = player.getWorld().getWorldData().getBiomeRegistry();
Set<BaseBiome> biomes = new HashSet<BaseBiome>(); Set<BaseBiome> biomes = new HashSet<>();
String qualifier; String qualifier;
if (args.hasFlag('t')) { if (args.hasFlag('t')) {
Vector blockPosition = player.getBlockTrace(300); Location blockPosition = player.getBlockTrace(300);
if (blockPosition == null) { if (blockPosition == null) {
player.printError("No block in sight!"); player.printError("No block in sight!");
return; return;
} }
BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector2D()); BaseBiome biome = player.getWorld().getBiome(blockPosition.toVector().toVector2D());
biomes.add(biome); biomes.add(biome);
qualifier = "at line of sight point"; qualifier = "at line of sight point";
} else if (args.hasFlag('p')) { } else if (args.hasFlag('p')) {
BaseBiome biome = player.getWorld().getBiome(player.getPosition().toVector2D()); BaseBiome biome = player.getWorld().getBiome(player.getPosition().toVector().toVector2D());
biomes.add(biome); biomes.add(biome);
qualifier = "at your position"; qualifier = "at your position";
@ -191,7 +192,7 @@ public class BiomeCommands {
Mask2D mask2d = mask != null ? mask.toMask2D() : null; Mask2D mask2d = mask != null ? mask.toMask2D() : null;
if (atPosition) { if (atPosition) {
region = new CuboidRegion(player.getPosition(), player.getPosition()); region = new CuboidRegion(player.getPosition().toVector(), player.getPosition().toVector());
} else { } else {
region = session.getSelection(world); region = session.getSelection(world);
} }

View File

@ -26,6 +26,7 @@ import com.sk89q.minecraft.util.commands.Logging;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.math.MathUtils; import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.storage.LegacyChunkStore; import com.sk89q.worldedit.world.storage.LegacyChunkStore;
import com.sk89q.worldedit.world.storage.McRegionChunkStore; import com.sk89q.worldedit.world.storage.McRegionChunkStore;
@ -58,7 +59,7 @@ public class ChunkCommands {
) )
@CommandPermissions("worldedit.chunkinfo") @CommandPermissions("worldedit.chunkinfo")
public void chunkInfo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void chunkInfo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockIn(); Location pos = player.getBlockIn();
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0); int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0); int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);

View File

@ -28,8 +28,8 @@ import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -161,7 +161,7 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.jumpto.command") @CommandPermissions("worldedit.navigation.jumpto.command")
public void jumpTo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void jumpTo(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
WorldVector pos = player.getSolidBlockTrace(300); Location pos = player.getSolidBlockTrace(300);
if (pos != null) { if (pos != null) {
player.findFreePosition(pos); player.findFreePosition(pos);
player.print("Poof!"); player.print("Poof!");

View File

@ -49,6 +49,7 @@ import com.sk89q.worldedit.regions.selector.RegionSelectorType;
import com.sk89q.worldedit.regions.selector.SphereRegionSelector; import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder; import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.StyledFragment;
@ -85,12 +86,12 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void pos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos; Location pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(","); String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2])); pos = new Location(player.getWorld(), Integer.parseInt(coords[0]), Integer.parseInt(coords[1]), Integer.parseInt(coords[2]));
} else { } else {
player.printError("Invalid coordinates " + args.getString(0)); player.printError("Invalid coordinates " + args.getString(0));
return; return;
@ -99,13 +100,13 @@ public class SelectionCommands {
pos = player.getBlockIn(); pos = player.getBlockIn();
} }
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set."); player.printError("Position already set.");
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos); .explainPrimarySelection(player, session, pos.toVector());
} }
@Command( @Command(
@ -119,11 +120,11 @@ public class SelectionCommands {
@CommandPermissions("worldedit.selection.pos") @CommandPermissions("worldedit.selection.pos")
public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void pos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos; Location pos;
if (args.argsLength() == 1) { if (args.argsLength() == 1) {
if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) { if (args.getString(0).matches("-?\\d+,-?\\d+,-?\\d+")) {
String[] coords = args.getString(0).split(","); String[] coords = args.getString(0).split(",");
pos = new Vector(Integer.parseInt(coords[0]), pos = new Location(player.getWorld(), Integer.parseInt(coords[0]),
Integer.parseInt(coords[1]), Integer.parseInt(coords[1]),
Integer.parseInt(coords[2])); Integer.parseInt(coords[2]));
} else { } else {
@ -134,13 +135,13 @@ public class SelectionCommands {
pos = player.getBlockIn(); pos = player.getBlockIn();
} }
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set."); player.printError("Position already set.");
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(player, session, pos.toVector());
} }
@Command( @Command(
@ -152,17 +153,17 @@ public class SelectionCommands {
) )
@CommandPermissions("worldedit.selection.hpos") @CommandPermissions("worldedit.selection.hpos")
public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void hpos1(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300); Location pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos, ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set."); player.printError("Position already set.");
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos); .explainPrimarySelection(player, session, pos.toVector());
} else { } else {
player.printError("No block in sight!"); player.printError("No block in sight!");
} }
@ -177,17 +178,17 @@ public class SelectionCommands {
) )
@CommandPermissions("worldedit.selection.hpos") @CommandPermissions("worldedit.selection.hpos")
public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { public void hpos2(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
Vector pos = player.getBlockTrace(300); Location pos = player.getBlockTrace(300);
if (pos != null) { if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos, ActorSelectorLimits.forActor(player))) { if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toVector(), ActorSelectorLimits.forActor(player))) {
player.printError("Position already set."); player.printError("Position already set.");
return; return;
} }
session.getRegionSelector(player.getWorld()) session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos); .explainSecondarySelection(player, session, pos.toVector());
} else { } else {
player.printError("No block in sight!"); player.printError("No block in sight!");
} }
@ -241,7 +242,7 @@ public class SelectionCommands {
min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector()); min2D = (args.hasFlag('c')) ? pos : ChunkStore.toChunk(pos.toVector());
} else { } else {
// use player loc // use player loc
min2D = ChunkStore.toChunk(player.getBlockIn()); min2D = ChunkStore.toChunk(player.getBlockIn().toVector());
} }
min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16); min = new Vector(min2D.getBlockX() * 16, 0, min2D.getBlockZ() * 16);

View File

@ -19,11 +19,12 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.command.tool.brush.SphereBrush; import com.sk89q.worldedit.command.tool.brush.SphereBrush;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
@ -34,11 +35,10 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Builds a shape at the place being looked at. * Builds a shape at the place being looked at.
*/ */
@ -162,7 +162,7 @@ public class BrushTool implements TraceTool {
@Override @Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVector target = null; Location target = null;
target = player.getBlockTrace(getRange(), true); target = player.getBlockTrace(getRange(), true);
if (target == null) { if (target == null) {
@ -189,7 +189,7 @@ public class BrushTool implements TraceTool {
} }
try { try {
brush.build(editSession, target, material, size); brush.build(editSession, target.toVector(), material, size);
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached."); player.printError("Max blocks change limit reached.");
} finally { } finally {

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits; import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Location;
/** /**
* A wand that can be used at a distance. * A wand that can be used at a distance.
@ -43,12 +44,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
@Override @Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) { if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player); Location target = getTarget(player);
if (target == null) return true; if (target == null) return true;
RegionSelector selector = session.getRegionSelector(player.getWorld()); RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectPrimary(target, ActorSelectorLimits.forActor(player))) { if (selector.selectPrimary(target.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainPrimarySelection(player, session, target); selector.explainPrimarySelection(player, session, target.toVector());
} }
return true; return true;
@ -60,12 +61,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
@Override @Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) { if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player); Location target = getTarget(player);
if (target == null) return true; if (target == null) return true;
RegionSelector selector = session.getRegionSelector(player.getWorld()); RegionSelector selector = session.getRegionSelector(player.getWorld());
if (selector.selectSecondary(target, ActorSelectorLimits.forActor(player))) { if (selector.selectSecondary(target.toVector(), ActorSelectorLimits.forActor(player))) {
selector.explainSecondarySelection(player, session, target); selector.explainSecondarySelection(player, session, target.toVector());
} }
return true; return true;
@ -73,8 +74,8 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
return false; return false;
} }
public WorldVector getTarget(Player player) { public Location getTarget(Player player) {
WorldVector target = null; Location target;
if (this.range > -1) { if (this.range > -1) {
target = player.getBlockTrace(getRange(), true); target = player.getBlockTrace(getRange(), true);
} else { } else {

View File

@ -19,20 +19,24 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
/** /**
* A tool that can place (or remove) blocks at a distance. * A tool that can place (or remove) blocks at a distance.
*/ */
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool { public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
BaseBlock primary; private BaseBlock primary;
BaseBlock secondary; private BaseBlock secondary;
public LongRangeBuildTool(BaseBlock primary, BaseBlock secondary) { public LongRangeBuildTool(BaseBlock primary, BaseBlock secondary) {
super("worldedit.tool.lrbuild"); super("worldedit.tool.lrbuild");
@ -47,14 +51,14 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
@Override @Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) { public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player); Location pos = getTargetFace(player);
if (pos == null) return false; if (pos == null) return false;
EditSession eS = session.createEditSession(player); EditSession eS = session.createEditSession(player);
try { try {
if (secondary.getType().getLegacyId() == BlockID.AIR) { if (secondary.getType() == BlockTypes.AIR) {
eS.setBlock(pos, secondary); eS.setBlock(pos.toVector(), secondary);
} else { } else {
eS.setBlock(pos.getFaceVector(), secondary); eS.setBlock(pos.getDirection(), secondary);
} }
return true; return true;
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
@ -66,14 +70,14 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
@Override @Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player); Location pos = getTargetFace(player);
if (pos == null) return false; if (pos == null) return false;
EditSession eS = session.createEditSession(player); EditSession eS = session.createEditSession(player);
try { try {
if (primary.getType().getLegacyId() == BlockID.AIR) { if (primary.getType() == BlockTypes.AIR) {
eS.setBlock(pos, primary); eS.setBlock(pos.toVector(), primary);
} else { } else {
eS.setBlock(pos.getFaceVector(), primary); eS.setBlock(pos.getDirection(), primary);
} }
return true; return true;
} catch (MaxChangedBlocksException e) { } catch (MaxChangedBlocksException e) {
@ -82,9 +86,8 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
return false; return false;
} }
public WorldVectorFace getTargetFace(Player player) { public Location getTargetFace(Player player) {
WorldVectorFace target = null; Location target = player.getBlockTraceFace(getRange(), true);
target = player.getBlockTraceFace(getRange(), true);
if (target == null) { if (target == null) {
player.printError("No block in sight!"); player.printError("No block in sight!");

View File

@ -21,15 +21,14 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.math.convolution.HeightMap; import com.sk89q.worldedit.math.convolution.HeightMap;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.math.convolution.GaussianKernel; import com.sk89q.worldedit.math.convolution.GaussianKernel;
import com.sk89q.worldedit.math.convolution.HeightMapFilter; import com.sk89q.worldedit.math.convolution.HeightMapFilter;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
public class SmoothBrush implements Brush { public class SmoothBrush implements Brush {
@ -47,9 +46,9 @@ public class SmoothBrush implements Brush {
@Override @Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException { public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
WorldVector min = new WorldVector(LocalWorldAdapter.adapt(editSession.getWorld()), position.subtract(size, size, size)); Location min = new Location(editSession.getWorld(), position.subtract(size, size, size));
Vector max = position.add(size, size + 10, size); Vector max = position.add(size, size + 10, size);
Region region = new CuboidRegion(editSession.getWorld(), min, max); Region region = new CuboidRegion(editSession.getWorld(), min.toVector(), max);
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly); HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0)); HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations); heightMap.applyFilter(filter, iterations);

View File

@ -22,11 +22,10 @@ package com.sk89q.worldedit.entity;
import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.WorldVectorFace;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
/** /**
@ -100,14 +99,14 @@ public interface Player extends Entity, Actor {
* *
* @param searchPos search position * @param searchPos search position
*/ */
void findFreePosition(WorldVector searchPos); void findFreePosition(Location searchPos);
/** /**
* Set the actor on the ground. * Set the actor on the ground.
* *
* @param searchPos The location to start searching from * @param searchPos The location to start searching from
*/ */
void setOnGround(WorldVector searchPos); void setOnGround(Location searchPos);
/** /**
* Find a position for the player to stand that is not inside a block. * Find a position for the player to stand that is not inside a block.
@ -179,14 +178,14 @@ public interface Player extends Entity, Actor {
* *
* @return point * @return point
*/ */
WorldVector getBlockIn(); Location getBlockIn();
/** /**
* Get the point of the block that is being stood upon. * Get the point of the block that is being stood upon.
* *
* @return point * @return point
*/ */
WorldVector getBlockOn(); Location getBlockOn();
/** /**
* Get the point of the block being looked at. May return null. * Get the point of the block being looked at. May return null.
@ -196,7 +195,7 @@ public interface Player extends Entity, Actor {
* @param useLastBlock try to return the last valid air block found * @param useLastBlock try to return the last valid air block found
* @return point * @return point
*/ */
WorldVector getBlockTrace(int range, boolean useLastBlock); Location getBlockTrace(int range, boolean useLastBlock);
/** /**
* Get the face that the player is looking at. * Get the face that the player is looking at.
@ -205,7 +204,7 @@ public interface Player extends Entity, Actor {
* @param useLastBlock try to return the last valid air block found * @param useLastBlock try to return the last valid air block found
* @return a face * @return a face
*/ */
WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock); Location getBlockTraceFace(int range, boolean useLastBlock);
/** /**
* Get the point of the block being looked at. May return null. * Get the point of the block being looked at. May return null.
@ -213,7 +212,7 @@ public interface Player extends Entity, Actor {
* @param range How far to checks for blocks * @param range How far to checks for blocks
* @return point * @return point
*/ */
WorldVector getBlockTrace(int range); Location getBlockTrace(int range);
/** /**
* Get the point of the block being looked at. May return null. * Get the point of the block being looked at. May return null.
@ -221,7 +220,7 @@ public interface Player extends Entity, Actor {
* @param range How far to checks for blocks * @param range How far to checks for blocks
* @return point * @return point
*/ */
WorldVector getSolidBlockTrace(int range); Location getSolidBlockTrace(int range);
/** /**
* Get the player's cardinal direction (N, W, NW, etc.). May return null. * Get the player's cardinal direction (N, W, NW, etc.). May return null.
@ -238,8 +237,7 @@ public interface Player extends Entity, Actor {
* @return the actor's position * @return the actor's position
* @deprecated use {@link #getLocation()} * @deprecated use {@link #getLocation()}
*/ */
@Deprecated Location getPosition();
WorldVector getPosition();
/** /**
* Get the player's view pitch in degrees. * Get the player's view pitch in degrees.

View File

@ -19,24 +19,21 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.BlockWorldVector;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.PlayerDirection;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.WorldVectorFace;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemID; import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.util.auth.AuthorizationException;
import java.io.File; import java.io.File;
@ -93,8 +90,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
} }
@Override @Override
public void findFreePosition(WorldVector searchPos) { public void findFreePosition(Location searchPos) {
World world = searchPos.getWorld(); Extent world = searchPos.getExtent();
int x = searchPos.getBlockX(); int x = searchPos.getBlockX();
int y = Math.max(0, searchPos.getBlockY()); int y = Math.max(0, searchPos.getBlockY());
int origY = y; int origY = y;
@ -102,7 +99,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0; byte free = 0;
while (y <= world.getMaxY() + 2) { while (y <= world.getMinimumPoint().getBlockY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free; ++free;
} else { } else {
@ -112,8 +109,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
if (free == 2) { if (free == 2) {
if (y - 1 != origY) { if (y - 1 != origY) {
final Vector pos = new Vector(x, y - 2, z); final Vector pos = new Vector(x, y - 2, z);
final int id = world.getBlockType(pos); final int id = world.getBlock(pos).getId();
final int data = world.getBlockData(pos); final int data = world.getBlock(pos).getData();
setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(id, data), z + 0.5)); setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(id, data), z + 0.5));
} }
@ -125,16 +122,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
} }
@Override @Override
public void setOnGround(WorldVector searchPos) { public void setOnGround(Location searchPos) {
World world = searchPos.getWorld(); Extent world = searchPos.getExtent();
int x = searchPos.getBlockX(); int x = searchPos.getBlockX();
int y = Math.max(0, searchPos.getBlockY()); int y = Math.max(0, searchPos.getBlockY());
int z = searchPos.getBlockZ(); int z = searchPos.getBlockZ();
while (y >= 0) { while (y >= 0) {
final Vector pos = new Vector(x, y, z); final Vector pos = new Vector(x, y, z);
final int id = world.getBlockType(pos); final int id = world.getBlock(pos).getId();
final int data = world.getBlockData(pos); final int data = world.getBlock(pos).getData();
if (!BlockType.canPassThrough(id, data)) { if (!BlockType.canPassThrough(id, data)) {
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5)); setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id, data), z + 0.5));
return; return;
@ -151,16 +148,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean ascendLevel() { public boolean ascendLevel() {
final WorldVector pos = getBlockIn(); final Location pos = getBlockIn();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY()); int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
final World world = pos.getWorld(); final Extent world = pos.getExtent();
byte free = 0; byte free = 0;
byte spots = 0; byte spots = 0;
while (y <= world.getMaxY() + 2) { while (y <= world.getMaximumPoint().getY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free; ++free;
} else { } else {
@ -192,11 +189,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean descendLevel() { public boolean descendLevel() {
final WorldVector pos = getBlockIn(); final Location pos = getBlockIn();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY() - 1); int y = Math.max(0, pos.getBlockY() - 1);
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
final World world = pos.getWorld(); final Extent world = pos.getExtent();
byte free = 0; byte free = 0;
@ -242,19 +239,19 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean ascendToCeiling(int clearance, boolean alwaysGlass) { public boolean ascendToCeiling(int clearance, boolean alwaysGlass) {
Vector pos = getBlockIn(); Location pos = getBlockIn();
int x = pos.getBlockX(); int x = pos.getBlockX();
int initialY = Math.max(0, pos.getBlockY()); int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 2); int y = Math.max(0, pos.getBlockY() + 2);
int z = pos.getBlockZ(); int z = pos.getBlockZ();
World world = getPosition().getWorld(); Extent world = getPosition().getExtent();
// No free space above // No free space above
if (world.getBlockType(new Vector(x, y, z)) != 0) { if (world.getBlock(new Vector(x, y, z)).getId() != 0) {
return false; return false;
} }
while (y <= world.getMaxY()) { while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling! // Found a ceiling!
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
int platformY = Math.max(initialY, y - 3 - clearance); int platformY = Math.max(initialY, y - 3 - clearance);
@ -275,15 +272,15 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) { public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Vector pos = getBlockIn(); final Location pos = getBlockIn();
final int x = pos.getBlockX(); final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY()); final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1); int y = Math.max(0, pos.getBlockY() + 1);
final int z = pos.getBlockZ(); final int z = pos.getBlockZ();
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance); final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
final World world = getPosition().getWorld(); final Extent world = getPosition().getExtent();
while (y <= world.getMaxY() + 2) { while (y <= world.getMaximumPoint().getY() + 2) {
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) { if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
break; // Hit something break; // Hit something
} else if (y > maxY + 1) { } else if (y > maxY + 1) {
@ -301,43 +298,43 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void floatAt(int x, int y, int z, boolean alwaysGlass) { public void floatAt(int x, int y, int z, boolean alwaysGlass) {
getPosition().getWorld().setBlockType(new Vector(x, y - 1, z), BlockID.GLASS); try {
getPosition().getExtent().setBlock(new Vector(x, y - 1, z), new BaseBlock(BlockTypes.GLASS));
} catch (WorldEditException e) {
e.printStackTrace();
}
setPosition(new Vector(x + 0.5, y, z + 0.5)); setPosition(new Vector(x + 0.5, y, z + 0.5));
} }
@Override @Override
public WorldVector getBlockIn() { public Location getBlockIn() {
WorldVector pos = getPosition(); return getPosition();
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
pos.getY(), pos.getZ());
} }
@Override @Override
public WorldVector getBlockOn() { public Location getBlockOn() {
WorldVector pos = getPosition(); return getPosition().setY(getPosition().getY() - 1);
return WorldVector.toBlockPoint(pos.getWorld(), pos.getX(),
pos.getY() - 1, pos.getZ());
} }
@Override @Override
public WorldVector getBlockTrace(int range, boolean useLastBlock) { public Location getBlockTrace(int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(this, range, 0.2); TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock()); return (useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock());
} }
@Override @Override
public WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock) { public Location getBlockTraceFace(int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(this, range, 0.2); TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace()); return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
} }
@Override @Override
public WorldVector getBlockTrace(int range) { public Location getBlockTrace(int range) {
return getBlockTrace(range, false); return getBlockTrace(range, false);
} }
@Override @Override
public WorldVector getSolidBlockTrace(int range) { public Location getSolidBlockTrace(int range) {
TargetBlock tb = new TargetBlock(this, range, 0.2); TargetBlock tb = new TargetBlock(this, range, 0.2);
return tb.getSolidTargetBlock(); return tb.getSolidTargetBlock();
} }
@ -383,14 +380,14 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
public boolean passThroughForwardWall(int range) { public boolean passThroughForwardWall(int range) {
int searchDist = 0; int searchDist = 0;
TargetBlock hitBlox = new TargetBlock(this, range, 0.2); TargetBlock hitBlox = new TargetBlock(this, range, 0.2);
World world = getPosition().getWorld(); Extent world = getPosition().getExtent();
BlockWorldVector block; Location block;
boolean firstBlock = true; boolean firstBlock = true;
int freeToFind = 2; int freeToFind = 2;
boolean inFree = false; boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) { while ((block = hitBlox.getNextBlock()) != null) {
boolean free = BlockType.canPassThrough(world.getBlock(block)); boolean free = BlockType.canPassThrough(world.getBlock(block.toVector()));
if (firstBlock) { if (firstBlock) {
firstBlock = false; firstBlock = false;
@ -451,10 +448,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (!(other instanceof LocalPlayer)) { if (!(other instanceof Player)) {
return false; return false;
} }
LocalPlayer other2 = (LocalPlayer) other; Player other2 = (Player) other;
return other2.getName().equals(getName()); return other2.getName().equals(getName());
} }

View File

@ -19,12 +19,13 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface; import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.command.tool.BlockTool; import com.sk89q.worldedit.command.tool.BlockTool;
import com.sk89q.worldedit.command.tool.DoubleActionBlockTool; import com.sk89q.worldedit.command.tool.DoubleActionBlockTool;
import com.sk89q.worldedit.command.tool.DoubleActionTraceTool; import com.sk89q.worldedit.command.tool.DoubleActionTraceTool;
@ -44,7 +45,6 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.Iterator; import java.util.Iterator;
@ -55,7 +55,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
/** /**
* Manages registered {@link Platform}s for WorldEdit. Platforms are * Manages registered {@link Platform}s for WorldEdit. Platforms are
@ -403,7 +403,7 @@ public class PlatformManager {
return; return;
} }
WorldVector pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance); Location pos = player.getSolidBlockTrace(getConfiguration().navigationWandMaxDistance);
if (pos != null) { if (pos != null) {
player.findFreePosition(pos); player.findFreePosition(pos);
} else { } else {
@ -417,7 +417,7 @@ public class PlatformManager {
LocalSession session = worldEdit.getSessionManager().get(player); LocalSession session = worldEdit.getSessionManager().get(player);
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionTraceTool) { if (tool instanceof DoubleActionTraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session); ((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
event.setCancelled(true); event.setCancelled(true);

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
@ -89,7 +88,7 @@ class PlayerProxy extends AbstractPlayerActor {
} }
@Override @Override
public WorldVector getPosition() { public Location getPosition() {
return basePlayer.getPosition(); return basePlayer.getPosition();
} }

View File

@ -19,8 +19,8 @@
package com.sk89q.worldedit.extent.inventory; package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.*; import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.util.Location;
/** /**
* Represents a source to get blocks from and store removed ones. * Represents a source to get blocks from and store removed ones.
@ -187,12 +187,12 @@ public abstract class BlockBag {
* *
* @param pos the position * @param pos the position
*/ */
public abstract void addSourcePosition(WorldVector pos); public abstract void addSourcePosition(Location pos);
/** /**
* Adds a position to be used a source. * Adds a position to be used a source.
* *
* @param pos the position * @param pos the position
*/ */
public abstract void addSingleSourcePosition(WorldVector pos); public abstract void addSingleSourcePosition(Location pos);
} }

View File

@ -1,264 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.internal;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData;
import javax.annotation.Nullable;
import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Wraps {@link World}s into {@link LocalWorld}.
*/
@SuppressWarnings("deprecation")
public class LocalWorldAdapter extends LocalWorld {
private final World world;
private LocalWorldAdapter(World world) {
checkNotNull(world);
this.world = world;
}
@Override
public String getName() {
return world.getName();
}
@Override
public int getMaxY() {
return world.getMaxY();
}
@Override
public boolean isValidBlockType(int id) {
return world.isValidBlockType(id);
}
@Override
public boolean usesBlockData(int id) {
return world.usesBlockData(id);
}
@Override
public Mask createLiquidMask() {
return world.createLiquidMask();
}
@Override
@Deprecated
public int getBlockType(Vector pt) {
return world.getBlockType(pt);
}
@Override
@Deprecated
public int getBlockData(Vector pt) {
return world.getBlockData(pt);
}
@Override
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
return world.setBlock(position, block, notifyAndLight);
}
@Override
public int getBlockLightLevel(Vector position) {
return world.getBlockLightLevel(position);
}
@Override
public boolean clearContainerBlockContents(Vector position) {
return world.clearContainerBlockContents(position);
}
@Override
public BaseBiome getBiome(Vector2D position) {
return world.getBiome(position);
}
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
return world.setBiome(position, biome);
}
@Override
public void dropItem(Vector position, BaseItemStack item, int count) {
world.dropItem(position, item, count);
}
@Override
public void dropItem(Vector position, BaseItemStack item) {
world.dropItem(position, item);
}
@Override
public void simulateBlockMine(Vector position) {
world.simulateBlockMine(position);
}
@Override
public boolean regenerate(Region region, EditSession editSession) {
return world.regenerate(region, editSession);
}
@Override
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTree(type, editSession, position);
}
@Override
@Deprecated
public boolean generateTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTree(editSession, position);
}
@Override
@Deprecated
public boolean generateBigTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateBigTree(editSession, position);
}
@Override
@Deprecated
public boolean generateBirchTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateBirchTree(editSession, position);
}
@Override
@Deprecated
public boolean generateRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateRedwoodTree(editSession, position);
}
@Override
@Deprecated
public boolean generateTallRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return world.generateTallRedwoodTree(editSession, position);
}
@Override
public void checkLoadedChunk(Vector position) {
world.checkLoadedChunk(position);
}
@Override
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
world.fixAfterFastMode(chunks);
}
@Override
public void fixLighting(Iterable<BlockVector2D> chunks) {
world.fixLighting(chunks);
}
@Override
public boolean playEffect(Vector position, int type, int data) {
return world.playEffect(position, type, data);
}
@Override
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
return world.queueBlockBreakEffect(server, position, blockId, priority);
}
@Override
public WorldData getWorldData() {
return world.getWorldData();
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object other) {
return world.equals(other);
}
@Override
public int hashCode() {
return world.hashCode();
}
@Override
public Vector getMinimumPoint() {
return world.getMinimumPoint();
}
@Override
public Vector getMaximumPoint() {
return world.getMaximumPoint();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return world.getEntities(region);
}
@Override
public BaseBlock getBlock(Vector position) {
return world.getBlock(position);
}
@Override
public BaseBlock getLazyBlock(Vector position) {
return world.getLazyBlock(position);
}
@Override
@Nullable
public Operation commit() {
return world.commit();
}
@Override
@Nullable
public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
return world.createEntity(location, entity);
}
@Override
public List<? extends Entity> getEntities() {
return world.getEntities();
}
public static LocalWorldAdapter adapt(World world) {
return new LocalWorldAdapter(world);
}
}

View File

@ -99,7 +99,7 @@ public class CommandLoggingHandler extends AbstractInvokeListener implements Inv
} }
if (logMode != null && sender.isPlayer()) { if (logMode != null && sender.isPlayer()) {
Vector position = player.getPosition(); Vector position = player.getPosition().toVector();
LocalSession session = worldEdit.getSessionManager().get(player); LocalSession session = worldEdit.getSessionManager().get(player);
switch (logMode) { switch (logMode) {

View File

@ -55,11 +55,6 @@ public abstract class AbstractRegion implements Region {
return world; return world;
} }
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override @Override
public void setWorld(World world) { public void setWorld(World world) {
this.world = world; this.world = world;
@ -89,7 +84,7 @@ public abstract class AbstractRegion implements Region {
final BlockVector min = getMinimumPoint().toBlockVector(); final BlockVector min = getMinimumPoint().toBlockVector();
final BlockVector max = getMaximumPoint().toBlockVector(); final BlockVector max = getMaximumPoint().toBlockVector();
final List<BlockVector2D> points = new ArrayList<BlockVector2D>(4); final List<BlockVector2D> points = new ArrayList<>(4);
points.add(new BlockVector2D(min.getX(), min.getZ())); points.add(new BlockVector2D(min.getX(), min.getZ()));
points.add(new BlockVector2D(min.getX(), max.getZ())); points.add(new BlockVector2D(min.getX(), max.getZ()));
@ -160,7 +155,7 @@ public abstract class AbstractRegion implements Region {
*/ */
@Override @Override
public Set<Vector2D> getChunks() { public Set<Vector2D> getChunks() {
final Set<Vector2D> chunks = new HashSet<Vector2D>(); final Set<Vector2D> chunks = new HashSet<>();
final Vector min = getMinimumPoint(); final Vector min = getMinimumPoint();
final Vector max = getMaximumPoint(); final Vector max = getMaximumPoint();
@ -185,7 +180,7 @@ public abstract class AbstractRegion implements Region {
@Override @Override
public Set<Vector> getChunkCubes() { public Set<Vector> getChunkCubes() {
final Set<Vector> chunks = new HashSet<Vector>(); final Set<Vector> chunks = new HashSet<>();
final Vector min = getMinimumPoint(); final Vector min = getMinimumPoint();
final Vector max = getMaximumPoint(); final Vector max = getMaximumPoint();

View File

@ -19,13 +19,13 @@
package com.sk89q.worldedit.regions; package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.LocalWorld; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.polyhedron.Edge; import com.sk89q.worldedit.regions.polyhedron.Edge;
import com.sk89q.worldedit.regions.polyhedron.Triangle; import com.sk89q.worldedit.regions.polyhedron.Triangle;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@ -33,24 +33,24 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull; import javax.annotation.Nullable;
public class ConvexPolyhedralRegion extends AbstractRegion { public class ConvexPolyhedralRegion extends AbstractRegion {
/** /**
* Vertices that are contained in the convex hull. * Vertices that are contained in the convex hull.
*/ */
private final Set<Vector> vertices = new LinkedHashSet<Vector>(); private final Set<Vector> vertices = new LinkedHashSet<>();
/** /**
* Triangles that form the convex hull. * Triangles that form the convex hull.
*/ */
private final List<Triangle> triangles = new ArrayList<Triangle>(); private final List<Triangle> triangles = new ArrayList<>();
/** /**
* Vertices that are coplanar to the first 3 vertices. * Vertices that are coplanar to the first 3 vertices.
*/ */
private final Set<Vector> vertexBacklog = new LinkedHashSet<Vector>(); private final Set<Vector> vertexBacklog = new LinkedHashSet<>();
/** /**
* Minimum point of the axis-aligned bounding box. * Minimum point of the axis-aligned bounding box.
@ -81,14 +81,6 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
super(world); super(world);
} }
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public ConvexPolyhedralRegion(LocalWorld world) {
super(world);
}
/** /**
* Constructs an independent copy of the given region. * Constructs an independent copy of the given region.
* *
@ -174,7 +166,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
} }
// Look for triangles that face the vertex and remove them // Look for triangles that face the vertex and remove them
final Set<Edge> borderEdges = new LinkedHashSet<Edge>(); final Set<Edge> borderEdges = new LinkedHashSet<>();
for (Iterator<Triangle> it = triangles.iterator(); it.hasNext(); ) { for (Iterator<Triangle> it = triangles.iterator(); it.hasNext(); ) {
final Triangle triangle = it.next(); final Triangle triangle = it.next();
@ -207,7 +199,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
vertices.remove(vertex); vertices.remove(vertex);
// Clone, clear and work through the backlog // Clone, clear and work through the backlog
final List<Vector> vertexBacklog2 = new ArrayList<Vector>(vertexBacklog); final List<Vector> vertexBacklog2 = new ArrayList<>(vertexBacklog);
vertexBacklog.clear(); vertexBacklog.clear();
for (Vector vertex2 : vertexBacklog2) { for (Vector vertex2 : vertexBacklog2) {
addVertex(vertex2); addVertex(vertex2);
@ -269,7 +261,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
} }
private static void shiftCollection(Collection<Vector> collection, Vector change) { private static void shiftCollection(Collection<Vector> collection, Vector change) {
final List<Vector> tmp = new ArrayList<Vector>(collection); final List<Vector> tmp = new ArrayList<>(collection);
collection.clear(); collection.clear();
for (Vector vertex : tmp) { for (Vector vertex : tmp) {
collection.add(change.add(vertex)); collection.add(change.add(vertex));
@ -323,7 +315,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
return vertices; return vertices;
} }
final List<Vector> ret = new ArrayList<Vector>(vertices); final List<Vector> ret = new ArrayList<>(vertices);
ret.addAll(vertexBacklog); ret.addAll(vertexBacklog);
return ret; return ret;

View File

@ -19,9 +19,10 @@
package com.sk89q.worldedit.regions; package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -33,8 +34,6 @@ import com.sk89q.worldedit.world.World;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Represents a cylindrical region. * Represents a cylindrical region.
*/ */
@ -53,13 +52,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
this((World) null); this((World) null);
} }
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public CylinderRegion(LocalWorld world) {
this((World) world);
}
/** /**
* Construct the region. * Construct the region.
* *
@ -70,11 +62,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
hasY = false; hasY = false;
} }
@Deprecated
public CylinderRegion(LocalWorld world, Vector center, Vector2D radius, int minY, int maxY) {
this((World) world, center, radius, minY, maxY);
}
/** /**
* Construct the region. * Construct the region.
* *

View File

@ -21,13 +21,13 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
/** /**
* Represents an ellipsoid region. * Represents an ellipsoid region.
@ -54,11 +54,6 @@ public class EllipsoidRegion extends AbstractRegion {
this(null, pos1, pos2); this(null, pos1, pos2);
} }
@Deprecated
public EllipsoidRegion(LocalWorld world, Vector center, Vector radius) {
this((World) world, center, radius);
}
/** /**
* Construct a new instance of this ellipsoid region. * Construct a new instance of this ellipsoid region.
* *

View File

@ -107,11 +107,6 @@ public class NullRegion implements Region {
this.world = world; this.world = world;
} }
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override @Override
public NullRegion clone() { public NullRegion clone() {
return new NullRegion(); return new NullRegion();

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator; import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
@ -52,11 +51,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
this((World) null); this((World) null);
} }
@Deprecated
public Polygonal2DRegion(LocalWorld world) {
this((World) world);
}
/** /**
* Construct the region. * Construct the region.
* *
@ -67,11 +61,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
hasY = false; hasY = false;
} }
@Deprecated
public Polygonal2DRegion(LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
this((World) world, points, minY, maxY);
}
/** /**
* Construct the region. * Construct the region.
* *

View File

@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D; import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -147,14 +146,6 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
*/ */
public void setWorld(@Nullable World world); public void setWorld(@Nullable World world);
/**
* Sets the world that the selection is in.
*
* @param world the world, which may be null
*/
@Deprecated
public void setWorld(@Nullable LocalWorld world);
/** /**
* Make a clone of the region. * Make a clone of the region.
* *

View File

@ -19,19 +19,19 @@
package com.sk89q.worldedit.regions; package com.sk89q.worldedit.regions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Iterators; import com.google.common.collect.Iterators;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.world.World;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* An intersection of several other regions. Any location that is contained in one * An intersection of several other regions. Any location that is contained in one
* of the child regions is considered as contained by this region. * of the child regions is considered as contained by this region.
@ -69,7 +69,7 @@ public class RegionIntersection extends AbstractRegion {
* @param world the world * @param world the world
* @param regions a list of regions, which is copied * @param regions a list of regions, which is copied
*/ */
public RegionIntersection(LocalWorld world, List<Region> regions) { public RegionIntersection(World world, List<Region> regions) {
super(world); super(world);
checkNotNull(regions); checkNotNull(regions);
checkArgument(!regions.isEmpty(), "empty region list is not supported"); checkArgument(!regions.isEmpty(), "empty region list is not supported");
@ -82,7 +82,7 @@ public class RegionIntersection extends AbstractRegion {
* @param world the world * @param world the world
* @param regions an array of regions, which is copied * @param regions an array of regions, which is copied
*/ */
public RegionIntersection(LocalWorld world, Region... regions) { public RegionIntersection(World world, Region... regions) {
super(world); super(world);
checkNotNull(regions); checkNotNull(regions);
checkArgument(regions.length > 0, "empty region list is not supported"); checkArgument(regions.length > 0, "empty region list is not supported");

View File

@ -93,14 +93,6 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
} }
} }
/**
* @deprecated cast {@code world} to {@link World}
*/
@Deprecated
public Polygonal2DRegionSelector(@Nullable LocalWorld world, List<BlockVector2D> points, int minY, int maxY) {
this((World) world, points, minY, maxY);
}
/** /**
* Create a new selector. * Create a new selector.
* *

View File

@ -31,7 +31,7 @@ import java.util.Set;
/** /**
* A region that mirrors the current selection according to the current * A region that mirrors the current selection according to the current
* {@link LocalSession} and {@link LocalWorld} set on the current * {@link LocalSession} and {@link World} set on the current
* {@link Request}. * {@link Request}.
* *
* <p>If a selection cannot be taken, then the selection will be assumed to be * <p>If a selection cannot be taken, then the selection will be assumed to be
@ -128,11 +128,6 @@ public class RequestSelection implements Region {
return getRegion().getWorld(); return getRegion().getWorld();
} }
@Override
public void setWorld(LocalWorld world) {
setWorld((World) world);
}
@Override @Override
public void setWorld(World world) { public void setWorld(World world) {
getRegion().setWorld(world); getRegion().setWorld(world);

View File

@ -217,6 +217,15 @@ public class Location {
xz * Math.cos(yaw)); xz * Math.cos(yaw));
} }
/**
* Get the direction as a {@link Direction}.
*
* @return The direction
*/
public Direction getDirectionEnum() {
return Direction.findClosest(getDirection(), Direction.Flag.ALL);
}
/** /**
* Create a clone of this object with the given direction. * Create a clone of this object with the given direction.
* *
@ -356,6 +365,16 @@ public class Location {
return new Location(extent, position.setZ(z), yaw, pitch); return new Location(extent, position.setZ(z), yaw, pitch);
} }
/**
* Return a copy of this object with the position set to the given value.
*
* @param position The new position
* @return a new immutable instance
*/
public Location setPosition(Vector position) {
return new Location(extent, position, yaw, pitch);
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.internal.LocalWorldAdapter; import com.sk89q.worldedit.world.World;
/** /**
* This class uses an inefficient method to figure out what block a player * This class uses an inefficient method to figure out what block a player
@ -34,7 +34,7 @@ import com.sk89q.worldedit.internal.LocalWorldAdapter;
*/ */
public class TargetBlock { public class TargetBlock {
private LocalWorld world; private World world;
private int maxDistance; private int maxDistance;
private double checkDistance, curDistance; private double checkDistance, curDistance;
private Vector targetPos = new Vector(); private Vector targetPos = new Vector();
@ -47,33 +47,22 @@ public class TargetBlock {
* *
* @param player player to work with * @param player player to work with
*/ */
public TargetBlock(LocalPlayer player) { public TargetBlock(Player player) {
this.world = LocalWorldAdapter.adapt(player.getWorld()); this.world = player.getWorld();
this.setValues(player.getPosition(), player.getYaw(), player.getPitch(), this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(),
300, 1.65, 0.2); 300, 1.65, 0.2);
} }
/** /**
* Constructor requiring a player, max distance and a checking distance * Constructor requiring a player, max distance and a checking distance
* *
* @param player LocalPlayer to work with * @param player Player to work with
* @param maxDistance how far it checks for blocks
* @param checkDistance how often to check for blocks, the smaller the more precise
*/
public TargetBlock(LocalPlayer player, int maxDistance, double checkDistance) {
this((Player) player, maxDistance, checkDistance);
}
/**
* Constructor requiring a player, max distance and a checking distance
*
* @param player LocalPlayer to work with
* @param maxDistance how far it checks for blocks * @param maxDistance how far it checks for blocks
* @param checkDistance how often to check for blocks, the smaller the more precise * @param checkDistance how often to check for blocks, the smaller the more precise
*/ */
public TargetBlock(Player player, int maxDistance, double checkDistance) { public TargetBlock(Player player, int maxDistance, double checkDistance) {
this.world = LocalWorldAdapter.adapt(player.getWorld()); this.world = player.getWorld();
this.setValues(player.getPosition(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance); this.setValues(player.getPosition().toVector(), player.getYaw(), player.getPitch(), maxDistance, 1.65, checkDistance);
} }
/** /**
@ -86,8 +75,7 @@ public class TargetBlock {
* @param viewHeight where the view is positioned in y-axis * @param viewHeight where the view is positioned in y-axis
* @param checkDistance how often to check for blocks, the smaller the more precise * @param checkDistance how often to check for blocks, the smaller the more precise
*/ */
private void setValues(Vector loc, double xRotation, double yRotation, private void setValues(Vector loc, double xRotation, double yRotation, int maxDistance, double viewHeight, double checkDistance) {
int maxDistance, double viewHeight, double checkDistance) {
this.maxDistance = maxDistance; this.maxDistance = maxDistance;
this.checkDistance = checkDistance; this.checkDistance = checkDistance;
this.curDistance = 0; this.curDistance = 0;
@ -111,11 +99,11 @@ public class TargetBlock {
* *
* @return Block * @return Block
*/ */
public BlockWorldVector getAnyTargetBlock() { public Location getAnyTargetBlock() {
boolean searchForLastBlock = true; boolean searchForLastBlock = true;
BlockWorldVector lastBlock = null; Location lastBlock = null;
while (getNextBlock() != null) { while (getNextBlock() != null) {
if (world.getBlockType(getCurrentBlock()) == BlockID.AIR) { if (world.getBlockType(getCurrentBlock().toVector()) == BlockID.AIR) {
if (searchForLastBlock) { if (searchForLastBlock) {
lastBlock = getCurrentBlock(); lastBlock = getCurrentBlock();
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) { if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
@ -126,7 +114,7 @@ public class TargetBlock {
break; break;
} }
} }
BlockWorldVector currentBlock = getCurrentBlock(); Location currentBlock = getCurrentBlock();
return (currentBlock != null ? currentBlock : lastBlock); return (currentBlock != null ? currentBlock : lastBlock);
} }
@ -136,8 +124,8 @@ public class TargetBlock {
* *
* @return Block * @return Block
*/ */
public BlockWorldVector getTargetBlock() { public Location getTargetBlock() {
while (getNextBlock() != null && world.getBlockType(getCurrentBlock()) == 0) ; while (getNextBlock() != null && world.getBlockType(getCurrentBlock().toVector()) == 0) ;
return getCurrentBlock(); return getCurrentBlock();
} }
@ -147,8 +135,8 @@ public class TargetBlock {
* *
* @return Block * @return Block
*/ */
public BlockWorldVector getSolidTargetBlock() { public Location getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock()))) ; while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock().toVector()))) ;
return getCurrentBlock(); return getCurrentBlock();
} }
@ -157,7 +145,7 @@ public class TargetBlock {
* *
* @return next block position * @return next block position
*/ */
public BlockWorldVector getNextBlock() { public Location getNextBlock() {
prevPos = targetPos; prevPos = targetPos;
do { do {
curDistance += checkDistance; curDistance += checkDistance;
@ -175,7 +163,7 @@ public class TargetBlock {
return null; return null;
} }
return new BlockWorldVector(world, targetPos); return new Location(world, targetPos);
} }
/** /**
@ -183,11 +171,11 @@ public class TargetBlock {
* *
* @return block position * @return block position
*/ */
public BlockWorldVector getCurrentBlock() { public Location getCurrentBlock() {
if (curDistance > maxDistance) { if (curDistance > maxDistance) {
return null; return null;
} else { } else {
return new BlockWorldVector(world, targetPos); return new Location(world, targetPos);
} }
} }
@ -196,18 +184,18 @@ public class TargetBlock {
* *
* @return block position * @return block position
*/ */
public BlockWorldVector getPreviousBlock() { public Location getPreviousBlock() {
return new BlockWorldVector(world, prevPos); return new Location(world, prevPos);
} }
public WorldVectorFace getAnyTargetBlockFace() { public Location getAnyTargetBlockFace() {
getAnyTargetBlock(); getAnyTargetBlock();
return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock()); return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector()));
} }
public WorldVectorFace getTargetBlockFace() { public Location getTargetBlockFace() {
getAnyTargetBlock(); getAnyTargetBlock();
return WorldVectorFace.getWorldVectorFace(world, getCurrentBlock(), getPreviousBlock()); return getCurrentBlock().setDirection(getCurrentBlock().toVector().subtract(getPreviousBlock().toVector()));
} }
} }

View File

@ -21,18 +21,13 @@ package com.sk89q.worldedit.forge;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -42,6 +37,10 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import java.util.UUID;
import javax.annotation.Nullable;
public class ForgePlayer extends AbstractPlayerActor { public class ForgePlayer extends AbstractPlayerActor {
private final EntityPlayerMP player; private final EntityPlayerMP player;
@ -59,7 +58,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override @Override
public int getItemInHand() { public int getItemInHand() {
ItemStack is = this.player.getHeldItem(EnumHand.MAIN_HAND); ItemStack is = this.player.getHeldItem(EnumHand.MAIN_HAND);
return is == null ? 0 : Item.getIdFromItem(is.getItem()); return Item.getIdFromItem(is.getItem());
} }
@Override @Override
@ -82,10 +81,9 @@ public class ForgePlayer extends AbstractPlayerActor {
this.player.rotationPitch); this.player.rotationPitch);
} }
@SuppressWarnings("deprecation")
@Override @Override
public WorldVector getPosition() { public Location getPosition() {
return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.world)), this.player.posX, this.player.posY, this.player.posZ); return new Location(ForgeWorldEdit.inst.getWorld(this.player.world), this.player.posX, this.player.posY, this.player.posZ);
} }
@Override @Override

View File

@ -19,19 +19,17 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.util.Location;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage; import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
@ -56,8 +54,6 @@ import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.block.BlockType;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static net.minecraft.block.Block.REGISTRY; import static net.minecraft.block.Block.REGISTRY;
@ -191,9 +187,7 @@ public class ForgeWorldEdit {
// event.setCanceled(true); // event.setCanceled(true);
} }
} else if (event instanceof PlayerInteractEvent.LeftClickBlock) { } else if (event instanceof PlayerInteractEvent.LeftClickBlock) {
@SuppressWarnings("deprecation") Location pos = new Location(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world),
event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
if (we.handleBlockLeftClick(player, pos)) { if (we.handleBlockLeftClick(player, pos)) {
event.setCanceled(true); event.setCanceled(true);
@ -203,9 +197,7 @@ public class ForgeWorldEdit {
event.setCanceled(true); event.setCanceled(true);
} }
} else if (event instanceof PlayerInteractEvent.RightClickBlock) { } else if (event instanceof PlayerInteractEvent.RightClickBlock) {
@SuppressWarnings("deprecation") Location pos = new Location(world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world),
event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
if (we.handleBlockRightClick(player, pos)) { if (we.handleBlockRightClick(player, pos)) {
event.setCanceled(true); event.setCanceled(true);

View File

@ -22,11 +22,9 @@ package com.sk89q.worldedit.sponge;
import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3d;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor; import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -39,11 +37,12 @@ import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.text.serializer.TextSerializers; import org.spongepowered.api.text.serializer.TextSerializers;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
public class SpongePlayer extends AbstractPlayerActor { public class SpongePlayer extends AbstractPlayerActor {
private final Player player; private final Player player;
@ -83,9 +82,9 @@ public class SpongePlayer extends AbstractPlayerActor {
} }
@Override @Override
public WorldVector getPosition() { public Location getPosition() {
Vector3d pos = this.player.getLocation().getPosition(); Vector3d pos = this.player.getLocation().getPosition();
return new WorldVector(LocalWorldAdapter.adapt(SpongeWorldEdit.inst().getAdapter().getWorld(this.player.getWorld())), pos.getX(), pos.getY(), pos.getZ()); return new Location(SpongeWorldEdit.inst().getAdapter().getWorld(this.player.getWorld()), pos.getX(), pos.getY(), pos.getZ());
} }
@Override @Override

View File

@ -19,16 +19,16 @@
package com.sk89q.worldedit.sponge; package com.sk89q.worldedit.sponge;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.sponge.adapter.AdapterLoadException; import com.sk89q.worldedit.sponge.adapter.AdapterLoadException;
import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter; import com.sk89q.worldedit.sponge.adapter.SpongeImplAdapter;
import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader; import com.sk89q.worldedit.sponge.adapter.SpongeImplLoader;
@ -44,7 +44,12 @@ import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent; import org.spongepowered.api.event.block.InteractBlockEvent;
import org.spongepowered.api.event.filter.cause.Root; import org.spongepowered.api.event.filter.cause.Root;
import org.spongepowered.api.event.game.state.*; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import org.spongepowered.api.event.game.state.GamePostInitializationEvent;
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.plugin.PluginContainer;
@ -57,8 +62,6 @@ import java.io.IOException;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* The Sponge implementation of WorldEdit. * The Sponge implementation of WorldEdit.
*/ */
@ -207,7 +210,8 @@ public class SpongeWorldEdit {
} }
Location<World> loc = optLoc.get(); Location<World> loc = optLoc.get();
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), loc.getX(), loc.getY(), loc.getZ()); com.sk89q.worldedit.util.Location pos = new com.sk89q.worldedit.util.Location(
world, loc.getX(), loc.getY(), loc.getZ());
if (we.handleBlockLeftClick(player, pos)) { if (we.handleBlockLeftClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);
@ -228,7 +232,8 @@ public class SpongeWorldEdit {
} }
Location<World> loc = optLoc.get(); Location<World> loc = optLoc.get();
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), loc.getX(), loc.getY(), loc.getZ()); com.sk89q.worldedit.util.Location pos = new com.sk89q.worldedit.util.Location(
world, loc.getX(), loc.getY(), loc.getZ());
if (we.handleBlockRightClick(player, pos)) { if (we.handleBlockRightClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);