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

@ -100,7 +100,6 @@ public class BlockArrayClipboard implements Clipboard {
@Override
public void setOrigin(BlockVector3 origin) {
// this.origin = origin;
getParent().setOrigin(origin.subtract(region.getMinimumPoint()));
}
@ -117,9 +116,9 @@ public class BlockArrayClipboard implements Clipboard {
@Override
public BlockState getBlock(BlockVector3 position) {
if (region.contains(position)) {
int x = position.getBlockX()- origin.getX();
int y = position.getBlockY()- origin.getY();
int z = position.getBlockZ()- origin.getZ();
int x = position.getBlockX() - origin.getX();
int y = position.getBlockY() - origin.getY();
int z = position.getBlockZ() - origin.getZ();
return getParent().getBlock(x, y, z);
}
@ -128,10 +127,10 @@ public class BlockArrayClipboard implements Clipboard {
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
if(region.contains(position)) {
int x = position.getBlockX()- origin.getX();
int y = position.getBlockY()- origin.getY();
int z = position.getBlockZ()- origin.getZ();
if (region.contains(position)) {
int x = position.getBlockX() - origin.getX();
int y = position.getBlockY() - origin.getY();
int z = position.getBlockZ() - origin.getZ();
return getParent().getFullBlock(x, y, z);
}
return BlockTypes.AIR.getDefaultState().toBaseBlock();
@ -320,8 +319,11 @@ public class BlockArrayClipboard implements Clipboard {
public static class ClipboardEntity implements Entity {
private final BaseEntity entity;
private final Clipboard clipboard;
private final double x, y, z;
private final float yaw, pitch;
private final double x;
private final double y;
private final double z;
private final float yaw;
private final float pitch;
public ClipboardEntity(Location loc, BaseEntity entity) {
this((Clipboard) loc.getExtent(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), entity);

View File

@ -129,7 +129,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
/**
* Remove entity from clipboard
* Remove entity from clipboard.
*/
void removeEntity(Entity entity);
@ -184,7 +184,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
/**
* Forwards to paste(world, to, true, true, null)
* Forwards to {@link #paste(World, BlockVector3, boolean, boolean, Transform)}.
*/
default EditSession paste(World world, BlockVector3 to) {
return paste(world, to, true, true, null);
@ -204,7 +204,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
/**
* Save this schematic to a stream
* Save this schematic to a stream.
*/
default void save(OutputStream stream, ClipboardFormat format) throws IOException {
checkNotNull(stream);
@ -220,7 +220,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
}
/**
* Paste this schematic in a world
* Paste this schematic in a world.
*/
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
boolean copyEntities, @Nullable Transform transform) {

View File

@ -34,6 +34,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Locale;
import java.util.Set;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@ -72,7 +73,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
@Override
public boolean isFormat(File file) {
String name = file.getName().toLowerCase();
String name = file.getName().toLowerCase(Locale.ROOT);
return name.endsWith(".schematic") || name.endsWith(".mcedit") || name.endsWith(".mce");
}
},
@ -108,7 +109,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
@Override
public boolean isFormat(File file) {
String name = file.getName().toLowerCase();
String name = file.getName().toLowerCase(Locale.ROOT);
return name.endsWith(".schem") || name.endsWith(".sponge");
}
@ -141,13 +142,13 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
@Override
public boolean isFormat(File file) {
String name = file.getName().toLowerCase();
String name = file.getName().toLowerCase(Locale.ROOT);
return name.endsWith(".nbt");
}
},
/**
* Isometric PNG writer
* Isometric PNG writer.
*/
PNG("png", "image") {

View File

@ -101,7 +101,7 @@ public interface ClipboardFormat {
/**
* Sets the actor's clipboard.
* @param actor
* @param actor the actor
* @param uri the URI of the schematic to hold
* @param inputStream the input stream
* @throws IOException thrown on I/O error

View File

@ -126,7 +126,7 @@ public class ClipboardFormats {
}
/**
* Detect the format using the given extension
* Detect the format using the given extension.
*
* @param extension the extension
* @return the format, otherwise null if one cannot be detected
@ -195,8 +195,8 @@ public class ClipboardFormats {
return null;
}
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ?
new File(working, player.getUniqueId().toString()) : working;
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS
? new File(working, player.getUniqueId().toString()) : working;
File f;
if (input.startsWith("#")) {
String[] extensions;

View File

@ -80,9 +80,14 @@ public class FastSchematicReader extends NBTSchematicReader {
private List<Map<String, Object>> tiles;
private List<Map<String, Object>> entities;
private int width, height, length;
private int offsetX, offsetY, offsetZ;
private char[] palette, biomePalette;
private int width;
private int height;
private int length;
private int offsetX;
private int offsetY;
private int offsetZ;
private char[] palette;
private char[] biomePalette;
private BlockVector3 min = BlockVector3.ZERO;
@ -97,22 +102,30 @@ public class FastSchematicReader extends NBTSchematicReader {
}
private String fix(String palettePart) {
if (fixer == null || dataVersion == -1) return palettePart;
if (fixer == null || dataVersion == -1) {
return palettePart;
}
return fixer.fixUp(DataFixer.FixTypes.BLOCK_STATE, palettePart, dataVersion);
}
private CompoundTag fixBlockEntity(CompoundTag tag) {
if (fixer == null || dataVersion == -1) return tag;
if (fixer == null || dataVersion == -1) {
return tag;
}
return fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, tag, dataVersion);
}
private CompoundTag fixEntity(CompoundTag tag) {
if (fixer == null || dataVersion == -1) return tag;
if (fixer == null || dataVersion == -1) {
return tag;
}
return fixer.fixUp(DataFixer.FixTypes.ENTITY, tag, dataVersion);
}
private String fixBiome(String biomePalettePart) {
if(fixer == null || dataVersion == -1) return biomePalettePart;
if (fixer == null || dataVersion == -1) {
return biomePalettePart;
}
return fixer.fixUp(DataFixer.FixTypes.BIOME, biomePalettePart, dataVersion);
}
@ -208,8 +221,12 @@ public class FastSchematicReader extends NBTSchematicReader {
throw new IOException("This schematic version is currently not supported");
}
if (blocks != null) blocks.close();
if (biomes != null) biomes.close();
if (blocks != null) {
blocks.close();
}
if (biomes != null) {
biomes.close();
}
blocks = null;
biomes = null;
@ -285,7 +302,9 @@ public class FastSchematicReader extends NBTSchematicReader {
CompoundTag tile = FaweCache.IMP.asTag(tileRaw);
int[] pos = tile.getIntArray("Pos");
int x,y,z;
int x;
int y;
int z;
if (pos.length != 3) {
if (!tile.containsKey("x") || !tile.containsKey("y") || !tile.containsKey("z")) {
return null;

View File

@ -190,7 +190,9 @@ public class MCEditSchematicReader extends NBTSchematicReader {
Map<BlockVector3, BlockState> blockStates = new HashMap<>();
for (Tag tag : tileEntities) {
if (!(tag instanceof CompoundTag)) continue;
if (!(tag instanceof CompoundTag)) {
continue;
}
CompoundTag t = (CompoundTag) tag;
Map<String, Tag> values = new HashMap<>(t.getValue());
String id = t.getString("id");

View File

@ -95,7 +95,7 @@ public class SchematicReader implements ClipboardReader {
private NBTInputStream inputStream;
private InputStream rootStream;
// private final DataFixer fixer; TODO
// private final DataFixer fixer; TODO
private FastByteArrayOutputStream idOut = new FastByteArrayOutputStream();
private FastByteArrayOutputStream dataOut = new FastByteArrayOutputStream();
@ -110,9 +110,15 @@ public class SchematicReader implements ClipboardReader {
private List<Map<String, Object>> tiles;
private List<Map<String, Object>> entities;
private int width, height, length;
private int offsetX, offsetY, offsetZ;
private int originX, originY, originZ;
private int width;
private int height;
private int length;
private int offsetX;
private int offsetY;
private int offsetZ;
private int originX;
private int originY;
private int originZ;
/**
* Create a new instance.
@ -249,10 +255,18 @@ public class SchematicReader implements ClipboardReader {
StreamDelegate root = createDelegate();
inputStream.readNamedTagLazy(root);
if (ids != null) ids.close();
if (datas != null) datas.close();
if (adds != null) adds.close();
if (biomes != null) biomes.close();
if (ids != null) {
ids.close();
}
if (datas != null) {
datas.close();
}
if (adds != null) {
adds.close();
}
if (biomes != null) {
biomes.close();
}
ids = null;
datas = null;
adds = null;
@ -265,7 +279,7 @@ public class SchematicReader implements ClipboardReader {
}
Clipboard clipboard = createOutput.apply(dimensions);
try (InputStream dataIn = new LZ4BlockInputStream(new FastByteArraysInputStream(dataOut.toByteArrays()));InputStream idIn = new LZ4BlockInputStream(new FastByteArraysInputStream(idOut.toByteArrays()))) {
try (InputStream dataIn = new LZ4BlockInputStream(new FastByteArraysInputStream(dataOut.toByteArrays())); InputStream idIn = new LZ4BlockInputStream(new FastByteArraysInputStream(idOut.toByteArrays()))) {
if (addOut != null) {
try (FaweInputStream addIn = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(addOut.toByteArrays())))) {
if (clipboard instanceof LinearClipboard) {
@ -368,7 +382,9 @@ public class SchematicReader implements ClipboardReader {
private void fixStates(Clipboard fc) {
for (BlockVector3 pos : fc) {
BlockState block = pos.getBlock(fc);
if (block.getMaterial().isAir()) continue;
if (block.getMaterial().isAir()) {
continue;
}
int x = pos.getX();
int y = pos.getY();
@ -425,13 +441,23 @@ public class SchematicReader implements ClipboardReader {
}
} else {
int group = group(type);
if (group == -1) return;
if (group == -1) {
return;
}
BlockState set = block;
if (set.getState(PropertyKey.NORTH) == Boolean.FALSE && merge(fc, group, x, y, z - 1)) set = set.with(PropertyKey.NORTH, true);
if (set.getState(PropertyKey.EAST) == Boolean.FALSE && merge(fc, group, x + 1, y, z)) set = set.with(PropertyKey.EAST, true);
if (set.getState(PropertyKey.SOUTH) == Boolean.FALSE && merge(fc, group, x, y, z + 1)) set = set.with(PropertyKey.SOUTH, true);
if (set.getState(PropertyKey.WEST) == Boolean.FALSE && merge(fc, group, x - 1, y, z)) set = set.with(PropertyKey.WEST, true);
if (set.getState(PropertyKey.NORTH) == Boolean.FALSE && merge(fc, group, x, y, z - 1)) {
set = set.with(PropertyKey.NORTH, true);
}
if (set.getState(PropertyKey.EAST) == Boolean.FALSE && merge(fc, group, x + 1, y, z)) {
set = set.with(PropertyKey.EAST, true);
}
if (set.getState(PropertyKey.SOUTH) == Boolean.FALSE && merge(fc, group, x, y, z + 1)) {
set = set.with(PropertyKey.SOUTH, true);
}
if (set.getState(PropertyKey.WEST) == Boolean.FALSE && merge(fc, group, x - 1, y, z)) {
set = set.with(PropertyKey.WEST, true);
}
if (group == 2) {
int ns = (set.getState(PropertyKey.NORTH) ? 1 : 0) + ((Boolean) set.getState(PropertyKey.SOUTH) ? 1 : 0);
@ -441,7 +467,9 @@ public class SchematicReader implements ClipboardReader {
}
}
if (set != block) pos.setBlock(fc, set);
if (set != block) {
pos.setBlock(fc, set);
}
}
}
}

View File

@ -24,5 +24,6 @@ import com.sk89q.worldedit.world.entity.EntityType;
public interface EntityNBTCompatibilityHandler {
boolean isAffectedEntity(EntityType type, CompoundTag entityTag);
CompoundTag updateNBT(EntityType type, CompoundTag entityTag);
}