diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml
index 723761ad7..5712fbced 100644
--- a/Plan/dependency-reduced-pom.xml
+++ b/Plan/dependency-reduced-pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.djrapitops
Plan
- 3.5.3
+ 3.5.4
${basedir}/src
clean package install
diff --git a/Plan/pom.xml b/Plan/pom.xml
index 4fde7e04e..3d88b655c 100644
--- a/Plan/pom.xml
+++ b/Plan/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.djrapitops
Plan
- 3.5.3
+ 3.5.4
jar
diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java
index a0b11565d..e3eb1df36 100644
--- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java
+++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java
@@ -28,10 +28,10 @@ public class ManageCommand extends TreeCommand {
@Override
public void addCommands() {
- commands.add(new ManageMoveCommand(plugin));
+// commands.add(new ManageMoveCommand(plugin));
commands.add(new ManageHotswapCommand(plugin));
- commands.add(new ManageBackupCommand(plugin));
- commands.add(new ManageRestoreCommand(plugin));
+// commands.add(new ManageBackupCommand(plugin));
+// commands.add(new ManageRestoreCommand(plugin));
commands.add(new ManageStatusCommand(plugin));
commands.add(new ManageImportCommand(plugin));
commands.add(new ManageRemoveCommand(plugin));
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 4f88d2de2..bb119f188 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
@@ -128,7 +128,7 @@ public abstract class SQLDB extends Database {
}
if (newDatabase) {
Log.info("New Database created.");
- setVersion(4);
+ setVersion(5);
}
Benchmark.start("Database: Create tables");
for (Table table : getAllTables()) {
@@ -142,8 +142,8 @@ public abstract class SQLDB extends Database {
return false;
}
Benchmark.stop("Database: Create tables");
- if (!newDatabase && getVersion() < 4) {
- setVersion(4);
+ if (!newDatabase && getVersion() < 5) {
+ setVersion(5);
}
}
return true;
diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java
index 9cef091ad..070efb111 100644
--- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java
+++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java
@@ -110,6 +110,9 @@ public class UsersTable extends Table {
if (version < 4) {
alterTablesV4();
}
+ if (version < 5) {
+ alterTablesV5();
+ }
return true;
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
@@ -117,6 +120,17 @@ public class UsersTable extends Table {
}
}
+ private void alterTablesV5() {
+ if (usingMySQL) {
+ try {
+ execute("ALTER TABLE " + tableName
+ + " DROP COLUMN " + columnDemAge + ","
+ + " DROP COLUMN " + columnDemGender);
+ } catch (Exception e) {
+ }
+ }
+ }
+
private void alterTablesV4() {
String[] queries;
if (usingMySQL) {
@@ -531,21 +545,7 @@ public class UsersTable extends Table {
int userId = getUserId(uuid);
int update = 0;
if (userId != -1) {
- String sql = "UPDATE " + tableName + " SET "
- + columnGeolocation + "=?, "
- + columnLastGM + "=?, "
- + columnLastGMSwapTime + "=?, "
- + columnPlayTime + "=?, "
- + columnLoginTimes + "=?, "
- + columnLastPlayed + "=?, "
- + columnDeaths + "=?, "
- + columnMobKills + "=?, "
- + columnContainsBukkitData + "=?, "
- + columnOP + "=?, "
- + columnBanned + "=?, "
- + columnName + "=?, "
- + columnRegistered + "=? "
- + "WHERE UPPER(" + columnUUID + ") LIKE UPPER(?)";
+ String sql = getUpdateStatement();
statement = prepareStatement(sql);
statement.setString(1, data.getGeolocation());
@@ -571,22 +571,7 @@ public class UsersTable extends Table {
}
if (update == 0) {
close(statement);
- statement = prepareStatement("INSERT INTO " + tableName + " ("
- + columnUUID + ", "
- + columnGeolocation + ", "
- + columnLastGM + ", "
- + columnLastGMSwapTime + ", "
- + columnPlayTime + ", "
- + columnLoginTimes + ", "
- + columnLastPlayed + ", "
- + columnDeaths + ", "
- + columnMobKills + ", "
- + columnContainsBukkitData + ", "
- + columnOP + ", "
- + columnBanned + ", "
- + columnName + ", "
- + columnRegistered
- + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ statement = prepareStatement(getInsertStatement());
statement.setString(1, uuid.toString());
statement.setString(2, data.getGeolocation());
@@ -615,6 +600,72 @@ public class UsersTable extends Table {
}
}
+ private boolean tableHasV4Columns() {
+ if (usingMySQL) {
+ return false;
+ } else {
+ PreparedStatement statement = null;
+ ResultSet set = null;
+ try {
+ try {
+ statement = prepareStatement("SELECT " + columnDemAge + " FROM " + tableName + " LIMIT 1");
+ set = statement.executeQuery();
+ Log.debug("UsersTable has V4 columns.");
+ return true;
+ } catch (SQLException e) {
+ return false;
+ }
+ } finally {
+ close(set, statement);
+ }
+ }
+ }
+
+ private String getInsertStatement() {
+ final boolean hasV4Columns = tableHasV4Columns();
+ String v4rows = hasV4Columns ? columnDemAge + ", " + columnDemGender + ", " : "";
+ String v4values = hasV4Columns ? "-1, Deprecated, " : "";
+ return "INSERT INTO " + tableName + " ("
+ + v4rows
+ + columnUUID + ", "
+ + columnGeolocation + ", "
+ + columnLastGM + ", "
+ + columnLastGMSwapTime + ", "
+ + columnPlayTime + ", "
+ + columnLoginTimes + ", "
+ + columnLastPlayed + ", "
+ + columnDeaths + ", "
+ + columnMobKills + ", "
+ + columnContainsBukkitData + ", "
+ + columnOP + ", "
+ + columnBanned + ", "
+ + columnName + ", "
+ + columnRegistered
+ + ") VALUES (" + v4values + "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ }
+
+ private String getUpdateStatement() {
+ final boolean hasV4Columns = tableHasV4Columns();
+ String v4rows = hasV4Columns ? columnDemAge + "=-1, " + columnDemGender + "='Deprecated', " : "";
+ String sql = "UPDATE " + tableName + " SET "
+ + v4rows
+ + columnGeolocation + "=?, "
+ + columnLastGM + "=?, "
+ + columnLastGMSwapTime + "=?, "
+ + columnPlayTime + "=?, "
+ + columnLoginTimes + "=?, "
+ + columnLastPlayed + "=?, "
+ + columnDeaths + "=?, "
+ + columnMobKills + "=?, "
+ + columnContainsBukkitData + "=?, "
+ + columnOP + "=?, "
+ + columnBanned + "=?, "
+ + columnName + "=?, "
+ + columnRegistered + "=? "
+ + "WHERE " + columnUUID + "=?";
+ return sql;
+ }
+
/**
*
* @param data
@@ -638,22 +689,7 @@ public class UsersTable extends Table {
private void insertNewUserData(Collection data) throws SQLException {
PreparedStatement statement = null;
try {
- statement = prepareStatement("INSERT INTO " + tableName + " ("
- + columnUUID + ", "
- + columnGeolocation + ", "
- + columnLastGM + ", "
- + columnLastGMSwapTime + ", "
- + columnPlayTime + ", "
- + columnLoginTimes + ", "
- + columnLastPlayed + ", "
- + columnDeaths + ", "
- + columnMobKills + ", "
- + columnContainsBukkitData + ", "
- + columnOP + ", "
- + columnBanned + ", "
- + columnName + ", "
- + columnRegistered
- + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ statement = prepareStatement(getInsertStatement());
boolean commitRequired = false;
int i = 0;
for (UserData uData : data) {
@@ -694,22 +730,8 @@ public class UsersTable extends Table {
PreparedStatement statement = null;
try {
List saveLast = new ArrayList<>();
- String uSQL = "UPDATE " + tableName + " SET "
- + columnGeolocation + "=?, "
- + columnLastGM + "=?, "
- + columnLastGMSwapTime + "=?, "
- + columnPlayTime + "=?, "
- + columnLoginTimes + "=?, "
- + columnLastPlayed + "=?, "
- + columnDeaths + "=?, "
- + columnMobKills + "=?, "
- + columnContainsBukkitData + "=?, "
- + columnOP + "=?, "
- + columnBanned + "=?, "
- + columnName + "=?, "
- + columnRegistered + "=? "
- + "WHERE " + columnUUID + "=?";
- statement = prepareStatement(uSQL);
+ String sql = getUpdateStatement();
+ statement = prepareStatement(sql);
boolean commitRequired = false;
Set savedUUIDs = getSavedUUIDs();
int i = 0;
diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/Html.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/Html.java
index 05a947a1e..8e80f52bf 100644
--- a/Plan/src/main/java/com/djrapitops/plan/ui/html/Html.java
+++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/Html.java
@@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.ui.html;
+import com.djrapitops.plugin.utilities.Verify;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -124,8 +125,9 @@ public enum Html {
* @return
*/
public String parse(String... p) {
+ Verify.nullCheck(p);
String returnValue = this.html;
- for (int i = 0; i < p.length; i++) {
+ for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replace("REPLACE" + i, p[i]);
}
return returnValue;
diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeckerAlgorithm.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeckerAlgorithm.java
index 6b9807a5f..a3cb912df 100644
--- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeckerAlgorithm.java
+++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/DouglasPeckerAlgorithm.java
@@ -14,6 +14,9 @@ import java.util.List;
public class DouglasPeckerAlgorithm {
public static List reducePoints(List points, double epsilon) {
+ if (points.isEmpty()) {
+ return points;
+ }
if (epsilon == -1) {
epsilon = 0.002;
}
diff --git a/Plan/src/main/resources/plugin.yml b/Plan/src/main/resources/plugin.yml
index 763ff5895..10ed26aec 100644
--- a/Plan/src/main/resources/plugin.yml
+++ b/Plan/src/main/resources/plugin.yml
@@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: main.java.com.djrapitops.plan.Plan
-version: 3.5.3
+version: 3.5.4
softdepend:
- OnTime