diff --git a/Plan/src/main/java/com/djrapitops/plan/Phrase.java b/Plan/src/main/java/com/djrapitops/plan/Phrase.java index 1406fba2c..f6194d500 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Phrase.java +++ b/Plan/src/main/java/com/djrapitops/plan/Phrase.java @@ -179,7 +179,7 @@ public enum Phrase { public String parse(String... p) { String returnValue = this.toString(); for (int i = 0; i < p.length; i++) { - returnValue = returnValue.replaceAll("REPLACE" + i, p[i]); + returnValue = returnValue.replace("REPLACE" + i, p[i]); } return returnValue; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java index d5f98866b..4bd1fb7bd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java @@ -81,7 +81,7 @@ public class UserData { isBanned = player.isBanned(); } catch (Exception e) { Plan plugin = getPlugin(Plan.class); - plugin.logError("Error getting ban date from Bukkit files. "+uuid.toString()); + plugin.logError("Error getting ban date from Bukkit files. " + uuid.toString()); plugin.toLog(this.getClass().getName(), e); } name = player.getName(); @@ -118,7 +118,7 @@ public class UserData { isBanned = player.isBanned(); } catch (Exception e) { Plan plugin = getPlugin(Plan.class); - plugin.logError("Error getting ban date from Bukkit files. "+uuid.toString()); + plugin.logError("Error getting ban date from Bukkit files. " + uuid.toString()); plugin.toLog(this.getClass().getName(), e); } name = player.getName(); @@ -130,6 +130,7 @@ public class UserData { /** * Creates a new UserData object with copied values. + * * @param data UserData to copy into the new object. */ public UserData(UserData data) { @@ -164,7 +165,7 @@ public class UserData { this.sessions = new ArrayList<>(); sessions.addAll(data.getSessions()); } - + /** * * @param ip @@ -210,9 +211,11 @@ public class UserData { */ public boolean addNickname(String nick) { if (!nicknames.contains(nick)) { - if (!nick.isEmpty()) { - nicknames.add(nick); - return true; + if (nick != null) { + if (!nick.isEmpty()) { + nicknames.add(nick); + return true; + } } } return false; @@ -304,7 +307,7 @@ public class UserData { public void access() { accessing++; } - + /** * */ @@ -313,12 +316,10 @@ public class UserData { } // Getters ------------------------------------------------------------- - /** * * @return */ - public UUID getUuid() { return uuid; } @@ -452,7 +453,6 @@ public class UserData { } // Setters ------------------------------------------------------------- - /** * * @param uuid @@ -620,7 +620,7 @@ public class UserData { public void setPlayerKills(List playerKills) { this.playerKills = playerKills; } - + /** * * @param kill @@ -734,6 +734,5 @@ public class UserData { } return true; } - - + } 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 43c891499..ca1173063 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/Database.java @@ -5,6 +5,8 @@ import java.util.*; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; /** @@ -164,4 +166,5 @@ public abstract class Database { * @throws SQLException */ public abstract int getUserId(String uuid) throws SQLException; + public abstract List getLocations(String userId, HashMap worlds) throws SQLException; } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index 9e803e63b..86f5ad99c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -714,7 +714,8 @@ public abstract class SQLDB extends Database { return nicknames; } - private List getLocations(String userId, HashMap worlds) throws SQLException { + @Override + public List getLocations(String userId, HashMap worlds) throws SQLException { PreparedStatement statement; ResultSet set; statement = connection.prepareStatement("SELECT * FROM " + locationName + " WHERE UPPER(" + locationColumnUserID + ") LIKE UPPER(?)"); @@ -965,11 +966,11 @@ public abstract class SQLDB extends Database { * @throws SQLException */ public void saveAdditionalLocationsList(int userId, List locations) throws SQLException { - List newLocations = new ArrayList<>(); - newLocations.addAll(locations); - if (newLocations.isEmpty()) { + if (locations == null || locations.isEmpty()) { return; } + List newLocations = new ArrayList<>(); + newLocations.addAll(locations); PreparedStatement saveStatement = connection.prepareStatement("INSERT INTO " + locationName + " (" + locationColumnUserID + ", " + locationColumnCoordinatesX + ", " @@ -979,6 +980,9 @@ public abstract class SQLDB extends Database { boolean commitRequired = false; if (!newLocations.isEmpty()) { for (Location location : newLocations) { + if (location == null) { + continue; + } saveStatement.setInt(1, userId); saveStatement.setInt(2, (int) location.getBlockX()); saveStatement.setInt(3, (int) location.getBlockZ()); @@ -1006,7 +1010,7 @@ public abstract class SQLDB extends Database { * @throws SQLException */ public void saveNickList(int userId, HashSet names, String lastNick) throws SQLException { - if (names.isEmpty()) { + if (names == null || names.isEmpty()) { return; } PreparedStatement statement = connection.prepareStatement( @@ -1056,9 +1060,14 @@ public abstract class SQLDB extends Database { + ") VALUES (?, ?, ?)"); boolean commitRequired = false; for (SessionData session : sessions) { + long end = session.getSessionEnd(); + long start = session.getSessionStart(); + if (end < start) { + continue; + } statement.setInt(1, userId); - statement.setLong(2, session.getSessionStart()); - statement.setLong(3, session.getSessionEnd()); + statement.setLong(2, start); + statement.setLong(3, end); statement.addBatch(); commitRequired = true; } @@ -1076,7 +1085,7 @@ public abstract class SQLDB extends Database { * @throws SQLException */ public void savePlayerKills(int userId, List kills) throws SQLException { - if (kills.isEmpty()) { + if (kills == null || kills.isEmpty()) { return; } PreparedStatement statement = connection.prepareStatement( @@ -1092,6 +1101,9 @@ public abstract class SQLDB extends Database { + ") VALUES (?, ?, ?, ?)"); boolean commitRequired = false; for (KillData kill : kills) { + if (kill == null) { + continue; + } statement.setInt(1, userId); statement.setInt(2, kill.getVictimUserID()); statement.setString(3, kill.getWeapon()); @@ -1101,7 +1113,6 @@ public abstract class SQLDB extends Database { } if (commitRequired) { statement.executeBatch(); - } statement.close(); } @@ -1113,7 +1124,7 @@ public abstract class SQLDB extends Database { * @throws SQLException */ public void saveIPList(int userId, HashSet ips) throws SQLException { - if (ips.isEmpty()) { + if (ips == null || ips.isEmpty()) { return; } PreparedStatement statement = connection.prepareStatement( @@ -1128,6 +1139,9 @@ public abstract class SQLDB extends Database { + ") VALUES (?, ?)"); boolean commitRequired = false; for (InetAddress ip : ips) { + if (ip == null) { + continue; + } statement.setInt(1, userId); statement.setString(2, ip.getHostAddress()); statement.addBatch(); @@ -1147,7 +1161,7 @@ public abstract class SQLDB extends Database { * @throws SQLException */ public void saveGMTimes(int userId, HashMap gamemodeTimes) throws SQLException { - if (gamemodeTimes.isEmpty()) { + if (gamemodeTimes == null || gamemodeTimes.isEmpty()) { return; } PreparedStatement statement = connection.prepareStatement( diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/Html.java b/Plan/src/main/java/com/djrapitops/plan/ui/Html.java index 9886652d2..1605f6da9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/Html.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/Html.java @@ -103,7 +103,7 @@ public enum Html { public String parse(String... p) { String returnValue = this.html; for (int i = 0; i < p.length; i++) { - returnValue = returnValue.replaceAll("REPLACE" + i, p[i]); + returnValue = returnValue.replace("REPLACE" + i, p[i]); } return returnValue; } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/tables/SortableCommandUseTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/tables/SortableCommandUseTableCreator.java index a64427dbf..4ba34130a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/tables/SortableCommandUseTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/tables/SortableCommandUseTableCreator.java @@ -33,7 +33,7 @@ public class SortableCommandUseTableCreator { } catch (IllegalArgumentException e) { Plan plugin = getPlugin(Plan.class); plugin.toLog("SortableCommandUseTableCreator", e); - plugin.toLog("Cause: "+values[1]+" "+values[2]); + plugin.toLog("Cause: "+values[0]+" "+values[1]); } } return html; 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 e75f0d036..185a0b110 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java @@ -82,9 +82,9 @@ public class HtmlUtils { } public static String removeXSS(String string) { - return string.replaceAll("", "") - .replaceAll("", ""); + return string.replace("", "") + .replace("", ""); } }