From 336e411e10cf005c2a3acd106f48406ab1c6ff95 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 29 Jan 2020 17:53:34 -0500 Subject: [PATCH] Minor code changes --- .../src/main/java/com/sk89q/jnbt/DoubleTag.java | 2 +- .../src/main/java/com/sk89q/jnbt/IntArrayTag.java | 4 ++-- .../src/main/java/com/sk89q/jnbt/ListTag.java | 6 +++--- .../src/main/java/com/sk89q/jnbt/LongArrayTag.java | 4 ++-- .../src/main/java/com/sk89q/jnbt/LongTag.java | 2 +- .../src/main/java/com/sk89q/jnbt/NBTConstants.java | 5 +++-- .../src/main/java/com/sk89q/jnbt/NBTInputStream.java | 6 +++--- .../sk89q/minecraft/util/commands/CommandContext.java | 10 +++++----- .../minecraft/util/commands/CommandException.java | 2 +- .../sk89q/minecraft/util/commands/CommandLocals.java | 4 ---- .../sk89q/minecraft/util/commands/CommandsManager.java | 6 +++--- .../sk89q/minecraft/util/commands/SimpleInjector.java | 2 +- .../sk89q/minecraft/util/commands/package-info.java | 2 +- .../regions/selector/CuboidRegionSelector.java | 4 ++-- 14 files changed, 28 insertions(+), 31 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java index ca27de1e7..f18d648b7 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/DoubleTag.java @@ -21,7 +21,7 @@ package com.sk89q.jnbt; /** * The {@code TAG_Double} tag. - * + * */ public final class DoubleTag extends NumberTag { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java index b4fa50a20..4ef19f877 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/IntArrayTag.java @@ -19,10 +19,10 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.Locale; +import static com.google.common.base.Preconditions.checkNotNull; + /** * The {@code TAG_Int_Array} tag. */ diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java index 205492f8c..ed309870a 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/ListTag.java @@ -30,7 +30,7 @@ import javax.annotation.Nullable; /** * The {@code TAG_List} tag. */ -public class ListTag extends Tag { +public final class ListTag extends Tag { @Override public int getTypeCode() { @@ -79,7 +79,7 @@ public class ListTag extends Tag { /** * Get the tag if it exists at the given index. - * + * * @param index the index * @return the tag or null */ @@ -437,7 +437,7 @@ public class ListTag extends Tag { @Override public String toString() { StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(type.getTypeName()).append("\r\n{\r\n"); + bldr.append("TAG_List").append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n"); for (Tag t : value) { bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java index f5139cfc4..e9622c601 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongArrayTag.java @@ -19,10 +19,10 @@ package com.sk89q.jnbt; -import static com.google.common.base.Preconditions.checkNotNull; - import java.util.Locale; +import static com.google.common.base.Preconditions.checkNotNull; + /** * The {@code TAG_Long_Array} tag. */ diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java index c3fe1cb04..bf4911a9c 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/LongTag.java @@ -21,7 +21,7 @@ package com.sk89q.jnbt; /** * The {@code TAG_Long} tag. - * + * */ public final class LongTag extends NumberTag { @Override diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java index 02ec68789..c73ab5184 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTConstants.java @@ -40,10 +40,10 @@ public final class NBTConstants { private NBTConstants() { } - + /** * Convert a type ID to its corresponding {@link Tag} class. - * + * * @param id type ID * @return tag class * @throws IllegalArgumentException thrown if the tag ID is not valid @@ -80,4 +80,5 @@ public final class NBTConstants { throw new IllegalArgumentException("Unknown tag type ID of " + id); } } + } diff --git a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java index e74ca6c7d..5418eca52 100644 --- a/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java +++ b/worldedit-core/src/main/java/com/sk89q/jnbt/NBTInputStream.java @@ -36,7 +36,7 @@ import java.util.Map; * This class reads NBT, or Named Binary Tag * streams, and produces an object graph of subclasses of the {@code Tag} * object. - * + * *

The NBT format was created by Markus Persson, and the specification may be * found at * http://www.minecraft.net/docs/NBT.txt.

@@ -48,7 +48,7 @@ public final class NBTInputStream implements Closeable { /** * Creates a new {@code NBTInputStream}, which will source its data * from the specified input stream. - * + * * @param is the input stream */ public NBTInputStream(InputStream is) { @@ -61,7 +61,7 @@ public final class NBTInputStream implements Closeable { /** * Reads an NBT tag from the stream. - * + * * @return The tag that was read. * @throws IOException if an I/O error occurs. */ diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java index 69bd40894..9dfc58d6f 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandContext.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Set; public class CommandContext { - + protected final String command; protected final List parsedArgs; @@ -55,7 +55,7 @@ public class CommandContext { this(args.split(" ", -1), valueFlags); } - public CommandContext(String args, Set valueFlags, boolean allowHangingFlag) + public CommandContext(String args, Set valueFlags, boolean allowHangingFlag) throws CommandException { this(args.split(" ", -1), valueFlags, allowHangingFlag, new CommandLocals()); } @@ -107,7 +107,7 @@ public class CommandContext { List argList = new ArrayList<>(args.length); for (int i = 1; i < args.length; ++i) { isHanging = false; - + String arg = args[i]; if (arg.isEmpty()) { isHanging = true; @@ -216,7 +216,7 @@ public class CommandContext { parsedArgs.add(arg); } } - + this.suggestionContext = suggestionContext; } @@ -248,7 +248,7 @@ public class CommandContext { } return buffer.toString(); } - + public String getRemainingString(int start) { return getString(start, parsedArgs.size() - 1); } diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java index e6834fdb8..4345793d1 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandException.java @@ -53,7 +53,7 @@ public class CommandException extends Exception { /** * Gets the command that was called, which will include the sub-command - * (i.e., "/br sphere"). + * (i.e. "/br sphere"). * * @param prefix the command shebang character (such as "/") -- may be empty * @param spacedSuffix a suffix to put at the end (optional) -- may be null diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandLocals.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandLocals.java index 40441aa09..0bc2992a5 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandLocals.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandLocals.java @@ -47,8 +47,4 @@ public class CommandLocals { return locals.put(key, value); } - public Object putIfAbsent(Object key, Object value) { - return locals.putIfAbsent(key, value); - } - } diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java index 592266eb3..e5153a1b2 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/CommandsManager.java @@ -20,6 +20,9 @@ package com.sk89q.minecraft.util.commands; import com.sk89q.util.StringUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -30,9 +33,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import org.enginehub.piston.inject.InjectedValueAccess; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Manager for handling commands. This allows you to easily process commands, diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java index 4ffefe26a..652c69a5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java @@ -50,4 +50,4 @@ public class SimpleInjector implements Injector { return null; } } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/package-info.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/package-info.java index 3312b9241..4b74b1b1e 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/package-info.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/package-info.java @@ -22,4 +22,4 @@ * to Piston, Intake, ACF, or similar systems. */ @Deprecated -package com.sk89q.minecraft.util.commands; \ No newline at end of file +package com.sk89q.minecraft.util.commands; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index 63ba9a430..1a4cecc71 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -129,7 +129,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) { checkNotNull(position); - if (position.equals(position1)) { + if (position1 != null && position.equals(position1)) { return false; } @@ -142,7 +142,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion { public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) { checkNotNull(position); - if (position.equals(position2)) { + if (position2 != null && position.equals(position2)) { return false; }