mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Javadoc and Formatting fixes. (#619)
Javadoc and Formatting fixes. Also, extremely minor code changes which have been tested. This commit is only part one of two commits that aim to fix problems with formatting in our project. In part two I will modify the Google Java Style Guide (since it closely matches our code style) for our project so there is guidance on how to format and document. * Updated PlotSquared URL * Removed plugin acronyms * Fixed a typo * Fixed grammar * Use modern block id's * Update YouTube video URL
This commit is contained in:
@ -138,7 +138,8 @@ public abstract class AbstractWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Operation commit() {
|
||||
@Nullable
|
||||
public Operation commit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshChunk(int X, int Z) {
|
||||
public void refreshChunk(int chunkX, int chunkZ) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -20,14 +20,14 @@
|
||||
package com.sk89q.worldedit.world;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.OptionalLong;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Regeneration options for {@link World#regenerate(Region, EditSession, RegenOptions)}.
|
||||
* Regeneration options for {@link World#regenerate(Region, Extent, RegenOptions)}.
|
||||
*/
|
||||
@AutoValue
|
||||
public abstract class RegenOptions {
|
||||
|
@ -66,6 +66,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
public BaseBlock(BlockType blockType) {
|
||||
this(blockType.getDefaultState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a block with a state.
|
||||
*
|
||||
@ -230,7 +231,9 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
@Override
|
||||
public void applyTileEntity(OutputExtent output, int x, int y, int z) {
|
||||
CompoundTag nbt = getNbtData();
|
||||
if (nbt != null) output.setTile(x, y, z, nbt);
|
||||
if (nbt != null) {
|
||||
output.setTile(x, y, z, nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -276,11 +279,8 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// if (getNbtData() != null) { // TODO Maybe make some JSON serialiser to make this not awful.
|
||||
// return blockState.getAsString() + " {" + String.valueOf(getNbtData()) + "}";
|
||||
// } else {
|
||||
return blockState.getAsString();
|
||||
// }
|
||||
// TODO use a json serializer for the NBT data
|
||||
return blockState.getAsString() + (hasNbtData() ? "{hasNbt}" : "");
|
||||
}
|
||||
|
||||
public BlockState toBlockState() {
|
||||
|
@ -37,7 +37,7 @@ public class BlockID {
|
||||
public static final int BARRIER = 24;
|
||||
public static final int BEACON = 25;
|
||||
public static final int BEDROCK = 26;
|
||||
public static final int BEE_NEST= 677;
|
||||
public static final int BEE_NEST = 677;
|
||||
public static final int BEEHIVE = 678; // highest
|
||||
public static final int BEETROOTS = 27;
|
||||
public static final int BELL = 605;
|
||||
|
@ -71,9 +71,8 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a temporary BlockState for a given internal id
|
||||
* @param combinedId
|
||||
* @deprecated magic number
|
||||
* Returns a temporary BlockState for a given internal id.
|
||||
* @deprecated Magic Numbers
|
||||
* @return BlockState
|
||||
*/
|
||||
|
||||
@ -88,7 +87,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a temporary BlockState for a given type and string
|
||||
* Returns a temporary BlockState for a given type and string.
|
||||
* @param state String e.g., minecraft:water[level=4]
|
||||
* @return BlockState
|
||||
*/
|
||||
@ -97,8 +96,10 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a temporary BlockState for a given type and string
|
||||
* - It's faster if a BlockType is provided compared to parsing the string
|
||||
* Returns a temporary BlockState for a given type and string.
|
||||
*
|
||||
* <p>It's faster if a BlockType is provided compared to parsing the string.</p>
|
||||
*
|
||||
* @param type BlockType e.g., BlockTypes.STONE (or null)
|
||||
* @param state String e.g., minecraft:water[level=4]
|
||||
* @return BlockState
|
||||
@ -108,8 +109,10 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a temporary BlockState for a given type and string
|
||||
* - It's faster if a BlockType is provided compared to parsing the string
|
||||
* Returns a temporary BlockState for a given type and string.
|
||||
*
|
||||
* <p>It's faster if a BlockType is provided compared to parsing the string.</p>
|
||||
*
|
||||
* @param type BlockType e.g., BlockTypes.STONE (or null)
|
||||
* @param state String e.g., minecraft:water[level=4]
|
||||
* @return BlockState
|
||||
@ -143,7 +146,9 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
|
||||
List<? extends Property> propList = type.getProperties();
|
||||
|
||||
if (state.charAt(state.length() - 1) != ']') state = state + "]";
|
||||
if (state.charAt(state.length() - 1) != ']') {
|
||||
state = state + "]";
|
||||
}
|
||||
MutableCharSequence charSequence = MutableCharSequence.getTemporal();
|
||||
charSequence.setString(state);
|
||||
|
||||
@ -222,6 +227,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
public BlockType getBlockType() {
|
||||
return this.blockType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBlock(extent, this);
|
||||
@ -242,8 +248,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal id with no type information
|
||||
* @return
|
||||
* The internal id with no type information.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
@ -405,7 +410,7 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
public boolean isAir() {
|
||||
try {
|
||||
return material.isAir();
|
||||
} catch (NullPointerException ignore) {
|
||||
} catch (NullPointerException ignored) {
|
||||
return getMaterial().isAir();
|
||||
}
|
||||
}
|
||||
|
@ -37,23 +37,20 @@ import javax.annotation.Nullable;
|
||||
public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEntityBlock, Pattern {
|
||||
|
||||
/**
|
||||
* Get the block type
|
||||
* Get the block type.
|
||||
*
|
||||
* @return The type
|
||||
*/
|
||||
BlockType getBlockType();
|
||||
|
||||
/**
|
||||
* Magic number (legacy uses)
|
||||
* @param propertyId
|
||||
* @return
|
||||
* Magic number (legacy uses).
|
||||
*/
|
||||
@Deprecated
|
||||
B withPropertyId(int propertyId);
|
||||
|
||||
/**
|
||||
* Get combined id (legacy uses)
|
||||
* @return
|
||||
* Get combined id (legacy uses).
|
||||
*/
|
||||
@Deprecated
|
||||
int getInternalId();
|
||||
@ -67,14 +64,13 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
BlockMaterial getMaterial();
|
||||
|
||||
/**
|
||||
* Get type id (legacy uses)
|
||||
* @return
|
||||
* Get type id (legacy uses).
|
||||
*/
|
||||
@Deprecated
|
||||
int getInternalBlockTypeId();
|
||||
|
||||
/**
|
||||
* Get the block data (legacy uses)
|
||||
* @return
|
||||
* Get the block data (legacy uses).
|
||||
*/
|
||||
@Deprecated
|
||||
int getInternalPropertiesId();
|
||||
@ -98,7 +94,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
<V> B with(final PropertyKey property, final V value);
|
||||
|
||||
/**
|
||||
* Gets the value at the given state
|
||||
* Gets the value for the given state.
|
||||
*
|
||||
* @param property The state
|
||||
* @return The value
|
||||
@ -106,7 +102,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
<V> V getState(Property<V> property);
|
||||
|
||||
/**
|
||||
* Gets the value at the given state
|
||||
* Gets the value for the given state.
|
||||
*
|
||||
* @param property The state
|
||||
* @return The value
|
||||
|
@ -186,7 +186,7 @@ public class BlockType implements Keyed, Pattern {
|
||||
public <V> Property<V> getProperty(PropertyKey key) {
|
||||
try {
|
||||
return (Property<V>) this.settings.propertiesMapArr[key.ordinal()];
|
||||
} catch (IndexOutOfBoundsException ignore) {
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ public class BlockTypeSwitchBuilder<T> {
|
||||
|
||||
public BlockTypeSwitch<T> build() {
|
||||
for (int i = 0; i < runnables.length; i++) {
|
||||
if (runnables[i] == null) runnables[i] = defaultTask;
|
||||
if (runnables[i] == null) {
|
||||
runnables[i] = defaultTask;
|
||||
}
|
||||
}
|
||||
return new BlockTypeSwitch(runnables);
|
||||
}
|
||||
|
@ -38,7 +38,8 @@ public class BlockTypeUtil {
|
||||
case BlockID.CREEPER_WALL_HEAD:
|
||||
case BlockID.DRAGON_WALL_HEAD:
|
||||
case BlockID.PLAYER_WALL_HEAD:
|
||||
case BlockID.ZOMBIE_WALL_HEAD: return 0.25;
|
||||
case BlockID.ZOMBIE_WALL_HEAD:
|
||||
return 0.25;
|
||||
case BlockID.ACACIA_SLAB:
|
||||
case BlockID.BIRCH_SLAB:
|
||||
case BlockID.BRICK_SLAB:
|
||||
@ -59,13 +60,16 @@ public class BlockTypeUtil {
|
||||
case BlockID.STONE_BRICK_SLAB:
|
||||
case BlockID.STONE_SLAB: {
|
||||
String state = (String) block.getState(PropertyKey.TYPE);
|
||||
if (state == null) return 0;
|
||||
if (state == null) {
|
||||
return 0;
|
||||
}
|
||||
switch (state) {
|
||||
case "double":
|
||||
case "bottom":
|
||||
return 0;
|
||||
case "top":
|
||||
return 0.5;
|
||||
case "double":
|
||||
case "bottom":
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case BlockID.ACACIA_TRAPDOOR:
|
||||
@ -87,9 +91,12 @@ public class BlockTypeUtil {
|
||||
case BlockID.DARK_OAK_FENCE_GATE:
|
||||
case BlockID.JUNGLE_FENCE_GATE:
|
||||
case BlockID.OAK_FENCE_GATE:
|
||||
case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
|
||||
case BlockID.SPRUCE_FENCE_GATE:
|
||||
return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
|
||||
default:
|
||||
if (type.getMaterial().isMovementBlocker()) return 0;
|
||||
if (type.getMaterial().isMovementBlocker()) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -119,29 +126,39 @@ public class BlockTypeUtil {
|
||||
case BlockID.PURPLE_BED:
|
||||
case BlockID.RED_BED:
|
||||
case BlockID.WHITE_BED:
|
||||
case BlockID.YELLOW_BED: return 0.5625;
|
||||
case BlockID.BREWING_STAND: return 0.875;
|
||||
case BlockID.CAKE: return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
|
||||
case BlockID.CAULDRON: return 0.3125;
|
||||
case BlockID.COCOA: return 0.750;
|
||||
case BlockID.ENCHANTING_TABLE: return 0.75;
|
||||
case BlockID.END_PORTAL_FRAME: return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
|
||||
case BlockID.YELLOW_BED:
|
||||
return 0.5625;
|
||||
case BlockID.BREWING_STAND:
|
||||
return 0.875;
|
||||
case BlockID.CAKE:
|
||||
return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
|
||||
case BlockID.CAULDRON:
|
||||
return 0.3125;
|
||||
case BlockID.COCOA:
|
||||
return 0.750;
|
||||
case BlockID.ENCHANTING_TABLE:
|
||||
return 0.75;
|
||||
case BlockID.END_PORTAL_FRAME:
|
||||
return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
|
||||
case BlockID.CREEPER_HEAD:
|
||||
case BlockID.DRAGON_HEAD:
|
||||
case BlockID.PISTON_HEAD:
|
||||
case BlockID.PLAYER_HEAD:
|
||||
case BlockID.ZOMBIE_HEAD: return 0.5;
|
||||
case BlockID.ZOMBIE_HEAD:
|
||||
return 0.5;
|
||||
case BlockID.CREEPER_WALL_HEAD:
|
||||
case BlockID.DRAGON_WALL_HEAD:
|
||||
case BlockID.PLAYER_WALL_HEAD:
|
||||
case BlockID.ZOMBIE_WALL_HEAD: return 0.75;
|
||||
case BlockID.ZOMBIE_WALL_HEAD:
|
||||
return 0.75;
|
||||
case BlockID.ACACIA_FENCE:
|
||||
case BlockID.BIRCH_FENCE:
|
||||
case BlockID.DARK_OAK_FENCE:
|
||||
case BlockID.JUNGLE_FENCE:
|
||||
case BlockID.NETHER_BRICK_FENCE:
|
||||
case BlockID.OAK_FENCE:
|
||||
case BlockID.SPRUCE_FENCE: return 1.5;
|
||||
case BlockID.SPRUCE_FENCE:
|
||||
return 1.5;
|
||||
case BlockID.ACACIA_SLAB:
|
||||
case BlockID.BIRCH_SLAB:
|
||||
case BlockID.BRICK_SLAB:
|
||||
@ -162,7 +179,9 @@ public class BlockTypeUtil {
|
||||
case BlockID.STONE_BRICK_SLAB:
|
||||
case BlockID.STONE_SLAB: {
|
||||
String state = (String) block.getState(PropertyKey.TYPE);
|
||||
if (state == null) return 0.5;
|
||||
if (state == null) {
|
||||
return 0.5;
|
||||
}
|
||||
switch (state) {
|
||||
case "bottom":
|
||||
return 0.5;
|
||||
@ -171,15 +190,23 @@ public class BlockTypeUtil {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
case BlockID.LILY_PAD: return 0.015625;
|
||||
case BlockID.REPEATER: return 0.125;
|
||||
case BlockID.SOUL_SAND: return 0.875;
|
||||
case BlockID.LILY_PAD:
|
||||
return 0.015625;
|
||||
case BlockID.REPEATER:
|
||||
return 0.125;
|
||||
case BlockID.SOUL_SAND:
|
||||
return 0.875;
|
||||
case BlockID.COBBLESTONE_WALL:
|
||||
case BlockID.MOSSY_COBBLESTONE_WALL: return 1.5;
|
||||
case BlockID.FLOWER_POT: return 0.375;
|
||||
case BlockID.COMPARATOR: return 0.125;
|
||||
case BlockID.DAYLIGHT_DETECTOR: return 0.375;
|
||||
case BlockID.HOPPER: return 0.625;
|
||||
case BlockID.MOSSY_COBBLESTONE_WALL:
|
||||
return 1.5;
|
||||
case BlockID.FLOWER_POT:
|
||||
return 0.375;
|
||||
case BlockID.COMPARATOR:
|
||||
return 0.125;
|
||||
case BlockID.DAYLIGHT_DETECTOR:
|
||||
return 0.375;
|
||||
case BlockID.HOPPER:
|
||||
return 0.625;
|
||||
case BlockID.ACACIA_TRAPDOOR:
|
||||
case BlockID.BIRCH_TRAPDOOR:
|
||||
case BlockID.DARK_OAK_TRAPDOOR:
|
||||
@ -199,12 +226,15 @@ public class BlockTypeUtil {
|
||||
case BlockID.DARK_OAK_FENCE_GATE:
|
||||
case BlockID.JUNGLE_FENCE_GATE:
|
||||
case BlockID.OAK_FENCE_GATE:
|
||||
case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
|
||||
case BlockID.SPRUCE_FENCE_GATE:
|
||||
return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
|
||||
default:
|
||||
if (type.hasProperty(PropertyKey.LAYERS)) {
|
||||
return PropertyGroup.LEVEL.get(block) * 0.0625;
|
||||
}
|
||||
if (!type.getMaterial().isMovementBlocker()) return 0;
|
||||
if (!type.getMaterial().isMovementBlocker()) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class BlockTypesCache {
|
||||
Settings
|
||||
-----------------------------------------------------
|
||||
*/
|
||||
protected final static class Settings {
|
||||
protected static final class Settings {
|
||||
protected final int internalId;
|
||||
protected final BlockState defaultState;
|
||||
protected final AbstractProperty<?>[] propertiesMapArr;
|
||||
@ -124,7 +124,9 @@ public class BlockTypesCache {
|
||||
|
||||
|
||||
private static int[] generateStateOrdinals(int internalId, int ordinal, int maxStateId, List<AbstractProperty<?>> props) {
|
||||
if (props.isEmpty()) return null;
|
||||
if (props.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
int[] result = new int[maxStateId];
|
||||
Arrays.fill(result, -1);
|
||||
int[] state = new int[props.size()];
|
||||
@ -146,7 +148,9 @@ public class BlockTypesCache {
|
||||
while (++state[index] == sizes[index]) {
|
||||
state[index] = 0;
|
||||
index++;
|
||||
if (index == state.length) break outer;
|
||||
if (index == state.length) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
index = 0;
|
||||
}
|
||||
@ -162,8 +166,8 @@ public class BlockTypesCache {
|
||||
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<>();
|
||||
// public static final NamespacedRegistry<BlockType> REGISTRY = new NamespacedRegistry<>("block type", $REGISTRY);
|
||||
//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;
|
||||
@ -184,7 +188,9 @@ public class BlockTypesCache {
|
||||
|
||||
int size = blockMap.size() + 1;
|
||||
Field[] idFields = BlockID.class.getDeclaredFields();
|
||||
for (Field field : idFields) size = Math.max(field.getInt(null) + 1, size);
|
||||
for (Field field : idFields) {
|
||||
size = Math.max(field.getInt(null) + 1, size);
|
||||
}
|
||||
BIT_OFFSET = MathMan.log2nlz(size);
|
||||
BIT_MASK = ((1 << BIT_OFFSET) - 1);
|
||||
values = new BlockType[size];
|
||||
@ -216,13 +222,17 @@ public class BlockTypesCache {
|
||||
for (Map.Entry<String, String> entry : blockMap.entrySet()) {
|
||||
String defaultState = entry.getValue();
|
||||
// Skip already registered ids
|
||||
for (; values[internalId] != null; internalId++);
|
||||
for (; values[internalId] != null; internalId++) {
|
||||
;
|
||||
}
|
||||
BlockType type = register(defaultState, internalId, stateList, tickList);
|
||||
values[internalId] = type;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (values[i] == null) values[i] = values[0];
|
||||
if (values[i] == null) {
|
||||
values[i] = values[0];
|
||||
}
|
||||
}
|
||||
|
||||
states = stateList.toArray(new BlockState[stateList.size()]);
|
||||
|
@ -9,10 +9,9 @@ public enum CompoundInput {
|
||||
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||
return state.toBaseBlock(input.getTile(x, y, z));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
;
|
||||
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,14 +85,14 @@ public class AnvilChunk implements Chunk {
|
||||
}
|
||||
|
||||
blocks[y] = NBTUtils.getChildTag(sectionTag.getValue(),
|
||||
"Blocks", ByteArrayTag.class).getValue();
|
||||
"Blocks", ByteArrayTag.class).getValue();
|
||||
data[y] = NBTUtils.getChildTag(sectionTag.getValue(), "Data",
|
||||
ByteArrayTag.class).getValue();
|
||||
ByteArrayTag.class).getValue();
|
||||
|
||||
// 4096 ID block support
|
||||
if (sectionTag.getValue().containsKey("Add")) {
|
||||
blocksAdd[y] = NBTUtils.getChildTag(sectionTag.getValue(),
|
||||
"Add", ByteArrayTag.class).getValue();
|
||||
"Add", ByteArrayTag.class).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,16 +100,17 @@ public class AnvilChunk implements Chunk {
|
||||
for (byte[] block : blocks) {
|
||||
if (block.length != sectionsize) {
|
||||
throw new InvalidFormatException(
|
||||
"Chunk blocks byte array expected " + "to be " + sectionsize + " bytes; found "
|
||||
+ block.length);
|
||||
"Chunk blocks byte array expected " + "to be "
|
||||
+ sectionsize + " bytes; found "
|
||||
+ block.length);
|
||||
}
|
||||
}
|
||||
|
||||
for (byte[] aData : data) {
|
||||
if (aData.length != (sectionsize / 2)) {
|
||||
throw new InvalidFormatException(
|
||||
"Chunk block data byte array " + "expected to be " + sectionsize
|
||||
+ " bytes; found " + aData.length);
|
||||
throw new InvalidFormatException("Chunk block data byte array "
|
||||
+ "expected to be " + sectionsize + " bytes; found "
|
||||
+ aData.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,7 +179,8 @@ public class AnvilChunk implements Chunk {
|
||||
* Used to load the tile entities.
|
||||
*/
|
||||
private void populateTileEntities() throws DataException {
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(), "TileEntities", ListTag.class).getValue();
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
|
||||
"TileEntities", ListTag.class).getValue();
|
||||
|
||||
tileEntities = new HashMap<>();
|
||||
|
||||
@ -254,8 +256,7 @@ public class AnvilChunk implements Chunk {
|
||||
|
||||
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
|
||||
if (state == null) {
|
||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data
|
||||
+ " found when loading legacy anvil chunk.");
|
||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
|
||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||
}
|
||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||
|
@ -50,7 +50,7 @@ public class AnvilChunk13 implements Chunk {
|
||||
private int rootX;
|
||||
private int rootZ;
|
||||
|
||||
private Map<BlockVector3, Map<String,Tag>> tileEntities;
|
||||
private Map<BlockVector3, Map<String, Tag>> tileEntities;
|
||||
|
||||
/**
|
||||
* Construct the chunk with a compound tag.
|
||||
@ -163,8 +163,6 @@ public class AnvilChunk13 implements Chunk {
|
||||
|
||||
/**
|
||||
* Used to load the tile entities.
|
||||
*
|
||||
* @throws DataException
|
||||
*/
|
||||
private void populateTileEntities() throws DataException {
|
||||
tileEntities = new HashMap<>();
|
||||
|
@ -40,7 +40,8 @@ public final class FluidCategories {
|
||||
return FluidCategory.REGISTRY.register(tag.getId(), tag);
|
||||
}
|
||||
|
||||
public static @Nullable FluidCategory get(final String id) {
|
||||
@Nullable
|
||||
public static FluidCategory get(final String id) {
|
||||
return FluidCategory.REGISTRY.get(id);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ public final class FluidTypes {
|
||||
return FluidType.REGISTRY.register(fluid.getId(), fluid);
|
||||
}
|
||||
|
||||
public static @Nullable FluidType get(final String id) {
|
||||
@Nullable
|
||||
public static FluidType get(final String id) {
|
||||
return FluidType.REGISTRY.get(id);
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public interface BlockMaterial {
|
||||
int getLightValue();
|
||||
|
||||
/**
|
||||
* Get the opacity of the block
|
||||
* Get the opacity of the block.
|
||||
* @return opacity
|
||||
*/
|
||||
int getLightOpacity();
|
||||
@ -159,14 +159,14 @@ public interface BlockMaterial {
|
||||
boolean isTranslucent();
|
||||
|
||||
/**
|
||||
* Gets whether the block has a container (Item container)
|
||||
* Gets whether the block has a container (Item container).
|
||||
*
|
||||
* @return If it has a container
|
||||
*/
|
||||
boolean hasContainer();
|
||||
|
||||
/**
|
||||
* Get the map color
|
||||
* Get the map color.
|
||||
* @return or 0
|
||||
*/
|
||||
int getMapColor();
|
||||
|
@ -75,7 +75,7 @@ public interface BlockRegistry {
|
||||
OptionalInt getInternalBlockStateId(BlockState state);
|
||||
|
||||
/**
|
||||
* Register all blocks
|
||||
* Register all blocks.
|
||||
*/
|
||||
default Collection<String> values() {
|
||||
return Collections.emptyList();
|
||||
|
@ -45,7 +45,7 @@ public interface EntityRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all entities
|
||||
* Register all entities.
|
||||
*/
|
||||
default Collection<String> registerEntities() {
|
||||
return Collections.emptyList();
|
||||
|
@ -158,7 +158,9 @@ public final class LegacyMapper {
|
||||
int base = blockArr[combinedId];
|
||||
if (base != 0) {
|
||||
for (int data_ = 0; data_ < 16; data_++, combinedId++) {
|
||||
if (blockArr[combinedId] == 0) blockArr[combinedId] = base;
|
||||
if (blockArr[combinedId] == 0) {
|
||||
blockArr[combinedId] = base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,12 +195,16 @@ public final class LegacyMapper {
|
||||
}
|
||||
|
||||
public ItemType getItemFromLegacy(String input) {
|
||||
if (input.startsWith("minecraft:")) input = input.substring(10);
|
||||
if (input.startsWith("minecraft:")) {
|
||||
input = input.substring(10);
|
||||
}
|
||||
return itemMap.get(getCombinedId(input));
|
||||
}
|
||||
|
||||
public BlockState getBlockFromLegacy(String input) {
|
||||
if (input.startsWith("minecraft:")) input = input.substring(10);
|
||||
if (input.startsWith("minecraft:")) {
|
||||
input = input.substring(10);
|
||||
}
|
||||
try {
|
||||
return BlockState.getFromInternalId(blockArr[getCombinedId(input)]);
|
||||
} catch (InputParseException e) {
|
||||
@ -246,13 +252,15 @@ public final class LegacyMapper {
|
||||
if (combinedId < blockArr.length) {
|
||||
try {
|
||||
int internalId = blockArr[combinedId];
|
||||
if (internalId == 0) return null;
|
||||
if (internalId == 0) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return BlockState.getFromInternalId(internalId);
|
||||
} catch (InputParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ignore) {
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -279,7 +287,9 @@ public final class LegacyMapper {
|
||||
@Nullable
|
||||
public Integer getLegacyCombined(BlockState blockState) {
|
||||
Integer result = blockStateToLegacyId4Data.get(blockState.getInternalId());
|
||||
if (result == null) result = blockStateToLegacyId4Data.get(blockState.getInternalBlockTypeId());
|
||||
if (result == null) {
|
||||
result = blockStateToLegacyId4Data.get(blockState.getInternalBlockTypeId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,8 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
* Get a chunk store.
|
||||
*
|
||||
* @return a chunk store
|
||||
* @throws IOException
|
||||
* @throws DataException
|
||||
* @throws IOException if there is an error loading the chunk store
|
||||
* @throws DataException if there is an error loading the chunk store
|
||||
*/
|
||||
public ChunkStore getChunkStore() throws IOException, DataException {
|
||||
ChunkStore chunkStore = internalGetChunkStore();
|
||||
@ -80,8 +80,8 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
* Get a chunk store.
|
||||
*
|
||||
* @return a chunk store
|
||||
* @throws IOException
|
||||
* @throws DataException
|
||||
* @throws IOException if there is an error loading the chunk store
|
||||
* @throws DataException if there is an error loading the chunk store
|
||||
*/
|
||||
private ChunkStore internalGetChunkStore() throws IOException, DataException {
|
||||
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
|
||||
@ -205,8 +205,10 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
public int compareTo(Snapshot o) {
|
||||
if (o.date == null || date == null) {
|
||||
// Remove the folder from the name
|
||||
int i = name.indexOf('/'), j = o.name.indexOf('/');
|
||||
return name.substring((i > 0 ? 0 : i)).compareTo(o.name.substring((j > 0 ? 0 : j)));
|
||||
int ourIndex = name.indexOf('/');
|
||||
int theirIndex = o.name.indexOf('/');
|
||||
return name.substring(Math.min(ourIndex, 0))
|
||||
.compareTo(o.name.substring(Math.min(theirIndex, 0)));
|
||||
} else {
|
||||
return date.compareTo(o.date);
|
||||
}
|
||||
|
@ -103,8 +103,9 @@ public class SnapshotRestore {
|
||||
}
|
||||
|
||||
private void checkAndAddBlock(BlockVector3 pos) {
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(pos))
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockVector2 chunkPos = ChunkStore.toChunk(pos);
|
||||
|
||||
|
@ -60,11 +60,15 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo> {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
SnapshotInfo that = (SnapshotInfo) o;
|
||||
return Objects.equals(name, that.name) &&
|
||||
Objects.equals(dateTime, that.dateTime);
|
||||
return Objects.equals(name, that.name)
|
||||
&& Objects.equals(dateTime, that.dateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,10 +78,10 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SnapshotInfo{" +
|
||||
"name='" + name + '\'' +
|
||||
",date=" + dateTime +
|
||||
'}';
|
||||
return "SnapshotInfo{"
|
||||
+ "name='" + name + '\''
|
||||
+ ",date=" + dateTime
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,8 +101,9 @@ public class SnapshotRestore {
|
||||
}
|
||||
|
||||
private void checkAndAddBlock(BlockVector3 pos) {
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(pos))
|
||||
if (editSession.getMask() != null && !editSession.getMask().test(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockVector2 chunkPos = ChunkStore.toChunk(pos);
|
||||
|
||||
|
@ -95,7 +95,8 @@ public class FolderSnapshot implements Snapshot {
|
||||
private final SnapshotInfo info;
|
||||
private final Path folder;
|
||||
private final AtomicReference<Object> regionFolder = new AtomicReference<>();
|
||||
private final @Nullable Closer closeCallback;
|
||||
@Nullable
|
||||
private final Closer closeCallback;
|
||||
|
||||
public FolderSnapshot(SnapshotInfo info, Path folder, @Nullable Closer closeCallback) {
|
||||
this.info = info;
|
||||
|
@ -35,14 +35,22 @@ import java.io.IOException;
|
||||
public abstract class ChunkStore implements Closeable {
|
||||
|
||||
/**
|
||||
* The shift for converting to/from a chunk position.
|
||||
*
|
||||
* <p>
|
||||
* {@code >>} - to chunk
|
||||
* {@code <<} - from chunk
|
||||
* </p>
|
||||
*/
|
||||
public static final int CHUNK_SHIFTS = 4;
|
||||
|
||||
/**
|
||||
* The shift for converting to/from a 3D chunk position.
|
||||
*
|
||||
* <p>
|
||||
* {@code >>} - to Y of 3D-chunk
|
||||
* {@code <<} - from Y of 3D-chunk
|
||||
* </p>
|
||||
*/
|
||||
public static final int CHUNK_SHIFTS_Y = 8;
|
||||
|
||||
|
@ -88,7 +88,9 @@ public class ChunkStoreHelper {
|
||||
}
|
||||
|
||||
int dataVersion = rootTag.getInt("DataVersion");
|
||||
if (dataVersion == 0) dataVersion = -1;
|
||||
if (dataVersion == 0) {
|
||||
dataVersion = -1;
|
||||
}
|
||||
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||
final int currentDataVersion = platform.getDataVersion();
|
||||
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
|
||||
|
@ -24,7 +24,6 @@ import com.sk89q.worldedit.world.DataException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
@ -32,7 +31,7 @@ import java.io.InputStream;
|
||||
*/
|
||||
public class FileLegacyChunkStore extends LegacyChunkStore {
|
||||
|
||||
private File path;
|
||||
private final File path;
|
||||
|
||||
/**
|
||||
* Create an instance. The passed path is the folder to read the
|
||||
@ -51,11 +50,10 @@ public class FileLegacyChunkStore extends LegacyChunkStore {
|
||||
* @param f2 the second part of the pathname
|
||||
* @param name the name of the file
|
||||
* @return an input stream
|
||||
* @throws DataException
|
||||
* @throws IOException
|
||||
* @throws DataException if there is an error getting data for this chunk
|
||||
*/
|
||||
@Override
|
||||
protected InputStream getInputStream(String f1, String f2, String name) throws DataException, IOException {
|
||||
protected InputStream getInputStream(String f1, String f2, String name) throws DataException {
|
||||
String file = f1 + File.separator + f2 + File.separator + name;
|
||||
try {
|
||||
return new FileInputStream(new File(path, file));
|
||||
|
@ -62,7 +62,9 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
|
||||
}
|
||||
|
||||
try {
|
||||
if (file == null) throw new FileNotFoundException();
|
||||
if (file == null) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
return new FileInputStream(file);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new MissingChunkException();
|
||||
@ -71,8 +73,8 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return new File(path, "region").isDirectory() ||
|
||||
new File(path, "DIM-1" + File.separator + "region").isDirectory();
|
||||
return new File(path, "region").isDirectory()
|
||||
|| new File(path, "DIM-1" + File.separator + "region").isDirectory();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ import java.util.zip.ZipException;
|
||||
*/
|
||||
public class TrueZipLegacyChunkStore extends LegacyChunkStore {
|
||||
|
||||
private File zipFile;
|
||||
private ZipFile zip;
|
||||
private final File zipFile;
|
||||
private final ZipFile zip;
|
||||
private String folder;
|
||||
|
||||
/**
|
||||
@ -47,8 +47,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
|
||||
*
|
||||
* @param zipFile the ZIP file to open
|
||||
* @param folder the folder to look into in the ZIP
|
||||
* @throws IOException
|
||||
* @throws ZipException
|
||||
* @throws IOException if there is an error opening the zip
|
||||
* @throws ZipException if there is an error opening the zip
|
||||
*/
|
||||
public TrueZipLegacyChunkStore(File zipFile, String folder) throws IOException, ZipException {
|
||||
this.zipFile = zipFile;
|
||||
@ -62,8 +62,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
|
||||
* be detected.
|
||||
*
|
||||
* @param zipFile the ZIP file to open
|
||||
* @throws IOException
|
||||
* @throws ZipException
|
||||
* @throws IOException if there is an error opening the zip
|
||||
* @throws ZipException if there is an error opening the zip
|
||||
*/
|
||||
public TrueZipLegacyChunkStore(File zipFile) throws IOException, ZipException {
|
||||
this.zipFile = zipFile;
|
||||
@ -78,8 +78,8 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
|
||||
* @param f2 the second part of the filename
|
||||
* @param name the name of the file
|
||||
* @return an input stream
|
||||
* @throws IOException
|
||||
* @throws DataException
|
||||
* @throws IOException if there is an error getting the chunk data
|
||||
* @throws DataException if there is an error getting the chunk data
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -49,8 +49,8 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
|
||||
*
|
||||
* @param zipFile the ZIP file
|
||||
* @param folder the folder to look into
|
||||
* @throws IOException
|
||||
* @throws ZipException
|
||||
* @throws IOException if there is an error opening the zip
|
||||
* @throws ZipException if there is an error opening the zip
|
||||
*/
|
||||
public TrueZipMcRegionChunkStore(File zipFile, String folder) throws IOException, ZipException {
|
||||
this.zipFile = zipFile;
|
||||
@ -64,8 +64,8 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
|
||||
* be detected.
|
||||
*
|
||||
* @param zipFile the ZIP file
|
||||
* @throws IOException
|
||||
* @throws ZipException
|
||||
* @throws IOException if there is an error opening the zip
|
||||
* @throws ZipException if there is an error opening the zip
|
||||
*/
|
||||
public TrueZipMcRegionChunkStore(File zipFile) throws IOException, ZipException {
|
||||
this.zipFile = zipFile;
|
||||
@ -79,8 +79,8 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
|
||||
* @param name the name
|
||||
* @param worldName the world name
|
||||
* @return an input stream
|
||||
* @throws IOException
|
||||
* @throws DataException
|
||||
* @throws IOException if there is an error getting the chunk data
|
||||
* @throws DataException if there is an error getting the chunk data
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -97,11 +97,18 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
|
||||
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
|
||||
ZipEntry testEntry = e.nextElement();
|
||||
// Check for world
|
||||
if (worldPattern.matcher(testEntry.getName()).matches()) {
|
||||
String entryName = testEntry.getName();
|
||||
if (worldPattern.matcher(entryName).matches()) {
|
||||
// Check for file
|
||||
if (pattern.matcher(testEntry.getName()).matches()) {
|
||||
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
|
||||
if (folder.endsWith("poi")) continue;
|
||||
if (pattern.matcher(entryName).matches()) {
|
||||
int endIndex = entryName.lastIndexOf('/');
|
||||
if (endIndex < 0) {
|
||||
endIndex = entryName.lastIndexOf('\\');
|
||||
}
|
||||
folder = entryName.substring(0, endIndex);
|
||||
if (folder.endsWith("poi")) {
|
||||
continue;
|
||||
}
|
||||
name = folder + "/" + name;
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user