mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Initial attempt at binding state IDs
This commit is contained in:
committed by
Matthew Miller
parent
e69ba31d6b
commit
a3a175ab8c
@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
@ -28,6 +29,7 @@ import org.bukkit.Material;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -54,6 +56,14 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||
return super.getProperties(blockType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getInternalBlockStateId(state);
|
||||
}
|
||||
return super.getInternalBlockStateId(state);
|
||||
}
|
||||
|
||||
public static class BukkitBlockMaterial extends PassthroughBlockMaterial {
|
||||
|
||||
private final Material material;
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -160,4 +161,15 @@ public interface BukkitImplAdapter {
|
||||
* @return the WorldEdit BaseItemStack
|
||||
*/
|
||||
BaseItemStack adapt(ItemStack itemStack);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the internal ID for a given state, if possible.
|
||||
*
|
||||
* @param state The block state
|
||||
* @return the internal ID of the state
|
||||
*/
|
||||
default OptionalInt getInternalBlockStateId(BlockState state) {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user