Skip to content

Commit ac213e2

Browse files
committed
fix(tutorial): Align saved times (utc)
1 parent f36b8c2 commit ac213e2

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ tasks.withType<Javadoc> {
7979

8080
tasks.shadowJar {
8181
archiveClassifier = ""
82-
83-
relocationPrefix = "$group.plotsystem.shaded"
82+
relocationPrefix = "com.alpsbte.plotsystem.shaded"
8483
enableAutoRelocation = true
8584
}
8685

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[versions]
44
# Dependencies
5-
com-alpsbte-alpslib-alpslib-hologram = "1.1.1" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-hologram/
6-
com-alpsbte-alpslib-alpslib-io = "1.2.2" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-io/
5+
com-alpsbte-alpslib-alpslib-hologram = "1.1.2" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-hologram/
6+
com-alpsbte-alpslib-alpslib-io = "1.2.3" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-io/
77
com-alpsbte-alpslib-alpslib-utils = "1.4.1" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/alpslib/alpslib-utils/
88
com-alpsbte-canvas = "1.3" # https://mvn.alps-bte.com/service/rest/repository/browse/alps-bte/com/alpsbte/canvas/
99
com-arcaniax-headdatabase-api = "1.3.2" # https://github.com/Arcaniax-Development/HeadDatabase-API/releases

src/main/java/com/alpsbte/plotsystem/PlotSystem.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ public static PlotSystem getPlugin() {
189189
return plugin;
190190
}
191191

192-
public void initDatabase() throws IOException, SQLException, ClassNotFoundException {
193-
DatabaseConnection.initializeDatabase(DatabaseConfigPaths.getConfig(getConfig()), true);
192+
public void initDatabase() throws IOException, SQLException, RuntimeException {
193+
// We currently want to save everything in UTC to have no mismatch, because CURRENT_TIMESTAMP uses UTC + DateTime doesn't support timezones (we would have to use TIMESTAMP)
194+
// These url parameters align behaviour (at least on linux)
195+
DatabaseConnection.initializeDatabase(DatabaseConfigPaths.getConfig(getConfig()), true, "serverTimezone=UTC&forceConnectionTimeZoneToSession=true");
194196
var initScript = CharStreams.toString(Objects.requireNonNull(getTextResource("DATABASE.sql")));
195197
try (var con = DatabaseConnection.getConnection(); var s = con.createStatement()) {
196198
s.execute(initScript);

src/main/java/com/alpsbte/plotsystem/core/EventListener.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
public class EventListener implements Listener {
7777
@EventHandler
78-
public void onPlayerJoinEvent(PlayerJoinEvent event) {
78+
public void onPlayerJoinEvent(@NotNull PlayerJoinEvent event) {
7979
Player player = event.getPlayer();
8080

8181
// Add Items
@@ -141,8 +141,10 @@ public void onPlayerQuitEvent(@NotNull PlayerQuitEvent event) {
141141
plotWorld.unloadWorld(false);
142142
}, 60L);
143143

144-
PlotUtils.plotReminder.get(event.getPlayer().getUniqueId()).cancel();
145-
PlotUtils.plotReminder.remove(event.getPlayer().getUniqueId());
144+
if (PlotUtils.plotReminder.containsKey(event.getPlayer().getUniqueId())) {
145+
PlotUtils.plotReminder.get(event.getPlayer().getUniqueId()).cancel();
146+
PlotUtils.plotReminder.remove(event.getPlayer().getUniqueId());
147+
}
146148
}
147149

148150
@EventHandler

src/main/java/com/alpsbte/plotsystem/core/database/providers/TutorialPlotProvider.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.sql.Date;
88
import java.sql.ResultSet;
99
import java.sql.Timestamp;
10-
import java.time.LocalDateTime;
10+
import java.time.Instant;
1111
import java.util.Deque;
1212
import java.util.HashMap;
1313
import java.util.LinkedList;
@@ -64,7 +64,7 @@ public boolean setStageId(int tutorialId, String playerUUID, int stageId) {
6464
String qSetStage = "UPDATE tutorial SET stage_id = ?, last_stage_complete_date = ? WHERE tutorial_id = ? AND uuid = ?;";
6565
return Boolean.TRUE.equals(Utils.handleSqlException(false, () -> SqlHelper.runQuery(qSetStage, ps -> {
6666
ps.setInt(1, stageId);
67-
ps.setTimestamp(2, Timestamp.valueOf(LocalDateTime.now()));
67+
ps.setTimestamp(2, Timestamp.from(Instant.now()));
6868
ps.setInt(3, tutorialId);
6969
ps.setString(4, playerUUID);
7070
return ps.executeUpdate() > 0;
@@ -75,7 +75,8 @@ public boolean setComplete(int tutorialId, String playerUUID) {
7575
String qSetComplete = "UPDATE tutorial SET is_complete = ?, last_stage_complete_date = ? WHERE tutorial_id = ? AND uuid = ?;";
7676
return Boolean.TRUE.equals(Utils.handleSqlException(false, () -> SqlHelper.runQuery(qSetComplete, ps -> {
7777
ps.setBoolean(1, true);
78-
ps.setTimestamp(2, Timestamp.valueOf(LocalDateTime.now()));
78+
79+
ps.setTimestamp(2, Timestamp.from(Instant.now()));
7980
ps.setInt(3, tutorialId);
8081
ps.setString(4, playerUUID);
8182
return ps.executeUpdate() > 0;

0 commit comments

Comments
 (0)