From 57342c54915ded3a8780064d460d9561ed6f8c3d Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Mon, 4 Sep 2023 20:53:13 +0200 Subject: [PATCH] Cleaned up some code --- .../viaproxy/cli/options/VersionEnumConverter.java | 2 +- .../ViaProxyClassicCustomCommandProvider.java | 2 +- .../java/net/raphimc/viaproxy/util/ArrayHelper.java | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java b/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java index af89783..fdd4bff 100644 --- a/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java +++ b/src/main/java/net/raphimc/viaproxy/cli/options/VersionEnumConverter.java @@ -44,7 +44,7 @@ public class VersionEnumConverter implements ValueConverter { public String valuePattern() { StringBuilder s = new StringBuilder(); for (VersionEnum version : VersionEnum.getAllVersions()) { - s.append((s.length() == 0) ? "" : ", ").append(version.getName()); + s.append((s.isEmpty()) ? "" : ", ").append(version.getName()); } return "[" + s + "]"; } diff --git a/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicCustomCommandProvider.java b/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicCustomCommandProvider.java index 86776c4..36c4f51 100644 --- a/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicCustomCommandProvider.java +++ b/src/main/java/net/raphimc/viaproxy/protocolhack/providers/ViaProxyClassicCustomCommandProvider.java @@ -32,7 +32,7 @@ public class ViaProxyClassicCustomCommandProvider extends ClassicCustomCommandPr if (message.startsWith("/")) { message = message.substring(1); final String[] args = message.split(" "); - if (args.length <= 0) return super.handleChatMessage(user, message); + if (args.length == 0) return super.handleChatMessage(user, message); if (args[0].equals("settime")) { try { if (args.length > 1) { diff --git a/src/main/java/net/raphimc/viaproxy/util/ArrayHelper.java b/src/main/java/net/raphimc/viaproxy/util/ArrayHelper.java index 2dec49e..8b563c0 100644 --- a/src/main/java/net/raphimc/viaproxy/util/ArrayHelper.java +++ b/src/main/java/net/raphimc/viaproxy/util/ArrayHelper.java @@ -346,23 +346,23 @@ public class ArrayHelper { return ""; } - String out = ""; + StringBuilder out = new StringBuilder(); for (int i = start; i <= end; i++) { if (out.isEmpty()) { - out = this.getString(i); + out = new StringBuilder(this.getString(i)); } else { - out += combiner + this.getString(i); + out.append(combiner).append(this.getString(i)); } } - return out; + return out.toString(); } @Override public String toString() { - String complete = ""; + StringBuilder complete = new StringBuilder(); for (String t : this.array) { - complete += (complete.isEmpty() ? "" : ", ") + t; + complete.append((complete.isEmpty()) ? "" : ", ").append(t); } return "[" + complete + "]"; }