From 6d68d048b01e78d17cadf83ceb37fbc8a8ba1147 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 3 Jun 2024 19:47:23 -0500 Subject: [PATCH] catch process mine window logic --- src/engine/objects/Mine.java | 56 +++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index 62f882dc..ae62a95e 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -661,37 +661,41 @@ public class Mine extends AbstractGameObject { mine.wasClaimed = true; return true; } - public static void processMineWindows(){ + public static void processMineWindows() { LocalDateTime currentTime = LocalDateTime.now(); for (Mine mine : Mine.getMines()) { - Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); - //if the tower comes back null, skip this mine - if(tower == null) - continue; - //check if this mine needs to open - LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0); - if(currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened){ - mineWindowOpen(mine); //hour and minute match, time to open the window - ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!"); - continue; - } - //check to see if the window shoul dbe closing now - if(currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) { - //check to see if the tower was destoryed - boolean towerDestroyed = tower.getRank() < 1; - if(towerDestroyed){ - //check if a valid claimer exists to close the window and claim the mine since the tower was destroyed - if(mine.lastClaimer != null) { + try { + Building tower = BuildingManager.getBuildingFromCache(mine.getBuildingID()); + //if the tower comes back null, skip this mine + if (tower == null) + continue; + //check if this mine needs to open + LocalDateTime openTime = LocalDateTime.now().withHour(mine.liveHour).withMinute(mine.liveMinute).withSecond(0).withNano(0); + if (currentTime.isAfter(openTime) && currentTime.isBefore(openTime.plusMinutes(30)) && !mine.wasOpened) { + mineWindowOpen(mine); //hour and minute match, time to open the window + ChatManager.chatSystemChannel(mine.getParentZone().getName() + " " + mine.getMineType() + "MINE is now vulnerable to attack!"); + continue; + } + //check to see if the window shoul dbe closing now + if (currentTime.isAfter(openTime.plusMinutes(29)) && mine.isActive) { + //check to see if the tower was destoryed + boolean towerDestroyed = tower.getRank() < 1; + if (towerDestroyed) { + //check if a valid claimer exists to close the window and claim the mine since the tower was destroyed + if (mine.lastClaimer != null) { + mineWindowClose(mine); + ChatManager.chatSystemChannel("The fight for " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE has concluded. " + mine.lastClaimer.getName() + " has seized it in the name of " + mine.lastClaimer.getGuild().getNation()); + } else { + ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues."); + } + } else { + //tower was not destroyed, mine window closes mineWindowClose(mine); - ChatManager.chatSystemChannel("The fight for " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE has concluded. " + mine.lastClaimer.getName() + " has seized it in the name of " + mine.lastClaimer.getGuild().getNation()); - }else{ - ChatManager.chatSystemChannel("The " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE is still unclaimed. The battle continues."); + ChatManager.chatSystemChannel(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim."); } - }else{ - //tower was not destroyed, mine window closes - mineWindowClose(mine); - ChatManager.chatSystemChannel(tower.getGuild().getNation().getName() + " has successfully defended the " + mine.getParentZone().getName() + " " + mine.getMineType() + " MINE, and retains their claim."); } + } catch (Exception ex) { + Logger.error("Mine Failed: " + mine.getObjectUUID() + " " + ex.getMessage()); } } }