fix dependencies

This commit is contained in:
Jesse Boyd
2019-08-26 05:45:03 +01:00
parent ae89c16390
commit 4e49d16505
88 changed files with 1536 additions and 1545 deletions

View File

@ -134,6 +134,11 @@ public class NullWorld extends AbstractWorld {
return BlockVector3.ZERO;
}
@Override
public void sendChunk(int X, int Z, int mask) {
}
@Override
public IChunkGet get(int x, int z) {
return NullChunkGet.INSTANCE;

View File

@ -72,7 +72,6 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
*
* @return the maximum Y
*/
@Override
int getMaxY();
/**

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.FawePattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
@ -36,6 +37,7 @@ import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -45,6 +47,9 @@ import java.util.stream.IntStream;
import javax.annotation.Nullable;
public class BlockType implements FawePattern, Keyed {
public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type");
private final String id;
private final BlockTypes.Settings settings;

View File

@ -26,11 +26,17 @@ import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.registry.IRegistry;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import com.sk89q.worldedit.registry.Registry;
import com.sk89q.worldedit.registry.state.AbstractProperty;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BlockRegistry;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.registry.Registries;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
@ -871,18 +877,22 @@ public final class BlockTypes {
public static final int BIT_OFFSET; // Used internally
protected static final int BIT_MASK; // Used internally
private static final Map<String, BlockType> $REGISTRY = new HashMap<>();
// private static final Map<String, BlockType> $REGISTRY = new HashMap<>();
// public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type", $REGISTRY);
public static final BlockType[] values;
public static final BlockState[] states;
private static final Set<String> $NAMESPACES = new LinkedHashSet<String>();
private static final Set<String> $NAMESPACES = new LinkedHashSet<>();
static {
try {
ArrayList<BlockState> stateList = new ArrayList<>();
Collection<String> blocks = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().registerBlocks();
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
Registries registries = platform.getRegistries();
BlockRegistry blockReg = registries.getBlockRegistry();
Collection<String> blocks = blockReg.registerBlocks();
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();
@ -928,7 +938,7 @@ public final class BlockTypes {
// Add to $Registry
for (BlockType type : values) {
$REGISTRY.put(type.getId().toLowerCase(Locale.ROOT), type);
BlockType.REGISTRY.register(type.getId().toLowerCase(Locale.ROOT), type);
}
states = stateList.toArray(new BlockState[stateList.size()]);
@ -954,15 +964,13 @@ public final class BlockTypes {
try {
Field field = BlockTypes.class.getDeclaredField(enumName);
ReflectionUtils.setFailsafeFieldValue(field, null, existing);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
// register states
if (typeName.startsWith("minecraft:")) $REGISTRY.put(typeName.substring(10), existing);
$REGISTRY.put(typeName, existing);
if (typeName.startsWith("minecraft:")) BlockType.REGISTRY.register(typeName.substring(10), existing);
BlockType.REGISTRY.register(typeName, existing);
String nameSpace = typeName.substring(0, typeName.indexOf(':'));
$NAMESPACES.add(nameSpace);
return existing;
@ -980,7 +988,7 @@ public final class BlockTypes {
String input = inputLower;
if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input;
BlockType result = $REGISTRY.get(input);
BlockType result = BlockType.REGISTRY.get(input);
if (result != null) return result;
try {
@ -1002,11 +1010,11 @@ public final class BlockTypes {
}
public static @Nullable BlockType get(final String id) {
return $REGISTRY.get(id);
return BlockType.REGISTRY.getMap().get(id);
}
public static @Nullable BlockType get(final CharSequence id) {
return $REGISTRY.get(id);
return BlockType.REGISTRY.getMap().get(id);
}
@Deprecated

View File

@ -22,6 +22,8 @@ package com.sk89q.worldedit.world.registry;
import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonPrimitive;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability;
@ -76,6 +78,15 @@ public final class BundledBlockData {
private void loadFromResource() throws IOException {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
gsonBuilder.registerTypeAdapter(int.class, (JsonDeserializer<Integer>) (json, typeOfT, context) -> {
JsonPrimitive primitive = (JsonPrimitive) json;
if (primitive.isString()) {
String value = primitive.getAsString();
if (value.charAt(0) == '#') return Integer.parseInt(value.substring(1), 16);
return Integer.parseInt(value);
}
return primitive.getAsInt();
});
Gson gson = gsonBuilder.create();
URL url = null;
final int dataVersion = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataVersion();

View File

@ -66,13 +66,13 @@ public class SnapshotRepository {
}
/**
* Get a list of snapshots in a directory. The newest snapshot is near the top of the array.
* Get a list of snapshots in a directory. The newest snapshot is
* near the top of the array.
*
* @param newestFirst true to get the newest first
* @return a list of snapshots
*/
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName)
throws MissingWorldException {
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException {
FilenameFilter filter = (dir, name) -> {
File f = new File(dir, name);
return isValidSnapshot(f);
@ -116,8 +116,7 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotAfter(ZonedDateTime date, String world)
throws MissingWorldException {
public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(true, world);
Snapshot last = null;
@ -139,8 +138,7 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotBefore(ZonedDateTime date, String world)
throws MissingWorldException {
public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(false, world);
Snapshot last = null;
@ -206,8 +204,7 @@ public class SnapshotRepository {
* @return whether it is a valid snapshot
*/
protected boolean isValidSnapshot(File file) {
if (!file.getName()
.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
if (!file.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
return false;
}