Minor code changes

This commit is contained in:
MattBDev 2020-01-29 17:53:34 -05:00
parent 7236b0a026
commit 336e411e10
14 changed files with 28 additions and 31 deletions

View File

@ -21,7 +21,7 @@ package com.sk89q.jnbt;
/** /**
* The {@code TAG_Double} tag. * The {@code TAG_Double} tag.
* *
*/ */
public final class DoubleTag extends NumberTag { public final class DoubleTag extends NumberTag {
@Override @Override

View File

@ -19,10 +19,10 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Locale; import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* The {@code TAG_Int_Array} tag. * The {@code TAG_Int_Array} tag.
*/ */

View File

@ -30,7 +30,7 @@ import javax.annotation.Nullable;
/** /**
* The {@code TAG_List} tag. * The {@code TAG_List} tag.
*/ */
public class ListTag extends Tag { public final class ListTag extends Tag {
@Override @Override
public int getTypeCode() { public int getTypeCode() {
@ -79,7 +79,7 @@ public class ListTag extends Tag {
/** /**
* Get the tag if it exists at the given index. * Get the tag if it exists at the given index.
* *
* @param index the index * @param index the index
* @return the tag or null * @return the tag or null
*/ */
@ -437,7 +437,7 @@ public class ListTag extends Tag {
@Override @Override
public String toString() { public String toString() {
StringBuilder bldr = new StringBuilder(); 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) { for (Tag t : value) {
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
} }

View File

@ -19,10 +19,10 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Locale; import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* The {@code TAG_Long_Array} tag. * The {@code TAG_Long_Array} tag.
*/ */

View File

@ -21,7 +21,7 @@ package com.sk89q.jnbt;
/** /**
* The {@code TAG_Long} tag. * The {@code TAG_Long} tag.
* *
*/ */
public final class LongTag extends NumberTag { public final class LongTag extends NumberTag {
@Override @Override

View File

@ -40,10 +40,10 @@ public final class NBTConstants {
private NBTConstants() { private NBTConstants() {
} }
/** /**
* Convert a type ID to its corresponding {@link Tag} class. * Convert a type ID to its corresponding {@link Tag} class.
* *
* @param id type ID * @param id type ID
* @return tag class * @return tag class
* @throws IllegalArgumentException thrown if the tag ID is not valid * @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); throw new IllegalArgumentException("Unknown tag type ID of " + id);
} }
} }
} }

View File

@ -36,7 +36,7 @@ import java.util.Map;
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong> * This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
* streams, and produces an object graph of subclasses of the {@code Tag} * streams, and produces an object graph of subclasses of the {@code Tag}
* object. * object.
* *
* <p>The NBT format was created by Markus Persson, and the specification may be * <p>The NBT format was created by Markus Persson, and the specification may be
* found at <a href="http://www.minecraft.net/docs/NBT.txt"> * found at <a href="http://www.minecraft.net/docs/NBT.txt">
* http://www.minecraft.net/docs/NBT.txt</a>.</p> * http://www.minecraft.net/docs/NBT.txt</a>.</p>
@ -48,7 +48,7 @@ public final class NBTInputStream implements Closeable {
/** /**
* Creates a new {@code NBTInputStream}, which will source its data * Creates a new {@code NBTInputStream}, which will source its data
* from the specified input stream. * from the specified input stream.
* *
* @param is the input stream * @param is the input stream
*/ */
public NBTInputStream(InputStream is) { public NBTInputStream(InputStream is) {
@ -61,7 +61,7 @@ public final class NBTInputStream implements Closeable {
/** /**
* Reads an NBT tag from the stream. * Reads an NBT tag from the stream.
* *
* @return The tag that was read. * @return The tag that was read.
* @throws IOException if an I/O error occurs. * @throws IOException if an I/O error occurs.
*/ */

View File

@ -28,7 +28,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
public class CommandContext { public class CommandContext {
protected final String command; protected final String command;
protected final List<String> parsedArgs; protected final List<String> parsedArgs;
@ -55,7 +55,7 @@ public class CommandContext {
this(args.split(" ", -1), valueFlags); this(args.split(" ", -1), valueFlags);
} }
public CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag) public CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag)
throws CommandException { throws CommandException {
this(args.split(" ", -1), valueFlags, allowHangingFlag, new CommandLocals()); this(args.split(" ", -1), valueFlags, allowHangingFlag, new CommandLocals());
} }
@ -107,7 +107,7 @@ public class CommandContext {
List<String> argList = new ArrayList<>(args.length); List<String> argList = new ArrayList<>(args.length);
for (int i = 1; i < args.length; ++i) { for (int i = 1; i < args.length; ++i) {
isHanging = false; isHanging = false;
String arg = args[i]; String arg = args[i];
if (arg.isEmpty()) { if (arg.isEmpty()) {
isHanging = true; isHanging = true;
@ -216,7 +216,7 @@ public class CommandContext {
parsedArgs.add(arg); parsedArgs.add(arg);
} }
} }
this.suggestionContext = suggestionContext; this.suggestionContext = suggestionContext;
} }
@ -248,7 +248,7 @@ public class CommandContext {
} }
return buffer.toString(); return buffer.toString();
} }
public String getRemainingString(int start) { public String getRemainingString(int start) {
return getString(start, parsedArgs.size() - 1); return getString(start, parsedArgs.size() - 1);
} }

View File

@ -53,7 +53,7 @@ public class CommandException extends Exception {
/** /**
* Gets the command that was called, which will include the sub-command * 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 prefix the command shebang character (such as "/") -- may be empty
* @param spacedSuffix a suffix to put at the end (optional) -- may be null * @param spacedSuffix a suffix to put at the end (optional) -- may be null

View File

@ -47,8 +47,4 @@ public class CommandLocals {
return locals.put(key, value); return locals.put(key, value);
} }
public Object putIfAbsent(Object key, Object value) {
return locals.putIfAbsent(key, value);
}
} }

View File

@ -20,6 +20,9 @@
package com.sk89q.minecraft.util.commands; package com.sk89q.minecraft.util.commands;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -30,9 +33,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; 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, * Manager for handling commands. This allows you to easily process commands,

View File

@ -50,4 +50,4 @@ public class SimpleInjector implements Injector {
return null; return null;
} }
} }
} }

View File

@ -22,4 +22,4 @@
* to Piston, Intake, ACF, or similar systems. * to Piston, Intake, ACF, or similar systems.
*/ */
@Deprecated @Deprecated
package com.sk89q.minecraft.util.commands; package com.sk89q.minecraft.util.commands;

View File

@ -129,7 +129,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) { public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
checkNotNull(position); checkNotNull(position);
if (position.equals(position1)) { if (position1 != null && position.equals(position1)) {
return false; return false;
} }
@ -142,7 +142,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) { public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
checkNotNull(position); checkNotNull(position);
if (position.equals(position2)) { if (position2 != null && position.equals(position2)) {
return false; return false;
} }