Revert "Upstream, generics, formatting"

This reverts commit cd88e513a8.
This commit is contained in:
NotMyFault
2019-06-12 15:45:41 +02:00
parent 6f9fa018b2
commit ec001b8d3b
126 changed files with 3093 additions and 2490 deletions

View File

@ -154,5 +154,4 @@ public abstract class AbstractWorld implements World {
return Double.compare(priority, other != null ? other.priority : 0);
}
}
}
}

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
@ -34,6 +35,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -52,7 +54,7 @@ public class NullWorld extends AbstractWorld {
private static final NullWorld INSTANCE = new NullWorld();
protected NullWorld() {
public NullWorld() {
}
@Override

View File

@ -830,15 +830,16 @@ public final class BlockTypes {
}
}
// Register new blocks
int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String id = entry.getKey();
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++);
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
{ // Register new blocks
int internalId = 1;
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
String id = entry.getKey();
String defaultState = entry.getValue();
// Skip already registered ids
for (; values[internalId] != null; internalId++);
BlockType type = register(defaultState, internalId, stateList);
values[internalId] = type;
}
}
// Add to $Registry
@ -865,7 +866,9 @@ public final class BlockTypes {
try {
Field field = BlockTypes.class.getDeclaredField(enumName);
ReflectionUtils.setFailsafeFieldValue(field, null, existing);
} catch (NoSuchFieldException | IllegalAccessException e) {
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
@ -895,12 +898,12 @@ public final class BlockTypes {
try {
BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) return block.getBlockType();
} catch (NumberFormatException | IndexOutOfBoundsException ignored) {
} catch (NumberFormatException | IndexOutOfBoundsException e) {
}
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values)
.filter(b -> StringMan.blockStateMatches(inputLower, b.getId()))
.map(BlockType::getId)
.map(e1 -> e1.getId())
.sorted(StringMan.blockStateComparator(inputLower))
.collect(Collectors.toList())
);
@ -910,31 +913,31 @@ public final class BlockTypes {
return $NAMESPACES;
}
public static @Nullable BlockType get(final String id) {
public static final @Nullable BlockType get(final String id) {
return $REGISTRY.get(id);
}
public static @Nullable BlockType get(final CharSequence id) {
public static final @Nullable BlockType get(final CharSequence id) {
return $REGISTRY.get(id);
}
@Deprecated
public static BlockType get(final int ordinal) {
public static final BlockType get(final int ordinal) {
return values[ordinal];
}
@Deprecated
public static BlockType getFromStateId(final int internalStateId) {
public static final BlockType getFromStateId(final int internalStateId) {
return values[internalStateId & BIT_MASK];
}
@Deprecated
public static BlockType getFromStateOrdinal(final int internalStateOrdinal) {
public static final BlockType getFromStateOrdinal(final int internalStateOrdinal) {
return states[internalStateOrdinal].getBlockType();
}
public static int size() {
return values.length;
}
}

View File

@ -28,9 +28,10 @@ import com.google.common.io.Resources;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -47,8 +48,11 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
public class LegacyMapper {
private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
@ -222,7 +226,7 @@ public class LegacyMapper {
Integer combinedId = getLegacyCombined(blockState);
return combinedId == null ? null : new int[] { combinedId >> 4, combinedId & 0xF };
}
public BaseBlock getBaseBlockFromPlotBlock(PlotBlock plotBlock) {
if(plotBlock instanceof StringPlotBlock) {
try {