mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Cleanup the bukkit implementation, and update to the 1.13 release items/blocks.
This commit is contained in:
@ -19,22 +19,59 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Adapts between Bukkit and WorldEdit equivalent objects.
|
||||
*/
|
||||
final class BukkitAdapter {
|
||||
public class BukkitAdapter {
|
||||
|
||||
private BukkitAdapter() {
|
||||
}
|
||||
|
||||
private static final ParserContext TO_BLOCK_CONTEXT = new ParserContext();
|
||||
|
||||
static {
|
||||
TO_BLOCK_CONTEXT.setRestricted(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
||||
*
|
||||
* @param blockType The WorldEdit BlockType
|
||||
* @param type The Bukkit Material
|
||||
* @return If they are equal
|
||||
*/
|
||||
public static boolean equals(BlockType blockType, Material type) {
|
||||
return Objects.equals(blockType.getId(), type.getKey().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
||||
*
|
||||
@ -95,7 +132,7 @@ final class BukkitAdapter {
|
||||
*/
|
||||
public static Location adapt(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
Vector position = BukkitUtil.toVector(location);
|
||||
Vector position = asVector(location);
|
||||
return new com.sk89q.worldedit.util.Location(
|
||||
adapt(location.getWorld()),
|
||||
position,
|
||||
@ -151,6 +188,17 @@ final class BukkitAdapter {
|
||||
location.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit Vector from a Bukkit location.
|
||||
*
|
||||
* @param location The Bukkit location
|
||||
* @return a WorldEdit vector
|
||||
*/
|
||||
public static Vector asVector(org.bukkit.Location location) {
|
||||
checkNotNull(location);
|
||||
return new Vector(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit entity from a Bukkit entity.
|
||||
*
|
||||
@ -162,4 +210,103 @@ final class BukkitAdapter {
|
||||
return new BukkitEntity(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit Material form a WorldEdit ItemType
|
||||
*
|
||||
* @param itemType The WorldEdit ItemType
|
||||
* @return The Bukkit Material
|
||||
*/
|
||||
public static Material adapt(ItemType itemType) {
|
||||
checkNotNull(itemType);
|
||||
if (!itemType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||
}
|
||||
return Material.getMaterial(itemType.getId().replace("minecraft:", "").toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit Material form a WorldEdit BlockType
|
||||
*
|
||||
* @param blockType The WorldEdit BlockType
|
||||
* @return The Bukkit Material
|
||||
*/
|
||||
public static Material adapt(BlockType blockType) {
|
||||
checkNotNull(blockType);
|
||||
if (!blockType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||
}
|
||||
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
||||
}
|
||||
|
||||
private static Map<String, BlockState> blockStateCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit BlockData
|
||||
*
|
||||
* @param blockData The Bukkit BlockData
|
||||
* @return The WorldEdit BlockState
|
||||
*/
|
||||
public static BlockState adapt(BlockData blockData) {
|
||||
checkNotNull(blockData);
|
||||
return blockStateCache.computeIfAbsent(blockData.getAsString(), new Function<String, BlockState>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState apply(@Nullable String input) {
|
||||
try {
|
||||
return WorldEdit.getInstance().getBlockFactory().parseFromInput(input, TO_BLOCK_CONTEXT).toImmutableState();
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
||||
*
|
||||
* @param block The WorldEdit BlockStateHolder
|
||||
* @return The Bukkit BlockData
|
||||
*/
|
||||
public static BlockData adapt(BlockStateHolder block) {
|
||||
checkNotNull(block);
|
||||
return Bukkit.createBlockData(block.getAsString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
||||
*
|
||||
* @param itemStack The Bukkit ItemStack
|
||||
* @return The WorldEdit BlockState
|
||||
*/
|
||||
public static BlockState asBlockState(ItemStack itemStack) {
|
||||
checkNotNull(itemStack);
|
||||
if (itemStack.getType().isBlock()) {
|
||||
return adapt(itemStack.getType().createBlockData());
|
||||
} else {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
||||
*
|
||||
* @param itemStack The Bukkit ItemStack
|
||||
* @return The WorldEdit BaseItemStack
|
||||
*/
|
||||
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||
checkNotNull(itemStack);
|
||||
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack
|
||||
*
|
||||
* @param item The WorldEdit BaseItemStack
|
||||
* @return The Bukkit ItemStack
|
||||
*/
|
||||
public static ItemStack adapt(BaseItemStack item) {
|
||||
checkNotNull(item);
|
||||
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit.bukkit;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import org.bukkit.Material;
|
||||
@ -39,7 +38,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockMaterial getMaterial(BlockType blockType) {
|
||||
return materialMap.computeIfAbsent(BukkitUtil.toMaterial(blockType),
|
||||
return materialMap.computeIfAbsent(BukkitAdapter.adapt(blockType),
|
||||
material -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), material));
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
||||
? player.getInventory().getItemInMainHand()
|
||||
: player.getInventory().getItemInOffHand();
|
||||
return BukkitUtil.toBaseItemStack(itemStack);
|
||||
return BukkitAdapter.adapt(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,7 +69,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
||||
? player.getInventory().getItemInMainHand()
|
||||
: player.getInventory().getItemInOffHand();
|
||||
return new BaseBlock(BukkitUtil.toBlock(itemStack));
|
||||
return new BaseBlock(BukkitAdapter.asBlockState(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,7 +79,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public void giveItem(BaseItemStack itemStack) {
|
||||
player.getInventory().addItem(BukkitUtil.toItemStack(itemStack));
|
||||
player.getInventory().addItem(BukkitAdapter.adapt(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,7 +135,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return BukkitUtil.getWorld(player.getWorld());
|
||||
return BukkitAdapter.adapt(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -176,7 +176,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
@Override
|
||||
public com.sk89q.worldedit.util.Location getLocation() {
|
||||
Location nativeLocation = player.getLocation();
|
||||
Vector position = BukkitUtil.toVector(nativeLocation);
|
||||
Vector position = BukkitAdapter.asVector(nativeLocation);
|
||||
return new com.sk89q.worldedit.util.Location(
|
||||
getWorld(),
|
||||
position,
|
||||
|
@ -79,7 +79,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!BukkitUtil.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||
if (!BukkitAdapter.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
@ -132,7 +132,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!BukkitUtil.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||
if (!BukkitAdapter.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||
// Type id doesn't fit
|
||||
continue;
|
||||
}
|
||||
@ -158,7 +158,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items[freeSlot] = new ItemStack(BukkitUtil.toItemStack(new BaseItemStack(blockState.getBlockType().getItemType(), amount)));
|
||||
items[freeSlot] = BukkitAdapter.adapt(new BaseItemStack(blockState.getBlockType().getItemType(), amount));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
|
||||
List<com.sk89q.worldedit.world.World> ret = new ArrayList<>(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
ret.add(BukkitUtil.getWorld(world));
|
||||
ret.add(BukkitAdapter.adapt(world));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1,185 +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 com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class BukkitUtil {
|
||||
|
||||
private BukkitUtil() {
|
||||
}
|
||||
|
||||
private static final ParserContext TO_BLOCK_CONTEXT = new ParserContext();
|
||||
|
||||
static {
|
||||
TO_BLOCK_CONTEXT.setRestricted(false);
|
||||
}
|
||||
|
||||
public static com.sk89q.worldedit.world.World getWorld(World w) {
|
||||
return new BukkitWorld(w);
|
||||
}
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(org.bukkit.Location loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Location toLocation(org.bukkit.Location loc) {
|
||||
return new Location(
|
||||
getWorld(loc.getWorld()),
|
||||
new Vector(loc.getX(), loc.getY(), loc.getZ()),
|
||||
loc.getYaw(), loc.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
public static Vector toVector(org.bukkit.util.Vector vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static org.bukkit.Location toLocation(World world, Vector pt) {
|
||||
return new org.bukkit.Location(world, pt.getX(), pt.getY(), pt.getZ());
|
||||
}
|
||||
|
||||
public static org.bukkit.Location center(org.bukkit.Location loc) {
|
||||
return new org.bukkit.Location(
|
||||
loc.getWorld(),
|
||||
loc.getBlockX() + 0.5,
|
||||
loc.getBlockY() + 0.5,
|
||||
loc.getBlockZ() + 0.5,
|
||||
loc.getPitch(),
|
||||
loc.getYaw()
|
||||
);
|
||||
}
|
||||
|
||||
public static Player matchSinglePlayer(Server server, String name) {
|
||||
List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return players.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bukkit's Location class has serious problems with floating point
|
||||
* precision.
|
||||
*/
|
||||
@SuppressWarnings("RedundantIfStatement")
|
||||
public static boolean equals(org.bukkit.Location a, org.bukkit.Location b) {
|
||||
if (Math.abs(a.getX() - b.getX()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getY() - b.getY()) > EQUALS_PRECISION) return false;
|
||||
if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean equals(BlockType blockType, Material type) {
|
||||
return Objects.equals(blockType.getId(), type.getKey().toString());
|
||||
}
|
||||
|
||||
public static final double EQUALS_PRECISION = 0.0001;
|
||||
|
||||
public static org.bukkit.Location toLocation(Location location) {
|
||||
Vector pt = location.toVector();
|
||||
return new org.bukkit.Location(
|
||||
toWorld(location.getExtent()),
|
||||
pt.getX(), pt.getY(), pt.getZ(),
|
||||
location.getYaw(), location.getPitch()
|
||||
);
|
||||
}
|
||||
|
||||
public static World toWorld(final Extent world) {
|
||||
return ((BukkitWorld) world).getWorld();
|
||||
}
|
||||
|
||||
public static Material toMaterial(ItemType itemType) {
|
||||
if (!itemType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||
}
|
||||
return Material.getMaterial(itemType.getId().replace("minecraft:", "").toUpperCase());
|
||||
}
|
||||
|
||||
public static Material toMaterial(BlockType blockType) {
|
||||
if (!blockType.getId().startsWith("minecraft:")) {
|
||||
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||
}
|
||||
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
||||
}
|
||||
|
||||
public static BlockState toBlock(BlockData blockData) {
|
||||
try {
|
||||
return WorldEdit.getInstance().getBlockFactory().parseFromInput(blockData.getAsString(), TO_BLOCK_CONTEXT).toImmutableState();
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BlockData toBlock(BlockStateHolder block) {
|
||||
return Bukkit.createBlockData(block.getAsString());
|
||||
}
|
||||
|
||||
public static BlockState toBlock(ItemStack itemStack) throws WorldEditException {
|
||||
if (itemStack.getType().isBlock()) {
|
||||
return toBlock(itemStack.getType().createBlockData());
|
||||
} else {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
}
|
||||
|
||||
public static BaseItemStack toBaseItemStack(ItemStack itemStack) {
|
||||
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||
}
|
||||
|
||||
public static ItemStack toItemStack(BaseItemStack item) {
|
||||
return new ItemStack(toMaterial(item.getType()), item.getAmount());
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
List<Entity> ents = world.getEntities();
|
||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||
for (Entity ent : ents) {
|
||||
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
|
||||
if (region.contains(BukkitAdapter.asVector(ent.getLocation()))) {
|
||||
entities.add(BukkitAdapter.adapt(ent));
|
||||
}
|
||||
}
|
||||
@ -284,14 +284,14 @@ public class BukkitWorld extends AbstractWorld {
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
||||
World world = getWorld();
|
||||
TreeType bukkitType = toBukkitTreeType(type);
|
||||
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
|
||||
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||
new EditSessionBlockChangeDelegate(editSession));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItem(Vector pt, BaseItemStack item) {
|
||||
World world = getWorld();
|
||||
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), BukkitUtil.toItemStack(item));
|
||||
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -343,7 +343,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return false;
|
||||
}
|
||||
|
||||
world.playEffect(BukkitUtil.toLocation(world, position), effect, data);
|
||||
world.playEffect(BukkitAdapter.adapt(world, position), effect, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -356,7 +356,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
return BukkitUtil.toBlock(bukkitBlock.getBlockData());
|
||||
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -366,7 +366,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||
} else {
|
||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
bukkitBlock.setBlockData(BukkitUtil.toBlock(block), notifyAndLight);
|
||||
bukkitBlock.setBlockData(BukkitAdapter.adapt(block), notifyAndLight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
@Override
|
||||
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||
try {
|
||||
editSession.setBlock(new Vector(x, y, z), BukkitUtil.toBlock(blockData));
|
||||
editSession.setBlock(new Vector(x, y, z), BukkitAdapter.adapt(blockData));
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
return false;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(int x, int y, int z) {
|
||||
return BukkitUtil.toBlock(editSession.getBlock(new Vector(x, y, z)));
|
||||
return BukkitAdapter.adapt(editSession.getBlock(new Vector(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user