Resolve IntelliJ recommended defects and increment paper version

This commit is contained in:
Michael Ziluck 2019-05-31 23:35:11 -05:00
parent 18e199bc2a
commit 3a25d70762
7 changed files with 14 additions and 20 deletions

View File

@ -15,7 +15,7 @@
<dependency> <dependency>
<groupId>com.destroystokyo.paper</groupId> <groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.14.1-R0.1-SNAPSHOT</version> <version>1.14.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -133,7 +133,7 @@ public class CommandArgumentBuilder<T>
public static <T> CommandArgumentBuilder<T> createBuilder(Class<T> type) public static <T> CommandArgumentBuilder<T> createBuilder(Class<T> type)
{ {
return new CommandArgumentBuilder<T>(); return new CommandArgumentBuilder<>();
} }
} }

View File

@ -170,7 +170,7 @@ public abstract class ValidBaseCommand extends ValidCommand
* @param sender the sender of the command. * @param sender the sender of the command.
* @param label the labels that this command has. * @param label the labels that this command has.
*/ */
public void help(CommandSender sender, String label[]) public void help(CommandSender sender, String[] label)
{ {
List<ValidCommand> allowedSubs = new LinkedList<>(); List<ValidCommand> allowedSubs = new LinkedList<>();
for (ValidCommand sub : subCommands) for (ValidCommand sub : subCommands)

View File

@ -261,7 +261,7 @@ public abstract class ValidCommand
} }
else else
{ {
return Arrays.asList(); return Collections.emptyList();
} }
} }
else else
@ -473,11 +473,11 @@ public abstract class ValidCommand
*/ */
protected boolean matches(String label) protected boolean matches(String label)
{ {
label = label.toLowerCase();
if (label == null) if (label == null)
{ {
return false; return false;
} }
label = label.toLowerCase();
if (label.equals(getName())) if (label.equals(getName()))
{ {
return true; return true;

View File

@ -198,7 +198,7 @@ public class CollectionUtils
*/ */
public static <T> T randomValue(Collection<T> collection) public static <T> T randomValue(Collection<T> collection)
{ {
return randomValue(collection, null); return randomValue(collection, (T) null);
} }
/** /**
@ -210,6 +210,7 @@ public class CollectionUtils
* *
* @return a random value from the collection. * @return a random value from the collection.
*/ */
@SafeVarargs
public static <T> T randomValue(Collection<T> collection, T... ignored) public static <T> T randomValue(Collection<T> collection, T... ignored)
{ {
// if it's null or empty, we don't care // if it's null or empty, we don't care

View File

@ -11,7 +11,7 @@ public class StringUtils
for (int i = start; i < end; i++) for (int i = start; i < end; i++)
{ {
sb.append(strings[i] + " "); sb.append(strings[i]).append(" ");
} }
return sb.toString().trim(); return sb.toString().trim();
@ -20,10 +20,7 @@ public class StringUtils
public static String[] add(String[] array, String add) public static String[] add(String[] array, String add)
{ {
String[] values = new String[array.length + 1]; String[] values = new String[array.length + 1];
for (int i = 0; i < array.length; i++) System.arraycopy(array, 0, values, 0, array.length);
{
values[i] = array[i];
}
values[array.length] = add; values[array.length] = add;
return values; return values;
} }
@ -49,11 +46,11 @@ public class StringUtils
return str; return str;
} }
final int newCodePoints[] = new int[strLen]; // cannot be longer than final int[] newCodePoints = new int[strLen]; // cannot be longer than
// the char array // the char array
int outOffset = 0; int outOffset = 0;
newCodePoints[outOffset++] = newCodePoint; // copy the first codepoint newCodePoints[outOffset++] = newCodePoint; // copy the first codepoint
for (int inOffset = Character.charCount(firstCodepoint); inOffset < strLen;) for (int inOffset = Character.charCount(firstCodepoint); inOffset < strLen; )
{ {
final int codepoint = str.codePointAt(inOffset); final int codepoint = str.codePointAt(inOffset);
newCodePoints[outOffset++] = codepoint; // copy the remaining ones newCodePoints[outOffset++] = codepoint; // copy the remaining ones

View File

@ -259,15 +259,11 @@ public class ItemDb
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) try (final BufferedReader reader = new BufferedReader(new FileReader(file)))
{ {
final List<String> lines = new ArrayList<>(9000); final List<String> lines = new ArrayList<>(9000);
String line = null; String line;
do while ((line = reader.readLine()) != null)
{ {
if ((line = reader.readLine()) == null)
{
break;
}
lines.add(line); lines.add(line);
} while (true); }
return lines; return lines;
} }
catch (IOException ex) catch (IOException ex)