diff --git a/Plan/common/src/main/java/com/djrapitops/plan/gathering/events/PlayerJoinEventConsumer.java b/Plan/common/src/main/java/com/djrapitops/plan/gathering/events/PlayerJoinEventConsumer.java index 794c79e40..4ee09eb63 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/gathering/events/PlayerJoinEventConsumer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/gathering/events/PlayerJoinEventConsumer.java @@ -130,8 +130,17 @@ public class PlayerJoinEventConsumer { .ifPresent(dbSystem.getDatabase()::executeTransaction); } - private CompletableFuture storeGamePlayer(PlayerJoin join) { + private static long getRegisterDate(PlayerJoin join) { long registerDate = join.getPlayer().getRegisterDate().orElseGet(join::getTime); + // Correct incorrect register dates https://github.com/plan-player-analytics/Plan/issues/2934 + if (registerDate < System.currentTimeMillis() / 1000) { + registerDate = registerDate * 1000; + } + return registerDate; + } + + private CompletableFuture storeGamePlayer(PlayerJoin join) { + long registerDate = getRegisterDate(join); String joinAddress = join.getPlayer().getJoinAddress().orElse(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP); Transaction transaction = new StoreServerPlayerTransaction( join.getPlayerUUID(), registerDate, join.getPlayer().getName(), join.getServerUUID(), joinAddress diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/StoreServerPlayerTransaction.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/StoreServerPlayerTransaction.java index 54ced4090..7af5b7738 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/StoreServerPlayerTransaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/transactions/events/StoreServerPlayerTransaction.java @@ -59,7 +59,11 @@ public class StoreServerPlayerTransaction extends PlayerRegisterTransaction { // Updates register date to smallest possible value. Optional foundRegisterDate = query(PlayerFetchQueries.fetchRegisterDate(playerUUID)); - if (foundRegisterDate.isPresent() && foundRegisterDate.get() > registerDate) { + if (foundRegisterDate.isPresent() && + (foundRegisterDate.get() > registerDate + // Correct incorrect register dates https://github.com/plan-player-analytics/Plan/issues/2934 + || foundRegisterDate.get() < System.currentTimeMillis() / 1000) + ) { execute(DataStoreQueries.updateMainRegisterDate(playerUUID, registerDate)); }