Almost finished the state system. Just got to have it actually load in the values.

This commit is contained in:
Matthew Miller
2018-07-17 17:31:07 +10:00
parent 3e1d438565
commit 4938f419ad
25 changed files with 179 additions and 83 deletions

View File

@ -20,12 +20,15 @@
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;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@ -41,6 +44,23 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
material -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(id), material));
}
@Override
public List<Object> getPropertyValues(BlockType blockType, Property<?> property) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getPropertyValues(blockType, property);
}
return super.getPropertyValues(blockType, property);
}
@Nullable
@Override
public Map<String, ? extends Property> getProperties(BlockType blockType) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getProperties(blockType);
}
return super.getProperties(blockType);
}
public static class BukkitBlockMaterial extends PassthroughBlockMaterial {
private final Material material;

View File

@ -20,12 +20,17 @@
package com.sk89q.worldedit.bukkit.adapter;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.world.block.BlockType;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.entity.Entity;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
/**
@ -91,4 +96,19 @@ public interface BukkitImplAdapter {
Entity createEntity(Location location, BaseEntity state);
/**
* Get a list of values for a property.
*
* @param property The property
* @return The list of values
*/
List<Object> getPropertyValues(BlockType blockType, Property<?> property);
/**
* Get a map of string -> properties
*
* @param blockType The block type
* @return The properties map
*/
Map<String, ? extends Property> getProperties(BlockType blockType);
}