mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Make timestamp optional again
This commit is contained in:
1 parent
e200bd670c
commit
7539094a2d
5 files changed
+37
-20
No files matched your search
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.William278</groupId>
|
<groupId>me.William278</groupId>
|
||||||
<artifactId>HuskHomes</artifactId>
|
<artifactId>HuskHomes</artifactId>
|
||||||
<version>2.8</version>
|
<version>2.8.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HuskHomes</name>
|
<name>HuskHomes</name>
|
||||||
|
|||||||
@@ -164,13 +164,18 @@ public class DataManager {
|
|||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
int locationID = resultSet.getInt("location_id");
|
int locationID = resultSet.getInt("location_id");
|
||||||
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
|
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,
|
playerHomes.add(new Home(teleportationPoint,
|
||||||
playerName,
|
playerName,
|
||||||
getPlayerUUID(resultSet.getInt("player_id"), connection),
|
getPlayerUUID(resultSet.getInt("player_id"), connection),
|
||||||
resultSet.getString("name"),
|
resultSet.getString("name"),
|
||||||
resultSet.getString("description"),
|
resultSet.getString("description"),
|
||||||
resultSet.getBoolean("public"),
|
resultSet.getBoolean("public"),
|
||||||
resultSet.getTimestamp("creation_time").getTime()));
|
epochTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -187,12 +192,17 @@ public class DataManager {
|
|||||||
int playerID = resultSet.getInt("player_id");
|
int playerID = resultSet.getInt("player_id");
|
||||||
int locationID = resultSet.getInt("location_id");
|
int locationID = resultSet.getInt("location_id");
|
||||||
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
|
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,
|
publicHomes.add(new Home(teleportationPoint,
|
||||||
getPlayerUsername(playerID, connection),
|
getPlayerUsername(playerID, connection),
|
||||||
getPlayerUUID(playerID, connection),
|
getPlayerUUID(playerID, connection),
|
||||||
resultSet.getString("name"),
|
resultSet.getString("name"),
|
||||||
resultSet.getString("description"), true,
|
resultSet.getString("description"), true,
|
||||||
resultSet.getTimestamp("creation_time").getTime()));
|
epochTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -208,10 +218,15 @@ public class DataManager {
|
|||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
int locationID = resultSet.getInt("location_id");
|
int locationID = resultSet.getInt("location_id");
|
||||||
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
|
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,
|
warps.add(new Warp(teleportationPoint,
|
||||||
resultSet.getString("name"),
|
resultSet.getString("name"),
|
||||||
resultSet.getString("description"),
|
resultSet.getString("description"),
|
||||||
resultSet.getTimestamp("creation_time").getTime()));
|
epochTime));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().severe("Result set of warps returned null!");
|
Bukkit.getLogger().severe("Result set of warps returned null!");
|
||||||
@@ -229,10 +244,15 @@ public class DataManager {
|
|||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
int locationID = resultSet.getInt("location_id");
|
int locationID = resultSet.getInt("location_id");
|
||||||
TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
|
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,
|
return new Warp(teleportationPoint,
|
||||||
resultSet.getString("name"),
|
resultSet.getString("name"),
|
||||||
resultSet.getString("description"),
|
resultSet.getString("description"),
|
||||||
resultSet.getTimestamp("creation_time").getTime());
|
epochTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -505,13 +525,18 @@ public class DataManager {
|
|||||||
if (resultSet.next()) {
|
if (resultSet.next()) {
|
||||||
final int locationID = resultSet.getInt("location_id");
|
final int locationID = resultSet.getInt("location_id");
|
||||||
final TeleportationPoint teleportationPoint = getTeleportationPoint(locationID, connection);
|
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,
|
final Home home = new Home(teleportationPoint,
|
||||||
ownerUsername,
|
ownerUsername,
|
||||||
getPlayerUUID(resultSet.getInt("player_id"), connection),
|
getPlayerUUID(resultSet.getInt("player_id"), connection),
|
||||||
resultSet.getString("name"),
|
resultSet.getString("name"),
|
||||||
resultSet.getString("description"),
|
resultSet.getString("description"),
|
||||||
resultSet.getBoolean("public"),
|
resultSet.getBoolean("public"),
|
||||||
resultSet.getTimestamp("creation_time").getTime());
|
epochTime);
|
||||||
statement.close();
|
statement.close();
|
||||||
return home;
|
return home;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class MySQL extends Database {
|
|||||||
"`name` varchar(16) NOT NULL," +
|
"`name` varchar(16) NOT NULL," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`public` boolean NOT NULL," +
|
"`public` boolean NOT NULL," +
|
||||||
"`creation_time` timestamp NOT NULL," +
|
"`creation_time` timestamp NULL," +
|
||||||
"PRIMARY KEY (`player_id`, `name`)," +
|
"PRIMARY KEY (`player_id`, `name`)," +
|
||||||
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
"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" +
|
"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," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`creation_time` timestamp NOT NULL," +
|
"`creation_time` timestamp NULL," +
|
||||||
"PRIMARY KEY (`location_id`)," +
|
"PRIMARY KEY (`location_id`)," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_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" +
|
||||||
");"
|
");"
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class SQLite extends Database {
|
|||||||
"`name` varchar(16) NOT NULL," +
|
"`name` varchar(16) NOT NULL," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`public` boolean NOT NULL," +
|
"`public` boolean NOT NULL," +
|
||||||
"`creation_time` timestamp NOT NULL," +
|
"`creation_time` timestamp NULL," +
|
||||||
"PRIMARY KEY (`player_id`, `name`)," +
|
"PRIMARY KEY (`player_id`, `name`)," +
|
||||||
"FOREIGN KEY (`player_id`) REFERENCES " + HuskHomes.getSettings().getPlayerDataTable() + " (`player_id`) ON DELETE CASCADE ON UPDATE NO ACTION," +
|
"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" +
|
"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," +
|
"`location_id` integer NOT NULL," +
|
||||||
"`name` varchar(16) NOT NULL UNIQUE," +
|
"`name` varchar(16) NOT NULL UNIQUE," +
|
||||||
"`description` varchar(255) NOT NULL," +
|
"`description` varchar(255) NOT NULL," +
|
||||||
"`creation_time` timestamp NOT NULL," +
|
"`creation_time` timestamp NULL," +
|
||||||
"PRIMARY KEY (`location_id`)," +
|
"PRIMARY KEY (`location_id`)," +
|
||||||
"FOREIGN KEY (`location_id`) REFERENCES " + HuskHomes.getSettings().getLocationsDataTable() + " (`location_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" +
|
||||||
");"
|
");"
|
||||||
|
|||||||
@@ -74,12 +74,8 @@ public class UpgradeDatabase {
|
|||||||
plugin.getLogger().info("Database upgrade needed: Adding creation timestamps to homes and warps...");
|
plugin.getLogger().info("Database upgrade needed: Adding creation timestamps to homes and warps...");
|
||||||
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
"ALTER TABLE " + HuskHomes.getSettings().getHomesDataTable()
|
"ALTER TABLE " + HuskHomes.getSettings().getHomesDataTable()
|
||||||
+ " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
|
+ " ADD `creation_time` timestamp NULL DEFAULT NULL;")) {
|
||||||
tableUpdateStatement.execute();
|
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)");
|
plugin.getLogger().info("Database upgrade in progress... (1/2)");
|
||||||
} catch (SQLException e) {
|
} 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.");
|
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(
|
try (PreparedStatement tableUpdateStatement = HuskHomes.getConnection().prepareStatement(
|
||||||
"ALTER TABLE " + HuskHomes.getSettings().getWarpsDataTable()
|
"ALTER TABLE " + HuskHomes.getSettings().getWarpsDataTable()
|
||||||
+ " ADD `creation_time` timestamp NOT NULL DEFAULT 0;")) {
|
+ " ADD `creation_time` timestamp NULL DEFAULT NULL;")) {
|
||||||
tableUpdateStatement.execute();
|
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)");
|
plugin.getLogger().info("Database upgrade in progress... (2/2)");
|
||||||
} catch (SQLException e) {
|
} 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.");
|
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.");
|
||||||
|
|||||||
Reference in new issue
Block a user