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

@ -55,9 +55,10 @@ public final class ChunkDeleter {
private static final Logger logger = LoggerFactory.getLogger(ChunkDeleter.class);
private static final Comparator<BlockVector2> chunkSorter = Comparator.comparing(
pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32);
pos -> (pos.getBlockX() & 31) + (pos.getBlockZ() & 31) * 32
);
private static Gson chunkDeleterGson = new GsonBuilder()
private static final Gson chunkDeleterGson = new GsonBuilder()
.registerTypeAdapter(BlockVector2.class, new BlockVector2Adapter())
.setPrettyPrinting()
.create();
@ -95,13 +96,13 @@ public final class ChunkDeleter {
} catch (IOException ignored) {
}
if (!deletedFile) {
logger.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences" +
" on next startup, or if /delchunks is used again.");
logger.warn("Chunk deletion file could not be cleaned up. This may have unintended consequences"
+ " on next startup, or if /delchunks is used again.");
}
}
} else {
logger.error("Error occurred while deleting chunks. " +
"If world errors occur, stop the server and restore the *.bak backup files.");
logger.error("Error occurred while deleting chunks. "
+ "If world errors occur, stop the server and restore the *.bak backup files.");
}
}
@ -118,7 +119,7 @@ public final class ChunkDeleter {
}
private final ChunkDeletionInfo chunkDeletionInfo;
private Set<Path> backedUpRegions = new HashSet<>();
private final Set<Path> backedUpRegions = new HashSet<>();
private boolean shouldPreload;
private int debugRate = 100;
private int totalChunksDeleted = 0;
@ -139,7 +140,9 @@ public final class ChunkDeleter {
return regionToChunkList.entrySet().stream().allMatch(entry -> {
Path regionPath = entry.getKey();
if (!Files.exists(regionPath)) return true;
if (!Files.exists(regionPath)) {
return true;
}
if (chunkBatch.backup && !backedUpRegions.contains(regionPath)) {
try {
backupRegion(regionPath);
@ -156,10 +159,10 @@ public final class ChunkDeleter {
Path worldPath = Paths.get(chunkBatch.worldPath);
if (chunkBatch.chunks != null) {
return chunkBatch.chunks.stream()
.collect(Collectors.groupingBy(RegionFilePos::new))
.entrySet().stream().collect(Collectors.toMap(
e -> worldPath.resolve("region").resolve(e.getKey().getFileName()),
e -> e.getValue().stream().sorted(chunkSorter)));
.collect(Collectors.groupingBy(RegionFilePos::new))
.entrySet().stream().collect(Collectors.toMap(
e -> worldPath.resolve("region").resolve(e.getKey().getFileName()),
e -> e.getValue().stream().sorted(chunkSorter)));
} else {
final BlockVector2 minChunk = chunkBatch.minChunk;
final BlockVector2 maxChunk = chunkBatch.maxChunk;
@ -169,7 +172,9 @@ public final class ChunkDeleter {
for (int regX = minRegion.getX(); regX <= maxRegion.getX(); regX++) {
for (int regZ = minRegion.getZ(); regZ <= maxRegion.getZ(); regZ++) {
final Path regionPath = worldPath.resolve("region").resolve(new RegionFilePos(regX, regZ).getFileName());
if (!Files.exists(regionPath)) continue;
if (!Files.exists(regionPath)) {
continue;
}
int startX = regX << 5;
int endX = (regX << 5) + 31;
int startZ = regZ << 5;
@ -180,17 +185,17 @@ public final class ChunkDeleter {
int maxX = Math.min(Math.max(startX, endX), maxChunk.getBlockX());
int maxZ = Math.min(Math.max(startZ, endZ), maxChunk.getBlockZ());
Stream<BlockVector2> stream = Stream.iterate(BlockVector2.at(minX, minZ),
bv2 -> {
int nextX = bv2.getBlockX();
int nextZ = bv2.getBlockZ();
if (++nextX > maxX) {
nextX = minX;
if (++nextZ > maxZ) {
return null;
}
bv2 -> {
int nextX = bv2.getBlockX();
int nextZ = bv2.getBlockZ();
if (++nextX > maxX) {
nextX = minX;
if (++nextZ > maxZ) {
return null;
}
return BlockVector2.at(nextX, nextZ);
});
}
return BlockVector2.at(nextX, nextZ);
});
groupedChunks.put(regionPath, stream);
}
}
@ -199,7 +204,9 @@ public final class ChunkDeleter {
}
private BiPredicate<RegionAccess, BlockVector2> createPredicates(List<ChunkDeletionInfo.DeletionPredicate> deletionPredicates) {
if (deletionPredicates == null) return (r, p) -> true;
if (deletionPredicates == null) {
return (r, p) -> true;
}
return deletionPredicates.stream()
.map(this::createPredicate)
.reduce(BiPredicate::and)
@ -249,7 +256,9 @@ public final class ChunkDeleter {
try (RegionAccess region = new RegionAccess(regionFile, shouldPreload)) {
for (Iterator<BlockVector2> iterator = chunks.iterator(); iterator.hasNext();) {
BlockVector2 chunk = iterator.next();
if (chunk == null) break;
if (chunk == null) {
break;
}
if (deletionPredicate.test(region, chunk)) {
region.deleteChunk(chunk);
totalChunksDeleted++;
@ -322,12 +331,18 @@ public final class ChunkDeleter {
@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;
}
RegionFilePos that = (RegionFilePos) o;
if (x != that.x) return false;
if (x != that.x) {
return false;
}
return z == that.z;
}

View File

@ -40,7 +40,9 @@ public class ChunkDeletionInfo {
public BlockVector2 maxChunk;
public int getChunkCount() {
if (chunks != null) return chunks.size();
if (chunks != null) {
return chunks.size();
}
final BlockVector2 dist = maxChunk.subtract(minChunk).add(1, 1);
return dist.getBlockX() * dist.getBlockZ();
}

View File

@ -42,6 +42,7 @@ public final class BlockStateIdAccess {
public interface BlockStateInternalId {
int getInternalId(BlockState blockState);
void setInternalId(BlockState blockState, int internalId);
}
@ -52,6 +53,7 @@ public final class BlockStateIdAccess {
}
/**
* An invalid internal ID, for verification purposes.
* @return an internal ID which is never valid
*/
public static int invalidId() {
@ -67,7 +69,8 @@ public final class BlockStateIdAccess {
//return blockStateInternalId.getInternalId(holder);
}
public static @Nullable BlockState getBlockStateById(int id) {
@Nullable
public static BlockState getBlockStateById(int id) {
return BlockState.getFromOrdinal(id);
}

View File

@ -69,6 +69,9 @@ public class CommandArgParser {
break;
case QUOTE:
handleQuote(nextPart);
break;
default:
break;
}
}
if (currentArg.size() > 0) {

View File

@ -23,43 +23,43 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.extension.platform.Actor;
public interface CUIRegion {
/**
* Sends CUI events describing the region for
* versions of CUI equal to or greater than the
* value supplied by getProtocolVersion().
*
*
*/
void describeCUI(LocalSession session, Actor player);
/**
* Sends CUI events describing the region for
* versions of CUI smaller than the value
* versions of CUI smaller than the value
* supplied by getProtocolVersion().
*
*
*/
void describeLegacyCUI(LocalSession session, Actor player);
/**
* Returns the CUI version that is required to send
* up-to-date data. If the CUI version is smaller than
* this value, the legacy methods will be called.
*
*
* @return the protocol version
*/
int getProtocolVersion();
/**
* Returns the type ID to send to CUI in the selection event.
*
* @return the type ID
*/
String getTypeID();
/**
* Returns the type ID to send to CUI in the selection
* event if the CUI is in legacy mode.
*
*
* @return the legacy type ID
*/
String getLegacyTypeID();

View File

@ -63,8 +63,12 @@ public class ServerCUIHandler {
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
RegionSelector regionSelector = session.getRegionSelector(player.getWorld());
int posX, posY, posZ;
int width, height, length;
int posX;
int posY;
int posZ;
int width;
int height;
int length;
if (regionSelector instanceof CuboidRegionSelector) {
if (regionSelector.isDefined()) {

View File

@ -25,10 +25,15 @@ package com.sk89q.worldedit.internal.expression;
public interface ExpressionEnvironment {
int getBlockType(double x, double y, double z);
int getBlockData(double x, double y, double z);
int getBlockTypeAbs(double x, double y, double z);
int getBlockDataAbs(double x, double y, double z);
int getBlockTypeRel(double x, double y, double z);
int getBlockDataRel(double x, double y, double z);
}

View File

@ -84,9 +84,8 @@ public class ExpressionHelper {
? (mh.type().parameterCount() - 1) + "+"
: String.valueOf(mh.type().parameterCount()))
.collect(Collectors.joining("/"));
throw evalException(ctx, "Incorrect number of arguments for function '" + fnName + "', " +
"expected " + possibleCounts + ", " +
"got " + ctx.args.size());
throw evalException(ctx, "Incorrect number of arguments for function '" + fnName + "', "
+ "expected " + possibleCounts + ", " + "got " + ctx.args.size());
}
// Special argument handle names

View File

@ -267,10 +267,10 @@ public final class Functions {
for (int i = 0; i < count; ++i) {
double currentX = getBufferItem(megabuf, index) - x;
double currentY = getBufferItem(megabuf, index+1) - y;
double currentZ = getBufferItem(megabuf, index+2) - z;
double currentY = getBufferItem(megabuf, index + 1) - y;
double currentZ = getBufferItem(megabuf, index + 2) - z;
double currentDistanceSquared = currentX*currentX + currentY*currentY + currentZ*currentZ;
double currentDistanceSquared = currentX * currentX + currentY * currentY + currentZ * currentZ;
if (currentDistanceSquared < minDistanceSquared) {
minDistanceSquared = currentDistanceSquared;

View File

@ -475,11 +475,15 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
long aLong = Double.doubleToRawLongBits(a);
// Make aLong lexicographically ordered as a twos-complement long
if (aLong < 0) aLong = 0x8000000000000000L - aLong;
if (aLong < 0) {
aLong = 0x8000000000000000L - aLong;
}
long bLong = Double.doubleToRawLongBits(b);
// Make bLong lexicographically ordered as a twos-complement long
if (bLong < 0) bLong = 0x8000000000000000L - bLong;
if (bLong < 0) {
bLong = 0x8000000000000000L - bLong;
}
final long longDiff = Math.abs(aLong - bLong);
return longDiff <= 450359963L;
@ -555,8 +559,8 @@ class CompilingVisitor extends ExpressionBaseVisitor<MethodHandle> {
value -= arg;
break;
default:
throw ExpressionHelper.evalException(ctx, "Invalid text for assign expr: " +
ctx.assignmentOperator().getText());
throw ExpressionHelper.evalException(ctx, "Invalid text for assign expr: "
+ ctx.assignmentOperator().getText());
}
}
variable.setValue(value);

View File

@ -23,6 +23,8 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import java.util.ArrayList;
import java.util.Collections;
@ -79,7 +81,7 @@ public abstract class AbstractFactory<E> {
}
}
throw new NoMatchException("No match for '" + input + "'");
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
}
public List<String> getSuggestions(String input) {