diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/export/HtmlExport.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/export/HtmlExport.java index 65993b756..57468cc71 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/export/HtmlExport.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/export/HtmlExport.java @@ -41,6 +41,7 @@ import com.djrapitops.plan.system.storage.file.PlanFiles; import com.djrapitops.plugin.logging.L; import com.djrapitops.plugin.logging.error.ErrorHandler; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import javax.inject.Inject; import javax.inject.Singleton; @@ -145,7 +146,7 @@ public class HtmlExport extends SpecificExport { .replace("href=\"css/", "href=\"../css/") .replace("src=\"plugins/", "src=\"../plugins/") .replace("src=\"js/", "src=\"../js/"); - List lines = Arrays.asList(html.split("\n")); + List lines = Arrays.asList(StringUtils.split(html, "\n")); File htmlLocation = new File(getFolder(), "players"); Verify.isTrue(htmlLocation.exists() && htmlLocation.isDirectory() || htmlLocation.mkdirs(), diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/PlayerJSONParser.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/PlayerJSONParser.java index b260b93b2..a03654ca1 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/PlayerJSONParser.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/PlayerJSONParser.java @@ -82,9 +82,7 @@ public class PlayerJSONParser { Database db = dbSystem.getDatabase(); Map serverNames = db.query(ServerQueries.fetchServerNames()); - String[] pieColors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(",")) - .map(color -> color.trim().replace("\"", "")) - .toArray(String[]::new); + String[] pieColors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE); PlayerContainer player = db.query(new PlayerContainerQuery(playerUUID)); SessionsMutator sessionsMutator = SessionsMutator.forContainer(player); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/GraphJSONParser.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/GraphJSONParser.java index ab5ae89e0..6c144034f 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/GraphJSONParser.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/GraphJSONParser.java @@ -285,9 +285,7 @@ public class GraphJSONParser { public Map serverPreferencePieJSONAsMap() { long now = System.currentTimeMillis(); long monthAgo = now - TimeUnit.DAYS.toMillis(30L); - String[] pieColors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(",")) - .map(color -> color.trim().replace("\"", "")) - .toArray(String[]::new); + String[] pieColors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE); Map data = new HashMap<>(); data.put("server_pie_colors", pieColors); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/pie/PieGraphFactory.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/pie/PieGraphFactory.java index 62cb10f49..343103c8e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/pie/PieGraphFactory.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/pie/PieGraphFactory.java @@ -26,11 +26,8 @@ import com.djrapitops.plan.system.settings.theme.ThemeVal; import javax.inject.Inject; import javax.inject.Singleton; -import java.util.Arrays; import java.util.Map; -import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; /** * Factory class for different objects representing HTML pie graphs. @@ -52,16 +49,8 @@ public class PieGraphFactory { this.theme = theme; } - public Pie activityPie_old(Map> activityData) { - String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); - Map flatActivityData = activityData.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().size())); - return new ActivityPie(flatActivityData, colors); - } - public Pie activityPie(Map activityData) { - String[] colors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(",")) - .map(color -> color.trim().replace("\"", "")) - .toArray(String[]::new); + String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE); return new ActivityPie(activityData, colors); } @@ -77,9 +66,7 @@ public class PieGraphFactory { WorldAliasSettings worldAliasSettings = config.getWorldAliasSettings(); Map playtimePerAlias = worldAliasSettings.getPlaytimePerAlias(worldTimes); Map gmTimesPerAlias = worldAliasSettings.getGMTimesPerAlias(worldTimes); - String[] colors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(",")) - .map(color -> color.trim().replace("\"", "")) - .toArray(String[]::new); + String[] colors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE); boolean orderByPercentage = config.isTrue(DisplaySettings.ORDER_WORLD_PIE_BY_PERC); return new WorldPie(playtimePerAlias, gmTimesPerAlias, colors, orderByPercentage); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/stack/StackGraphFactory.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/stack/StackGraphFactory.java index d3ca905af..8297a5ac6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/stack/StackGraphFactory.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/rendering/json/graphs/stack/StackGraphFactory.java @@ -24,7 +24,7 @@ import com.djrapitops.plan.utilities.formatting.Formatters; import javax.inject.Inject; import javax.inject.Singleton; -import java.util.*; +import java.util.Map; /** * Factory class for different objects representing HTML stack graphs. @@ -46,15 +46,8 @@ public class StackGraphFactory { this.dayFormatter = formatters.dayLong(); } - public StackGraph activityStackGraph(TreeMap>> activityData) { - String[] colors = theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", "); - return new ActivityStackGraph(activityData, colors, dayFormatter); - } - public StackGraph activityStackGraph(DateMap> activityData) { - String[] colors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(",")) - .map(color -> color.trim().replace("\"", "")) - .toArray(String[]::new); + String[] colors = theme.getPieColors(ThemeVal.GRAPH_ACTIVITY_PIE); return new ActivityStackGraph(activityData, colors, dayFormatter); } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestHandler.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestHandler.java index 9595d9491..5bd1dafe0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestHandler.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestHandler.java @@ -37,6 +37,7 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; +import org.apache.commons.lang3.StringUtils; import javax.inject.Inject; import javax.inject.Singleton; @@ -176,8 +177,8 @@ public class RequestHandler implements HttpHandler { } String authLine = authorization.get(0); - if (authLine.contains("Basic ")) { - return new BasicAuthentication(authLine.split(" ")[1], dbSystem.getDatabase()); + if (StringUtils.contains(authLine, "Basic ")) { + return new BasicAuthentication(StringUtils.split(authLine, ' ')[1], dbSystem.getDatabase()); } return null; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestTarget.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestTarget.java index 7130ea0ee..6089b7516 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestTarget.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/RequestTarget.java @@ -16,6 +16,8 @@ */ package com.djrapitops.plan.system.delivery.webserver; +import org.apache.commons.lang3.StringUtils; + import java.net.URI; import java.util.*; import java.util.stream.Collectors; @@ -33,7 +35,8 @@ public class RequestTarget { public RequestTarget(URI targetURI) { resourceString = targetURI.getPath(); - resource = Arrays.stream(resourceString.split("/")).filter(part -> !part.isEmpty()).collect(Collectors.toList()); + resource = Arrays.stream(StringUtils.split(resourceString, '/')) + .filter(part -> !part.isEmpty()).collect(Collectors.toList()); parameters = new TreeMap<>(); parseParameters(targetURI.getQuery()); @@ -44,12 +47,12 @@ public class RequestTarget { return; } - String[] keysAndValues = parameterString.split("&"); + String[] keysAndValues = StringUtils.split(parameterString, '&'); for (String kv : keysAndValues) { if (kv.isEmpty()) { continue; } - String[] keyAndValue = kv.split("=", 2); + String[] keyAndValue = StringUtils.split(kv, "=", 2); if (keyAndValue.length >= 2) { parameters.put(keyAndValue[0], keyAndValue[1]); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/auth/BasicAuthentication.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/auth/BasicAuthentication.java index 6f4cd8eea..25bf1a14b 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/auth/BasicAuthentication.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/auth/BasicAuthentication.java @@ -24,6 +24,7 @@ import com.djrapitops.plan.system.storage.database.Database; import com.djrapitops.plan.system.storage.database.queries.objects.WebUserQueries; import com.djrapitops.plan.utilities.Base64Util; import com.djrapitops.plan.utilities.PassEncryptUtil; +import org.apache.commons.lang3.StringUtils; /** * Authentication handling for Basic Auth. @@ -47,7 +48,7 @@ public class BasicAuthentication implements Authentication { public WebUser getWebUser() throws WebUserAuthException { String decoded = Base64Util.decode(authenticationString); - String[] userInfo = decoded.split(":"); + String[] userInfo = StringUtils.split(decoded, ':'); if (userInfo.length != 2) { throw new WebUserAuthException(FailReason.USER_AND_PASS_NOT_SPECIFIED); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/FileResponse.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/FileResponse.java index 0911b19e5..9048d56f6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/FileResponse.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/FileResponse.java @@ -18,6 +18,7 @@ package com.djrapitops.plan.system.delivery.webserver.response; import com.djrapitops.plan.system.storage.file.PlanFiles; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; @@ -36,7 +37,7 @@ public class FileResponse extends Response { } public static String format(String fileName) { - String[] split = fileName.split("/"); + String[] split = StringUtils.split(fileName, '/'); int i; for (i = 0; i < split.length; i++) { String s = split[i]; @@ -47,7 +48,7 @@ public class FileResponse extends Response { StringBuilder b = new StringBuilder("web"); for (int j = i; j < split.length; j++) { String s = split[j]; - b.append("/").append(s); + b.append('/').append(s); } return b.toString(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/Response.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/Response.java index f82100d8c..81487ccff 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/Response.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/Response.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.system.settings.locale.Locale; import com.djrapitops.plan.system.settings.theme.Theme; import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; +import org.apache.commons.lang3.StringUtils; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -55,9 +56,14 @@ public abstract class Response { } public Optional getHeader(String called) { - for (String header : header.split("\r\n")) { - if (header.startsWith(called)) { - return Optional.of(header.split(": ")[1]); + if (header != null) { + for (String header : StringUtils.split(header, "\r\n")) { + if (called == null) { + return Optional.of(header); + } + if (StringUtils.startsWith(header, called)) { + return Optional.of(StringUtils.split(header, ':')[1].trim()); + } } } return Optional.empty(); @@ -84,7 +90,7 @@ public abstract class Response { } public int getCode() { - return header == null ? 500 : Integer.parseInt(header.split(" ")[1]); + return getHeader(null).map(h -> Integer.parseInt(StringUtils.split(h, ' ')[1])).orElse(500); } @Override diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/errors/ErrorResponse.java b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/errors/ErrorResponse.java index 384d01887..d87a6db0e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/errors/ErrorResponse.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/delivery/webserver/response/errors/ErrorResponse.java @@ -19,6 +19,7 @@ package com.djrapitops.plan.system.delivery.webserver.response.errors; import com.djrapitops.plan.system.delivery.webserver.response.pages.PageResponse; import com.djrapitops.plan.system.storage.file.PlanFiles; import com.djrapitops.plan.system.version.VersionCheckSystem; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringSubstitutor; import java.io.IOException; @@ -50,7 +51,7 @@ public class ErrorResponse extends PageResponse { public void replacePlaceholders() { Map placeholders = new HashMap<>(); placeholders.put("title", title); - String[] split = title.split(">", 3); + String[] split = StringUtils.split(title, ">", 3); placeholders.put("titleText", split.length == 3 ? split[2] : title); placeholders.put("paragraph", paragraph); placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton())); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/gathering/domain/GeoInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/system/gathering/domain/GeoInfo.java index 00fd0290f..b53682c50 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/gathering/domain/GeoInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/gathering/domain/GeoInfo.java @@ -18,6 +18,7 @@ package com.djrapitops.plan.system.gathering.domain; import com.djrapitops.plan.system.delivery.domain.DateHolder; import com.djrapitops.plan.system.delivery.domain.DateMap; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.net.Inet6Address; @@ -61,7 +62,7 @@ public class GeoInfo implements DateHolder, Serializable { if (address instanceof Inet6Address) { StringBuilder b = new StringBuilder(); int i = 0; - for (String part : ip.split(":")) { + for (String part : StringUtils.split(ip, ':')) { if (i >= 3) { break; } @@ -75,7 +76,7 @@ public class GeoInfo implements DateHolder, Serializable { } else { StringBuilder b = new StringBuilder(); int i = 0; - for (String part : ip.split("\\.")) { + for (String part : StringUtils.split(ip, '.')) { if (i >= 2) { break; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java index ea0c9ee4b..00fa74436 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigNode.java @@ -24,6 +24,7 @@ package com.djrapitops.plan.system.settings.config; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.util.*; @@ -78,7 +79,7 @@ public class ConfigNode { } private String[] splitPathInTwo(String path) { - String[] split = path.split("\\.", 2); + String[] split = StringUtils.split(path, "\\.", 2); if (split.length <= 1) { return new String[]{split[0], ""}; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigReader.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigReader.java index f10b8d707..2d1325c59 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigReader.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigReader.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.system.settings.config; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import java.io.*; import java.nio.charset.StandardCharsets; @@ -144,7 +145,7 @@ public class ConfigReader implements Closeable { private ConfigNode parseNode(String line) { // Parse a node "Key: value" - String[] keyAndValue = line.split(":", 2); + String[] keyAndValue = StringUtils.split(line, ":", 2); if (keyAndValue.length <= 1) { return handleMultiline(line); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java index ead1610bb..e5cb0d2f1 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.system.settings.config; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import java.util.ArrayList; @@ -161,7 +162,7 @@ public interface ConfigValueParser { @Override public List compose(String fromValue) { List values = new ArrayList<>(); - for (String line : fromValue.split("\\n")) { + for (String line : StringUtils.split(fromValue, "\\n")) { if (line.trim().isEmpty()) { continue; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigWriter.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigWriter.java index 1b6ceb0b8..ec95179e4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigWriter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigWriter.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.system.settings.config; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -110,10 +111,10 @@ public class ConfigWriter { if (value == null || value.isEmpty()) { addKey(key, lines); - } else if (value.contains("\n")) { + } else if (StringUtils.contains(value, "\n")) { // List values include newline characters, // see ConfigValueParser.StringListParser - addListValue(key, value.split("\\n"), lines); + addListValue(key, StringUtils.split(value, "\\n"), lines); } else { addNormalValue(key, value, lines); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java index 95f4efbe7..6a51c496e 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/theme/Theme.java @@ -27,6 +27,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import static com.djrapitops.plan.system.settings.theme.ThemeVal.*; @@ -62,6 +63,12 @@ public class Theme implements SubSystem { } } + public String[] getPieColors(ThemeVal variable) { + return Arrays.stream(StringUtils.split(getValue(variable), ',')) + .map(color -> StringUtils.remove(StringUtils.trim(color), '"')) + .toArray(String[]::new); + } + @Override public void enable() throws EnableException { try { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/storage/file/PlanFiles.java b/Plan/common/src/main/java/com/djrapitops/plan/system/storage/file/PlanFiles.java index b7eba5873..35f874109 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/storage/file/PlanFiles.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/storage/file/PlanFiles.java @@ -20,6 +20,7 @@ import com.djrapitops.plan.PlanPlugin; import com.djrapitops.plan.exceptions.EnableException; import com.djrapitops.plan.system.SubSystem; import com.djrapitops.plugin.utilities.Verify; +import org.apache.commons.lang3.StringUtils; import javax.inject.Inject; import javax.inject.Singleton; @@ -120,7 +121,7 @@ public class PlanFiles implements SubSystem { private Optional attemptToFind(String resourceName) { if (dataFolder.exists() && dataFolder.isDirectory()) { - String[] path = resourceName.split("/"); + String[] path = StringUtils.split(resourceName, '/'); Path toFile = dataFolder.getAbsoluteFile().toPath().toAbsolutePath(); for (String next : path) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/version/VersionInfoLoader.java b/Plan/common/src/main/java/com/djrapitops/plan/system/version/VersionInfoLoader.java index bf22133f1..67e244d73 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/version/VersionInfoLoader.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/version/VersionInfoLoader.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.system.version; import com.djrapitops.plugin.api.utility.Version; +import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.net.URL; @@ -70,7 +71,7 @@ public class VersionInfoLoader { if (!line.startsWith("REL") && !line.startsWith("DEV")) { return Optional.empty(); } - String[] parts = line.split("\\|"); + String[] parts = StringUtils.split(line, '|'); if (parts.length < 4) { return Optional.empty(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java index 596ee1df3..89ace6b39 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/PassEncryptUtil.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.utilities; import com.djrapitops.plan.exceptions.PassEncryptException; +import org.apache.commons.lang3.StringUtils; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; @@ -82,7 +83,7 @@ public class PassEncryptUtil { private static boolean verifyPassword(char[] password, String correctHash) throws CannotPerformOperationException, InvalidHashException { // Decode the hash into its parameters - String[] params = correctHash.split(":"); + String[] params = StringUtils.split(correctHash, ':'); if (params.length != HASH_SECTIONS) { throw new InvalidHashException( "Fields are missing from the password hash." diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/ItemNameFormatter.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/ItemNameFormatter.java index 14c404a3f..0afa71fab 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/ItemNameFormatter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/formatting/ItemNameFormatter.java @@ -17,6 +17,7 @@ package com.djrapitops.plan.utilities.formatting; import com.djrapitops.plugin.utilities.Format; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.TextStringBuilder; import java.util.Arrays; @@ -30,7 +31,7 @@ public class ItemNameFormatter implements Formatter { @Override public String apply(String name) { - String[] parts = name.split("_"); + String[] parts = StringUtils.split(name, '_'); TextStringBuilder builder = new TextStringBuilder(); builder.appendWithSeparators(Arrays.stream(parts).map(part -> new Format(part).capitalize()).iterator(), " "); return builder.toString();