From 4f217e320ab04e88a891eb168ee55d5d6ba87e89 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Thu, 7 Dec 2023 23:56:26 +0100 Subject: [PATCH] fix: Move back to unix timestamp for cooldowns because I never should have listened to those two guys who claimed I should be using game time #705 #433 #432 --- .../mods/waystones/core/PersistentPlayerWaystoneData.java | 4 ++-- .../blay09/mods/waystones/core/PlayerWaystoneManager.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/shared/src/main/java/net/blay09/mods/waystones/core/PersistentPlayerWaystoneData.java b/shared/src/main/java/net/blay09/mods/waystones/core/PersistentPlayerWaystoneData.java index 53c1be3a..484684f3 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/core/PersistentPlayerWaystoneData.java +++ b/shared/src/main/java/net/blay09/mods/waystones/core/PersistentPlayerWaystoneData.java @@ -12,8 +12,8 @@ public class PersistentPlayerWaystoneData implements IPlayerWaystoneData { private static final String TAG_NAME = "WaystonesData"; private static final String ACTIVATED_WAYSTONES = "Waystones"; - private static final String INVENTORY_BUTTON_COOLDOWN_UNTIL = "InventoryButtonCooldownUntilNew"; - private static final String WARP_STONE_COOLDOWN_UNTIL = "WarpStoneCooldownUntilNew"; + private static final String INVENTORY_BUTTON_COOLDOWN_UNTIL = "InventoryButtonCooldownUntilUnix"; + private static final String WARP_STONE_COOLDOWN_UNTIL = "WarpStoneCooldownUntilUnix"; @Override public void activateWaystone(Player player, IWaystone waystone) { diff --git a/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java b/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java index a1b581eb..4cc83a25 100644 --- a/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java +++ b/shared/src/main/java/net/blay09/mods/waystones/core/PlayerWaystoneManager.java @@ -297,8 +297,8 @@ private static void applyCooldown(WarpMode warpMode, Player player, int cooldown final Level level = player.level(); switch (warpMode) { case INVENTORY_BUTTON -> - getPlayerWaystoneData(level).setInventoryButtonCooldownUntil(player, level.getGameTime() + cooldown * 20L); - case WARP_STONE -> getPlayerWaystoneData(level).setWarpStoneCooldownUntil(player, level.getGameTime() + cooldown * 20L); + getPlayerWaystoneData(level).setInventoryButtonCooldownUntil(player, System.currentTimeMillis() + cooldown * 20L); + case WARP_STONE -> getPlayerWaystoneData(level).setWarpStoneCooldownUntil(player, System.currentTimeMillis() + cooldown * 20L); } WaystoneSyncManager.sendWaystoneCooldowns(player); } @@ -513,7 +513,7 @@ public static long getWarpStoneCooldownUntil(Player player) { public static long getWarpStoneCooldownLeft(Player player) { long cooldownUntil = getWarpStoneCooldownUntil(player); - return Math.max(0, cooldownUntil - player.level().getGameTime()); + return Math.max(0, cooldownUntil - System.currentTimeMillis()); } public static void setWarpStoneCooldownUntil(Player player, long timeStamp) { @@ -526,7 +526,7 @@ public static long getInventoryButtonCooldownUntil(Player player) { public static long getInventoryButtonCooldownLeft(Player player) { long cooldownUntil = getInventoryButtonCooldownUntil(player); - return Math.max(0, cooldownUntil - player.level().getGameTime()); + return Math.max(0, cooldownUntil - System.currentTimeMillis()); } public static void setInventoryButtonCooldownUntil(Player player, long timeStamp) {