From a9eab6fb79138e88ad25cce8caf18994e2b14029 Mon Sep 17 00:00:00 2001 From: iquelli Date: Sat, 30 Mar 2024 21:38:47 +0000 Subject: [PATCH] fix: time outside is consistent with game time --- .../prisonescape/bukkit/BukkitWorldEditor.java | 10 ++++++++++ .../tiagofar78/prisonescape/game/PrisonEscapeGame.java | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java b/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java index 87204347..3bf708e5 100644 --- a/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java +++ b/src/main/java/net/tiagofar78/prisonescape/bukkit/BukkitWorldEditor.java @@ -15,6 +15,8 @@ public class BukkitWorldEditor { private static final int SIGN_INDEX = 1; private static final World WORLD = Bukkit.getWorld(ConfigManager.getInstance().getWorldName()); + private static final int DAY_START_TIME = 0; + private static final int NIGHT_START_TIME = 13000; public static void addSignAboveVault(PrisonEscapeLocation location, String text) { Location bukkitLocation = new Location(WORLD, location.getX(), location.getY() + 1, location.getZ()); @@ -39,4 +41,12 @@ public static void deleteVaultAndRespectiveSign(PrisonEscapeLocation location) { signLocation.getBlock().setType(Material.AIR); } + public static void changeTimeToDay() { + WORLD.setTime(DAY_START_TIME); + } + + public static void changeTimeToNight() { + WORLD.setTime(NIGHT_START_TIME); + } + } diff --git a/src/main/java/net/tiagofar78/prisonescape/game/PrisonEscapeGame.java b/src/main/java/net/tiagofar78/prisonescape/game/PrisonEscapeGame.java index 97180e62..07567b53 100644 --- a/src/main/java/net/tiagofar78/prisonescape/game/PrisonEscapeGame.java +++ b/src/main/java/net/tiagofar78/prisonescape/game/PrisonEscapeGame.java @@ -4,6 +4,7 @@ import net.tiagofar78.prisonescape.bukkit.BukkitMessageSender; import net.tiagofar78.prisonescape.bukkit.BukkitScheduler; import net.tiagofar78.prisonescape.bukkit.BukkitTeleporter; +import net.tiagofar78.prisonescape.bukkit.BukkitWorldEditor; import net.tiagofar78.prisonescape.game.phases.Finished; import net.tiagofar78.prisonescape.game.phases.Phase; import net.tiagofar78.prisonescape.game.phases.Waiting; @@ -339,6 +340,7 @@ private void startDay() { _dayPeriod = DayPeriod.DAY; _currentDay++; + BukkitWorldEditor.changeTimeToDay(); _prison.reloadChests(); @@ -364,6 +366,7 @@ private void startNight() { } _dayPeriod = DayPeriod.NIGHT; + BukkitWorldEditor.changeTimeToNight(); for (PrisonEscapePlayer player : _playersOnLobby) { MessageLanguageManager messages = MessageLanguageManager.getInstanceByPlayer(player.getName());