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:
Matt
2020-10-05 13:41:41 -04:00
committed by GitHub
parent b06d943f7c
commit 96dcb95b7c
393 changed files with 6537 additions and 4700 deletions

View File

@ -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() {

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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()]);

View File

@ -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();
}
}
}