diff --git a/pom.xml b/pom.xml
index d16e4579..b1c14cdc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.William278
HuskHomes
- 2.8
+ 2.8.1
jar
HuskHomes
diff --git a/src/main/java/me/william278/huskhomes2/data/DataManager.java b/src/main/java/me/william278/huskhomes2/data/DataManager.java
index 0f41d595..57c7a85c 100644
--- a/src/main/java/me/william278/huskhomes2/data/DataManager.java
+++ b/src/main/java/me/william278/huskhomes2/data/DataManager.java
@@ -164,13 +164,18 @@ public class DataManager {
while (resultSet.next()) {
int locationID = resultSet.getInt("location_id");
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
+ long epochTime = 0;
+ final Timestamp timestamp = resultSet.getTimestamp("creation_time");
+ if (timestamp != null) {
+ epochTime = timestamp.getTime();
+ }
playerHomes.add(new Home(teleportationPoint,
playerName,
getPlayerUUID(resultSet.getInt("player_id"), connection),
resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getBoolean("public"),
- resultSet.getTimestamp("creation_time").getTime()));
+ epochTime));
}
}
@@ -187,12 +192,17 @@ public class DataManager {
int playerID = resultSet.getInt("player_id");
int locationID = resultSet.getInt("location_id");
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
+ long epochTime = 0;
+ final Timestamp timestamp = resultSet.getTimestamp("creation_time");
+ if (timestamp != null) {
+ epochTime = timestamp.getTime();
+ }
publicHomes.add(new Home(teleportationPoint,
getPlayerUsername(playerID, connection),
getPlayerUUID(playerID, connection),
resultSet.getString("name"),
resultSet.getString("description"), true,
- resultSet.getTimestamp("creation_time").getTime()));
+ epochTime));
}
}
@@ -208,10 +218,15 @@ public class DataManager {
while (resultSet.next()) {
int locationID = resultSet.getInt("location_id");
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
+ long epochTime = 0;
+ final Timestamp timestamp = resultSet.getTimestamp("creation_time");
+ if (timestamp != null) {
+ epochTime = timestamp.getTime();
+ }
warps.add(new Warp(teleportationPoint,
resultSet.getString("name"),
resultSet.getString("description"),
- resultSet.getTimestamp("creation_time").getTime()));
+ epochTime));
}
} else {
Bukkit.getLogger().severe("Result set of warps returned null!");
@@ -229,10 +244,15 @@ public class DataManager {
if (resultSet.next()) {
int locationID = resultSet.getInt("location_id");
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
+ long epochTime = 0;
+ final Timestamp timestamp = resultSet.getTimestamp("creation_time");
+ if (timestamp != null) {
+ epochTime = timestamp.getTime();
+ }
return new Warp(teleportationPoint,
resultSet.getString("name"),
resultSet.getString("description"),
- resultSet.getTimestamp("creation_time").getTime());
+ epochTime);
}
}
return null;
@@ -505,13 +525,18 @@ public class DataManager {
if (resultSet.next()) {
final int locationID = resultSet.getInt("location_id");
final TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
+ long epochTime = 0;
+ final Timestamp timestamp = resultSet.getTimestamp("creation_time");
+ if (timestamp != null) {
+ epochTime = timestamp.getTime();
+ }
final Home home = new Home(teleportationPoint,
ownerUsername,
getPlayerUUID(resultSet.getInt("player_id"), connection),
resultSet.getString("name"),
resultSet.getString("description"),
resultSet.getBoolean("public"),
- resultSet.getTimestamp("creation_time").getTime());
+ epochTime);
statement.close();
return home;
}
diff --git a/src/main/java/me/william278/huskhomes2/data/SQL/MySQL.java b/src/main/java/me/william278/huskhomes2/data/SQL/MySQL.java
index 8566ac6a..695a4b86 100644
--- a/src/main/java/me/william278/huskhomes2/data/SQL/MySQL.java
+++ b/src/main/java/me/william278/huskhomes2/data/SQL/MySQL.java
@@ -48,7 +48,7 @@ public class MySQL extends Database {
"`name` varchar(16) NOT NULL," +
"`description` varchar(255) NOT NULL," +
"`public` boolean NOT NULL," +
- "`creation_time` timestamp NOT NULL," +
+ "`creation_time` timestamp NULL," +
"PRIMARY KEY (`player_id`, `name`)," +
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
@@ -58,7 +58,7 @@ public class MySQL extends Database {
"`location_id` integer NOT NULL," +
"`name` varchar(16) NOT NULL UNIQUE," +
"`description` varchar(255) NOT NULL," +
- "`creation_time` timestamp NOT NULL," +
+ "`creation_time` timestamp NULL," +
"PRIMARY KEY (`location_id`)," +
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
");"
diff --git a/src/main/java/me/william278/huskhomes2/data/SQL/SQLite.java b/src/main/java/me/william278/huskhomes2/data/SQL/SQLite.java
index 96a23e0d..46dac2cb 100644
--- a/src/main/java/me/william278/huskhomes2/data/SQL/SQLite.java
+++ b/src/main/java/me/william278/huskhomes2/data/SQL/SQLite.java
@@ -50,7 +50,7 @@ public class SQLite extends Database {
"`name` varchar(16) NOT NULL," +
"`description` varchar(255) NOT NULL," +
"`public` boolean NOT NULL," +
- "`creation_time` timestamp NOT NULL," +
+ "`creation_time` timestamp NULL," +
"PRIMARY KEY (`player_id`, `name`)," +
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
@@ -60,7 +60,7 @@ public class SQLite extends Database {
"`location_id` integer NOT NULL," +
"`name` varchar(16) NOT NULL UNIQUE," +
"`description` varchar(255) NOT NULL," +
- "`creation_time` timestamp NOT NULL," +
+ "`creation_time` timestamp NULL," +
"PRIMARY KEY (`location_id`)," +
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_id`) ON DELETE CASCADE ON UPDATE NO ACTION" +
");"
diff --git a/src/main/java/me/william278/huskhomes2/migrators/UpgradeDatabase.java b/src/main/java/me/william278/huskhomes2/migrators/UpgradeDatabase.java
index 7b7db881..d8451173 100644
--- a/src/main/java/me/william278/huskhomes2/migrators/UpgradeDatabase.java
+++ b/src/main/java/me/william278/huskhomes2/migrators/UpgradeDatabase.java
@@ -74,12 +74,8 @@ public class UpgradeDatabase {
plugin.getLogger().info("Database upgrade needed: Adding creation timestamps to homes and warps...");
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
"ALTER TABLE " + HuskHomes.getSettings().getHomesDataTable()
- + " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
+ + " ADD `creation_time` timestamp NULL DEFAULT NULL;")) {
tableUpdateStatement.execute();
- try (PreparedStatement timeSettingStatement = HuskHomes.getConnection().prepareStatement(
- "UPDATE " + HuskHomes.getSettings().getHomesDataTable() + " SET `creation_time`=CURRENT_TIMESTAMP;")) {
- timeSettingStatement.executeUpdate();
- }
plugin.getLogger().info("Database upgrade in progress... (1/2)");
} catch (SQLException e) {
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");
@@ -87,12 +83,8 @@ public class UpgradeDatabase {
}
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
"ALTER TABLE " + HuskHomes.getSettings().getWarpsDataTable()
- + " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
+ + " ADD `creation_time` timestamp NULL DEFAULT NULL;")) {
tableUpdateStatement.execute();
- try (PreparedStatement timeSettingStatement = HuskHomes.getConnection().prepareStatement(
- "UPDATE " + HuskHomes.getSettings().getWarpsDataTable() + " SET `creation_time`=CURRENT_TIMESTAMP;")) {
- timeSettingStatement.executeUpdate();
- }
plugin.getLogger().info("Database upgrade in progress... (2/2)");
} catch (SQLException e) {
plugin.getLogger().info("Skipped performing the database upgrade: " + e.getCause() + ". This might be because another server on your HuskHomes network already carried out the upgrade - in which case you can safely ignore this warning.");