diff --git a/Plan/src/main/java/com/djrapitops/plan/data/handling/LoginHandling.java b/Plan/src/main/java/com/djrapitops/plan/data/handling/LoginHandling.java index c92352410..7b459a229 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/handling/LoginHandling.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/handling/LoginHandling.java @@ -1,11 +1,12 @@ package main.java.com.djrapitops.plan.data.handling; +import main.java.com.djrapitops.plan.Phrase; +import main.java.com.djrapitops.plan.data.UserData; + import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.URL; -import main.java.com.djrapitops.plan.Phrase; -import main.java.com.djrapitops.plan.data.UserData; /** * Class containing static methods for processing information contained in a @@ -46,17 +47,17 @@ public class LoginHandling { */ public static void updateGeolocation(InetAddress ip, UserData data) { try { - String result = ""; + StringBuilder result = new StringBuilder(); URL url = new URL("http://freegeoip.net/csv/" + ip.getHostAddress()); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String resultline; while ((resultline = in.readLine()) != null) { - result += resultline + ","; + result.append(resultline).append(","); } in.close(); - String[] results = result.split(","); + String[] results = result.toString().split(","); if (!results[2].isEmpty()) { data.setGeolocation(results[2]); } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java index 5ab898d33..3aae95fae 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/KillsTableCreator.java @@ -2,12 +2,13 @@ package main.java.com.djrapitops.plan.ui.html.tables; import com.djrapitops.plugin.utilities.player.Fetch; import com.djrapitops.plugin.utilities.player.IOfflinePlayer; -import java.util.List; import main.java.com.djrapitops.plan.data.KillData; import main.java.com.djrapitops.plan.ui.html.Html; import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.HtmlUtils; +import java.util.List; + /** * * @author Rsl1122 @@ -20,9 +21,9 @@ public class KillsTableCreator { * @return */ public static String createSortedSessionDataTable10(List killData) { - String html = Html.TABLE_KILLS_START.parse(); + StringBuilder html = new StringBuilder(Html.TABLE_KILLS_START.parse()); if (killData.isEmpty()) { - html += Html.TABLELINE_3.parse(Html.KILLDATA_NONE.parse(), "", ""); + html.append(Html.TABLELINE_3.parse(Html.KILLDATA_NONE.parse(), "", "")); } else { int i = 0; for (KillData kill : killData) { @@ -32,15 +33,15 @@ public class KillsTableCreator { long date = kill.getDate(); IOfflinePlayer victim = Fetch.getIOfflinePlayer(kill.getVictim()); String name = victim.getName(); - html += Html.TABLELINE_3_CUSTOMKEY_1.parse( + html.append(Html.TABLELINE_3_CUSTOMKEY_1.parse( date + "", FormatUtils.formatTimeStamp(date), Html.LINK.parse(HtmlUtils.getInspectUrl(name), name), kill.getWeapon() - ); + )); i++; } } - html += Html.TABLE_END.parse(); - return html; + html.append(Html.TABLE_END.parse()); + return html.toString(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/SessionTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/SessionTableCreator.java index 0fab01083..ee3e2f1ab 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/SessionTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/SessionTableCreator.java @@ -19,9 +19,9 @@ public class SessionTableCreator { * @return */ public static String createSortedSessionDataTable10(List sessionData) { - String html = Html.TABLE_SESSIONS_START.parse(); + StringBuilder html = new StringBuilder(Html.TABLE_SESSIONS_START.parse()); if (sessionData.isEmpty()) { - html += Html.TABLELINE_3.parse(Html.SESSIONDATA_NONE.parse(), "", ""); + html.append(Html.TABLELINE_3.parse(Html.SESSIONDATA_NONE.parse(), "", "")); } else { sessionData.sort(new SessionDataComparator()); Collections.reverse(sessionData); @@ -36,15 +36,15 @@ public class SessionTableCreator { if (length < 0) { continue; } - html += Html.TABLELINE_3_CUSTOMKEY.parse( + html.append(Html.TABLELINE_3_CUSTOMKEY.parse( start + "", FormatUtils.formatTimeStamp(start), end + "", FormatUtils.formatTimeStamp(end), length + "", FormatUtils.formatTimeAmount(length) - ); + )); i++; } } - html += Html.TABLE_END.parse(); - return html; + html.append(Html.TABLE_END.parse()); + return html.toString(); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java index 819115ed0..ce7979b85 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java @@ -1,14 +1,15 @@ package main.java.com.djrapitops.plan.utilities; +import main.java.com.djrapitops.plan.Plan; +import main.java.com.djrapitops.plan.Settings; +import main.java.com.djrapitops.plan.ui.html.Html; + import java.io.File; import java.io.FileNotFoundException; import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.Scanner; -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.Settings; -import main.java.com.djrapitops.plan.ui.html.Html; /** * @@ -35,12 +36,12 @@ public class HtmlUtils { resourceStream = plugin.getResource(fileName); scanner = new Scanner(resourceStream); } - String html = ""; + StringBuilder html = new StringBuilder(); while (scanner.hasNextLine()) { String line = scanner.nextLine(); - html += line + "\r\n"; + html.append(line).append("\r\n"); } - return html; + return html.toString(); } finally { MiscUtils.close(resourceStream, scanner); }