diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/HookHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/HookHandler.java index d2259b13f..784785c1d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/HookHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/HookHandler.java @@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.data.additional; import com.djrapitops.pluginbridge.plan.Bridge; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.*; @@ -52,7 +53,7 @@ public class HookHandler { configHandler.createSection(dataSource); } if (configHandler.isEnabled(dataSource)) { - Log.debug("Registered a new datasource: " + dataSource.getPlaceholder("").replace("%", "")); + Log.debug("Registered a new datasource: " + StringUtils.remove(dataSource.getPlaceholder(""), '%')); additionalDataSources.add(dataSource); } } catch (Exception e) { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/Database.java b/Plan/src/main/java/com/djrapitops/plan/database/Database.java index 47b9d2e32..3d192a132 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/Database.java @@ -4,6 +4,7 @@ import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.database.tables.*; import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.lang3.StringUtils; import java.sql.Connection; import java.sql.SQLException; @@ -150,7 +151,7 @@ public abstract class Database { * @return sqlite/mysql */ public String getConfigName() { - return getName().toLowerCase().replace(" ", ""); + return StringUtils.remove(getName().toLowerCase(), ' '); } public abstract boolean isNewDatabase() throws SQLException; diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index b313d517f..14465fdf4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.utilities; import com.djrapitops.plugin.utilities.Format; import com.djrapitops.plugin.utilities.FormattingUtils; import main.java.com.djrapitops.plan.Settings; +import org.apache.commons.lang3.StringUtils; import org.bukkit.Location; import java.text.DecimalFormat; @@ -136,7 +137,7 @@ public class FormatUtils { } builder.append(s); } - String formattedTime = builder.toString().replace("%zero%", ""); + String formattedTime = StringUtils.remove(builder.toString(), "%zero%"); if (formattedTime.isEmpty()) { return Settings.FORMAT_SECONDS.toString().replace("%seconds%", "0"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index fe8f10e65..2b038f537 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -28,6 +28,7 @@ import main.java.com.djrapitops.plan.utilities.comparators.UserInfoLastPlayedCom import main.java.com.djrapitops.plan.utilities.html.HtmlStructure; import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import main.java.com.djrapitops.plan.utilities.html.tables.PlayersTableCreator; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.sql.SQLException; @@ -191,7 +192,7 @@ public class Analysis { Log.debug("Analysis", "Additional Sources: " + sources.size()); sources.parallelStream().filter(Verify::notNull).forEach(source -> { try { - Benchmark.start("Source " + source.getPlaceholder("").replace("%", "")); + Benchmark.start("Source " + StringUtils.remove(source.getPlaceholder(""), '%')); final List analysisTypes = source.getAnalysisTypes(); if (analysisTypes.isEmpty()) { return; @@ -217,11 +218,11 @@ public class Analysis { replaceMap.put(source.getPlaceholder(boolTot.getPlaceholderModifier()), AnalysisUtils.getBooleanTotal(boolTot, source, uuids)); } } catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) { - Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", "")); + Log.error("A PluginData-source caused an exception: " + StringUtils.remove(source.getPlaceholder(""), '%')); Log.toLog(this.getClass().getName(), e); } finally { - Benchmark.stop("Analysis", "Source " + source.getPlaceholder("").replace("%", "")); + Benchmark.stop("Analysis", "Source " + StringUtils.remove(source.getPlaceholder(""), '%')); } }); Benchmark.stop("Analysis", "3rd party"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java index 286565dd9..1d5888451 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/AnalysisUtils.java @@ -7,6 +7,7 @@ import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.comparators.SessionLengthComparator; +import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.*; @@ -194,8 +195,10 @@ public class AnalysisUtils { } private static String logPluginDataCausedError(PluginData source, Throwable e) { - Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", "")); - Log.toLog("PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""), e); + String placeholder = StringUtils.remove(source.getPlaceholder(""), '%'); + + Log.error("A PluginData-source caused an exception: " + placeholder); + Log.toLog("PluginData-source caused an exception: " + placeholder, e); return source.parseContainer("", "Exception during calculation."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java index 72ceee668..cd69563dc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlUtils.java @@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.utilities.html; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.systems.webserver.WebServer; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.text.StrSubstitutor; import java.io.Serializable; @@ -93,7 +94,7 @@ public class HtmlUtils { * @return */ public static String removeXSS(String string) { - return string.replaceAll("()|()", ""); + return StringUtils.removeAll(string,"()|()"); } /** @@ -114,7 +115,7 @@ public class HtmlUtils { string = Html.SPAN.parse(string); } - return string.replace("§r", ""); + return StringUtils.remove(string, "§r"); } public static String separateWithQuotes(String... strings) { diff --git a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java index 6b80d8a5e..fb5366427 100644 --- a/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/ui/graphs/GraphTest.java @@ -9,6 +9,7 @@ import main.java.com.djrapitops.plan.data.TPS; import main.java.com.djrapitops.plan.data.time.WorldTimes; import main.java.com.djrapitops.plan.utilities.analysis.Point; import main.java.com.djrapitops.plan.utilities.html.graphs.*; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; import test.java.utils.RandomData; @@ -57,7 +58,7 @@ public class GraphTest { @Test public void testSeriesCreator() { - String result = SeriesCreator.seriesGraph(points, false, false).replaceAll("[\\[\\]]", ""); + String result = StringUtils.removeAll(SeriesCreator.seriesGraph(points, false, false), "[\\[\\]]"); String[] splittedResult = result.split(","); Map expected = new LinkedHashMap<>();