From 270301c35b2d29a8b69596afd6fd66ca7d641952 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 23 May 2024 18:07:39 -0500 Subject: [PATCH] new mines system --- src/engine/workthreads/MineThread.java | 39 +++++--------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/src/engine/workthreads/MineThread.java b/src/engine/workthreads/MineThread.java index 1b7396fd..9cdfd17a 100644 --- a/src/engine/workthreads/MineThread.java +++ b/src/engine/workthreads/MineThread.java @@ -13,10 +13,7 @@ import engine.objects.Guild; import engine.objects.Mine; import engine.objects.PlayerCharacter; import org.pmw.tinylog.Logger; - import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; public class MineThread implements Runnable { public MineThread(){ @@ -113,41 +110,19 @@ public class MineThread implements Runnable { Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); if(tower == null) continue; - LocalDateTime liveTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).minusMinutes(1); - ZonedDateTime localizedTime = convertCSTToLocalTime(liveTime); + LocalDateTime liveTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).minusMinutes(1).plusHours(5); if(!mine.isActive && !mine.wasOpened) { - if (ZonedDateTime.now().isAfter(localizedTime)) { + if (LocalDateTime.now().isAfter(liveTime)) { mineWindowOpen(mine); // mine has not opened today yet, and it is now after the time it should have, open the mine } - }else{ + } //mine is active right now - if (ZonedDateTime.now().isBefore(localizedTime.plusMinutes(30))){ - continue; // window is not over yet - } + if (LocalDateTime.now().isBefore(liveTime.plusMinutes(30))) + continue; // window is not over yet - if(tower.getRank() == 1){ - //mine was not knocked down, close the window - mineWindowClose(mine); - }else{ - if(mine.lastClaimer != null) - mineWindowClose(mine); //has a claimer, close the window - } - } + if(tower.getRank() == 1 || mine.lastClaimer != null) + mineWindowClose(mine); } } - public static ZonedDateTime convertCSTToLocalTime(LocalDateTime cstDateTime) { - // Define the CST time zone (Central Standard Time) - ZoneId cstZoneId = ZoneId.of("America/Chicago"); // CST is represented by America/Chicago - // Define the system's default time zone - ZoneId localZoneId = ZoneId.systemDefault(); - - // Create a ZonedDateTime object for CST - ZonedDateTime cstZonedDateTime = ZonedDateTime.of(cstDateTime, cstZoneId); - - // Convert CST to the local time zone - ZonedDateTime localZonedDateTime = cstZonedDateTime.withZoneSameInstant(localZoneId); - - return localZonedDateTime; - } }