mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-12 04:23:54 +00:00
Plenty of changes to core block behavior to become more compatible with upstream WorldEdit (still more to be done!)
This commit is contained in:
@ -142,7 +142,7 @@ public enum BukkitAdapter {
|
||||
return getAdapter().adapt(blockData);
|
||||
}
|
||||
|
||||
public static BlockTypes adapt(Material material) {
|
||||
public static BlockType adapt(Material material) {
|
||||
return getAdapter().adapt(material);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends Property> getProperties(BlockType blockType) {
|
||||
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.getProperties(blockType);
|
||||
|
@ -96,7 +96,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
||||
public void giveItem(BaseItemStack itemStack) {
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
ItemStack newItem = BukkitAdapter.adapt(itemStack);
|
||||
if (itemStack.getType() == WorldEdit.getInstance().getConfiguration().wandItem) {
|
||||
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
||||
inv.remove(newItem);
|
||||
}
|
||||
final ItemStack item = player.getItemInHand();
|
||||
|
@ -478,10 +478,10 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.sk89q.worldedit.world.block.BlockState getFullBlock(BlockVector3 position) {
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toBaseBlock();
|
||||
} else {
|
||||
return getBlock(position).toBaseBlock();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
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;
|
||||
@ -52,17 +53,17 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
@Override
|
||||
public ItemType asItemType(Material material) {
|
||||
try {
|
||||
return ItemTypes.values[itemTypes[material.ordinal()]];
|
||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return asItemType(material);
|
||||
return ItemTypes.values[itemTypes[material.ordinal()]];
|
||||
return ItemTypes.get(itemTypes[material.ordinal()]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockTypes adapt(Material material) {
|
||||
public BlockType adapt(Material material) {
|
||||
try {
|
||||
return BlockTypes.values[blockTypes[material.ordinal()]];
|
||||
return BlockTypes.values[blockTypes[material.ordinal()]];
|
||||
} catch (NullPointerException e) {
|
||||
if (init()) return adapt(material);
|
||||
throw e;
|
||||
@ -80,7 +81,7 @@ public abstract class CachedBukkitAdapter implements IBukkitAdapter {
|
||||
try {
|
||||
checkNotNull(blockData);
|
||||
Material material = blockData.getMaterial();
|
||||
BlockTypes type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
|
||||
BlockType type = BlockTypes.getFromStateId(blockTypes[material.ordinal()]);
|
||||
List<? extends Property> propList = type.getProperties();
|
||||
if (propList.size() == 0) return type.getDefaultState();
|
||||
String properties = blockData.getAsString();
|
||||
|
@ -284,7 +284,7 @@ public interface IBukkitAdapter {
|
||||
*/
|
||||
BlockState adapt(BlockData blockData);
|
||||
|
||||
BlockTypes adapt(Material material);
|
||||
BlockType adapt(Material material);
|
||||
|
||||
/**
|
||||
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.sk89q.worldedit.bukkit.adapter;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -31,7 +32,7 @@ public class SimpleBukkitAdapter extends CachedBukkitAdapter {
|
||||
int typeId = block.getInternalBlockTypeId();
|
||||
BlockData[] dataCache = blockDataCache[typeId];
|
||||
if (dataCache == null) {
|
||||
BlockTypes type = BlockTypes.get(typeId);
|
||||
BlockType type = BlockTypes.get(typeId);
|
||||
blockDataCache[typeId] = dataCache = new BlockData[type.getMaxStateId() + 1];
|
||||
}
|
||||
int propId = block.getInternalPropertiesId();
|
||||
|
Reference in New Issue
Block a user