From 5929d5dd56b89a60124a771a48996b2f64e05814 Mon Sep 17 00:00:00 2001
From: MagicBot <MagicBot@magicbane.com>
Date: Fri, 13 Jan 2023 08:43:20 -0500
Subject: [PATCH] Cleanup of NextMindWindow logic.

---
 src/engine/objects/Mine.java | 45 +++++++++++++++---------------------
 1 file changed, 19 insertions(+), 26 deletions(-)

diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java
index 39564bd2..d84ee3bd 100644
--- a/src/engine/objects/Mine.java
+++ b/src/engine/objects/Mine.java
@@ -179,23 +179,23 @@ public class Mine extends AbstractGameObject {
     }
 
     private void setNextMineWindow() {
-    	
-    	//default time, 9 pm est
-    	int mineHour = 21;
-    	
+
+		int nextMineHour = MBServerStatics.MINE_EARLY_WINDOW;;
+		LocalDateTime nextOpenDate = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0);
+
+		// Use the new owners Mine WOO.  If errant use Early window for this server.
+
     	if (this.owningGuild != null || this.owningGuild.isErrant() == false)
-    		mineHour = this.owningGuild.getNation().getMineTime();
-    	int days = 1;
-    	
-    	//midnight hours
-    	if (this.openDate.getHour() != 0 && this.openDate.getHour() != 24 && (this.openDate.getDayOfMonth() == LocalDateTime.now().getDayOfMonth()))
-    		if (mineHour == 0 || mineHour == 24)
-    			days = 2;
-    	
-    	LocalDateTime newTime = this.openDate.plusDays(days).withHour(mineHour).withMinute(0).withSecond(0).withNano(0);
-    	
-    	DbManager.MineQueries.CHANGE_MINE_TIME(this, newTime);
-		this.openDate = newTime;
+			nextMineHour = this.owningGuild.getMineTime();
+
+    	if ((this.openDate.getHour() == 0 || this.openDate.getHour() == 24) &&
+			(this.owningGuild.getMineTime() != 0 && this.owningGuild.getMineTime() != 24))
+			nextOpenDate = nextOpenDate.withHour(nextMineHour);
+		else
+			nextOpenDate = nextOpenDate.withHour(nextMineHour).plusDays(1);
+
+    	DbManager.MineQueries.CHANGE_MINE_TIME(this, nextOpenDate);
+		this.openDate = nextOpenDate;
 	}
 
 	public static void loadAllMines() {
@@ -576,16 +576,9 @@ try{
 		Guild nation = this.owningGuild.getNation();
 		this.nationName = nation.getName();
 		this.nationTag = nation.getGuildTag();
-		
-		LocalDateTime guildDate = LocalDateTime.now().withHour(this.owningGuild.getMineTime()).withMinute(0).withSecond(0).withNano(0);
-		
-		if (this.openDate.getDayOfMonth() == LocalDateTime.now().getDayOfMonth())
-		if (this.owningGuild.getMineTime() == 0 || this.owningGuild.getMineTime() == 24)
-			guildDate = guildDate.plusDays(1);
-		
-		guildDate = guildDate.withHour(this.owningGuild.getMineTime()).withMinute(0).withSecond(0).withNano(0);
-		this.openDate = guildDate;
-		Mine.setLastChange(System.currentTimeMillis());
+
+		setNextMineWindow();
+		setLastChange(System.currentTimeMillis());
 
 		if (mineBuilding.getRank() < 1){