mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
some adapter refactoring
This commit is contained in:
@ -144,6 +144,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
BlockState state = null;
|
||||
try {
|
||||
String palettePart = fix(entry.getKey());
|
||||
System.out.println("Read " + palettePart);
|
||||
state = BlockState.get(palettePart);
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -179,7 +179,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
// Suggest property
|
||||
String input = charSequence.toString();
|
||||
BlockType finalType = type;
|
||||
throw new SuggestInputParseException("Invalid property " + charSequence + ":" + input + " for type " + type, input, () ->
|
||||
throw new SuggestInputParseException("Invalid property " + key + ":" + input + " for type " + type, input, () ->
|
||||
finalType.getProperties().stream()
|
||||
.map(Property::getName)
|
||||
.filter(p -> StringMan.blockStateMatches(input, p))
|
||||
@ -196,6 +196,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
case '=': {
|
||||
charSequence.setSubstring(last, i);
|
||||
property = (AbstractProperty) type.getPropertyMap().get(charSequence);
|
||||
if (property == null) System.out.println("No prop " + charSequence + " | " + type.getPropertyMap());
|
||||
last = i + 1;
|
||||
break;
|
||||
}
|
||||
|
@ -741,6 +741,7 @@ public final class BlockTypes {
|
||||
private static Field[] fieldsTmp;
|
||||
private static JoinedCharSequence joined;
|
||||
private static int initIndex = 0;
|
||||
|
||||
public static BlockType init() {
|
||||
if (fieldsTmp == null) {
|
||||
fieldsTmp = BlockTypes.class.getDeclaredFields();
|
||||
|
@ -176,7 +176,7 @@ public class BlockTypesCache {
|
||||
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
|
||||
Registries registries = platform.getRegistries();
|
||||
BlockRegistry blockReg = registries.getBlockRegistry();
|
||||
Collection<String> blocks = blockReg.registerBlocks();
|
||||
Collection<String> blocks = blockReg.values();
|
||||
Map<String, String> blockMap = blocks.stream().collect(Collectors.toMap(item -> item.charAt(item.length() - 1) == ']' ? item.substring(0, item.indexOf('[')) : item, item -> item));
|
||||
|
||||
int size = blockMap.size();
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.registry.ItemRegistry;
|
||||
import com.sk89q.worldedit.world.registry.Registries;
|
||||
|
||||
public final class ItemTypesCache {
|
||||
public static void init() {}
|
||||
|
||||
static {
|
||||
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
|
||||
Registries registries = platform.getRegistries();
|
||||
ItemRegistry itemReg = registries.getItemRegistry();
|
||||
for (String key : itemReg.values()) {
|
||||
ItemType item = new ItemType(key);
|
||||
ItemType.REGISTRY.register(key, item);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@ public interface BlockRegistry {
|
||||
/**
|
||||
* Register all blocks
|
||||
*/
|
||||
default Collection<String> registerBlocks() {
|
||||
default Collection<String> values() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ package com.sk89q.worldedit.world.registry;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public interface ItemRegistry {
|
||||
|
||||
@ -34,4 +36,10 @@ public interface ItemRegistry {
|
||||
@Nullable
|
||||
String getName(ItemType itemType);
|
||||
|
||||
/**
|
||||
* Register all items
|
||||
*/
|
||||
default Collection<String> values() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user