From 2f22b3b91b59c6c8515982ffc560d5d8af7f72bf Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 09:44:51 -0500 Subject: [PATCH 1/8] Protocol Handler created for ArcMineWindowChangeMsg --- src/engine/db/handlers/dbMineHandler.java | 13 --- src/engine/net/client/ClientMessagePump.java | 3 - src/engine/net/client/Protocol.java | 2 +- .../handlers/MineWindowChangeHandler.java | 88 +++++++++++++++++++ 4 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 src/engine/net/client/handlers/MineWindowChangeHandler.java diff --git a/src/engine/db/handlers/dbMineHandler.java b/src/engine/db/handlers/dbMineHandler.java index acc8384b..43753937 100644 --- a/src/engine/db/handlers/dbMineHandler.java +++ b/src/engine/db/handlers/dbMineHandler.java @@ -6,19 +6,6 @@ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com - - - - -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - package engine.db.handlers; import engine.Enum; diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 07ede49c..d3e08a08 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -265,9 +265,6 @@ public class ClientMessagePump implements NetMsgHandler { case ARCMINEWINDOWAVAILABLETIME: MineWindowAvailableTime((ArcMineWindowAvailableTimeMsg) msg, origin); break; - case ARCMINEWINDOWCHANGE: - MineWindowChange((ArcMineWindowChangeMsg) msg, origin); - break; case ARCOWNEDMINESLIST: ListOwnedMines((ArcOwnedMinesListMsg) msg, origin); break; diff --git a/src/engine/net/client/Protocol.java b/src/engine/net/client/Protocol.java index d95becd3..38965bb8 100644 --- a/src/engine/net/client/Protocol.java +++ b/src/engine/net/client/Protocol.java @@ -36,7 +36,7 @@ public enum Protocol { ARCMINECHANGEPRODUCTION(0x1EAA993F, ArcMineChangeProductionMsg.class, null), ARCMINETOWERCRESTUPDATE(0x34164D0D, null, null), ARCMINEWINDOWAVAILABLETIME(0x6C909DE7, ArcMineWindowAvailableTimeMsg.class, null), - ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, null), + ARCMINEWINDOWCHANGE(0x92B2148A, ArcMineWindowChangeMsg.class, MineWindowChangeHandler.class), ARCOWNEDMINESLIST(0x59184455, ArcOwnedMinesListMsg.class, null), ARCPETATTACK(0x18CD61AD, PetAttackMsg.class, null), // Pet Attack ARCPETCMD(0x4E80E001, PetCmdMsg.class, null), // Stop ArcPetAttack, Toggle Assist, Toggle Rest diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java new file mode 100644 index 00000000..1ef1bb50 --- /dev/null +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -0,0 +1,88 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + +package engine.net.client.handlers; + +import engine.Enum; +import engine.Enum.DispatchChannel; +import engine.exception.MsgSendException; +import engine.gameManager.BuildingManager; +import engine.gameManager.ChatManager; +import engine.gameManager.DbManager; +import engine.gameManager.SessionManager; +import engine.net.Dispatch; +import engine.net.DispatchMessage; +import engine.net.client.ClientConnection; +import engine.net.client.msg.ArcMineWindowChangeMsg; +import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.KeepAliveServerClientMsg; +import engine.objects.Building; +import engine.objects.Guild; +import engine.objects.GuildStatusController; +import engine.objects.PlayerCharacter; +import engine.server.MBServerStatics; +import org.pmw.tinylog.Logger; + +/* + * @Author: + * @Summary: Processes requests to change a mine's opendate + */ + +public class MineWindowChangeHandler extends AbstractClientMsgHandler { + + public MineWindowChangeHandler() { + super(ArcMineWindowChangeMsg.class); + } + + @Override + protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { + + PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin); + ArcMineWindowChangeMsg mineWindowChangeMsg = (ArcMineWindowChangeMsg)baseMsg; + + if (playerCharacter == null) + return true; + + Building treeOfLife = BuildingManager.getBuildingFromCache(mineWindowChangeMsg.getBuildingID()); + + if (treeOfLife == null) + return true; + + if (treeOfLife.getBlueprintUUID() == 0) + return true; + + if (treeOfLife.getBlueprint().getBuildingGroup() != Enum.BuildingGroup.TOL) + return true; + + Guild mineGuild = treeOfLife.getGuild(); + if (mineGuild == null) + return true; + + if (!Guild.sameGuild(mineGuild, playerCharacter.getGuild())) + return true; //must be same guild + + if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL? + return true; + + //hodge podge sanity check to make sure they don't set it before early window and is not set at late window. + if (mineWindowChangeMsg.getTime() < MBServerStatics.MINE_EARLY_WINDOW && + mineWindowChangeMsg.getTime() != MBServerStatics.MINE_LATE_WINDOW) + return true; //invalid mine time, must be in range + + if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), mineWindowChangeMsg.getTime())) { + Logger.error("MineWindowChange", "Failed to update mine time for guild " + mineGuild.getObjectUUID()); + ChatManager.chatGuildError(playerCharacter, "Failed to update the mine time"); + return true; + } + mineGuild.setMineTime(mineWindowChangeMsg.getTime()); + ChatManager.chatGuildInfo(playerCharacter, "Mine time updated."); + + return true; + } + +} \ No newline at end of file From 83b514a05fa3d1355b3ae12b9490d698694b300e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 10:35:00 -0500 Subject: [PATCH 2/8] Class cleanup. --- .../net/client/handlers/MineWindowChangeHandler.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java index 1ef1bb50..4edc8a2b 100644 --- a/src/engine/net/client/handlers/MineWindowChangeHandler.java +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -44,6 +44,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin); ArcMineWindowChangeMsg mineWindowChangeMsg = (ArcMineWindowChangeMsg)baseMsg; + int newMineTime; if (playerCharacter == null) return true; @@ -69,17 +70,19 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL? return true; + newMineTime = mineWindowChangeMsg.getTime(); + //hodge podge sanity check to make sure they don't set it before early window and is not set at late window. - if (mineWindowChangeMsg.getTime() < MBServerStatics.MINE_EARLY_WINDOW && - mineWindowChangeMsg.getTime() != MBServerStatics.MINE_LATE_WINDOW) + if (newMineTime < MBServerStatics.MINE_EARLY_WINDOW && + newMineTime != MBServerStatics.MINE_LATE_WINDOW) return true; //invalid mine time, must be in range - if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), mineWindowChangeMsg.getTime())) { + if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), newMineTime)) { Logger.error("MineWindowChange", "Failed to update mine time for guild " + mineGuild.getObjectUUID()); ChatManager.chatGuildError(playerCharacter, "Failed to update the mine time"); return true; } - mineGuild.setMineTime(mineWindowChangeMsg.getTime()); + mineGuild.setMineTime(newMineTime); ChatManager.chatGuildInfo(playerCharacter, "Mine time updated."); return true; From 302358e31c9adbe65a108e2b3a85e99565312496 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 11:03:07 -0500 Subject: [PATCH 3/8] Storing lastWooEditTime for guilds in obj_guild table. Requires Schema Change. --- src/engine/net/client/handlers/MineWindowChangeHandler.java | 6 ++++++ src/engine/objects/Guild.java | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java index 4edc8a2b..5be628c6 100644 --- a/src/engine/net/client/handlers/MineWindowChangeHandler.java +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -28,6 +28,8 @@ import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.time.LocalDateTime; + /* * @Author: * @Summary: Processes requests to change a mine's opendate @@ -73,15 +75,19 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { newMineTime = mineWindowChangeMsg.getTime(); //hodge podge sanity check to make sure they don't set it before early window and is not set at late window. + if (newMineTime < MBServerStatics.MINE_EARLY_WINDOW && newMineTime != MBServerStatics.MINE_LATE_WINDOW) return true; //invalid mine time, must be in range + // Update guild mine time + if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), newMineTime)) { Logger.error("MineWindowChange", "Failed to update mine time for guild " + mineGuild.getObjectUUID()); ChatManager.chatGuildError(playerCharacter, "Failed to update the mine time"); return true; } + mineGuild.setMineTime(newMineTime); ChatManager.chatGuildInfo(playerCharacter, "Mine time updated."); diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index e28009af..2f7abea2 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -36,11 +36,14 @@ import engine.net.client.msg.UpdateClientAlliancesMsg; import engine.net.client.msg.guild.GuildInfoMsg; import engine.server.MBServerStatics; import org.joda.time.DateTime; +import org.joda.time.LocalDateTime; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; @@ -79,6 +82,7 @@ public class Guild extends AbstractWorldObject { private String hash; private boolean ownerIsNPC; + public Timestamp lastWooEditTime; public HashMap guildAlliances = new HashMap<>(); /** @@ -176,8 +180,8 @@ public class Guild extends AbstractWorldObject { this.teleportMax = rs.getInt("teleportMax"); this.mineTime = rs.getInt("mineTime"); + this.lastWooEditTime = rs.getTimestamp("lastWooEditTime"); this.hash = rs.getString("hash"); - } public void setNation(Guild nation) { From 4b5ce5bdb1f223220355c3856d05e8d7d845b8a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 11:22:38 -0500 Subject: [PATCH 4/8] 15hr WOO restriction check added. --- .../net/client/handlers/MineWindowChangeHandler.java | 8 ++++++++ src/engine/objects/Guild.java | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java index 5be628c6..141981eb 100644 --- a/src/engine/net/client/handlers/MineWindowChangeHandler.java +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -20,6 +20,7 @@ import engine.net.DispatchMessage; import engine.net.client.ClientConnection; import engine.net.client.msg.ArcMineWindowChangeMsg; import engine.net.client.msg.ClientNetMsg; +import engine.net.client.msg.ErrorPopupMsg; import engine.net.client.msg.KeepAliveServerClientMsg; import engine.objects.Building; import engine.objects.Guild; @@ -74,6 +75,13 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { newMineTime = mineWindowChangeMsg.getTime(); + // Enforce 15hr restriction between WOO edits + + if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(15))) { + ErrorPopupMsg.sendErrorMsg(playerCharacter, "You must wait 15 hours between WOO changes."); + return true; + } + //hodge podge sanity check to make sure they don't set it before early window and is not set at late window. if (newMineTime < MBServerStatics.MINE_EARLY_WINDOW && diff --git a/src/engine/objects/Guild.java b/src/engine/objects/Guild.java index 2f7abea2..fd1a386c 100644 --- a/src/engine/objects/Guild.java +++ b/src/engine/objects/Guild.java @@ -36,12 +36,12 @@ import engine.net.client.msg.UpdateClientAlliancesMsg; import engine.net.client.msg.guild.GuildInfoMsg; import engine.server.MBServerStatics; import org.joda.time.DateTime; -import org.joda.time.LocalDateTime; import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -82,7 +82,7 @@ public class Guild extends AbstractWorldObject { private String hash; private boolean ownerIsNPC; - public Timestamp lastWooEditTime; + public LocalDateTime lastWooEditTime; public HashMap guildAlliances = new HashMap<>(); /** @@ -180,7 +180,12 @@ public class Guild extends AbstractWorldObject { this.teleportMax = rs.getInt("teleportMax"); this.mineTime = rs.getInt("mineTime"); - this.lastWooEditTime = rs.getTimestamp("lastWooEditTime"); + + Timestamp lastWooRequest = rs.getTimestamp("lastWooEditTime"); + + if (lastWooRequest != null) + this.lastWooEditTime = lastWooRequest.toLocalDateTime(); + this.hash = rs.getString("hash"); } From 860d4d9b31d1b8fbc1b015ed0eeff8a812e09b4f Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 11:31:41 -0500 Subject: [PATCH 5/8] Bugfix: setting lastwoocheck field after update. --- src/engine/net/client/handlers/MineWindowChangeHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java index 141981eb..351faed7 100644 --- a/src/engine/net/client/handlers/MineWindowChangeHandler.java +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -97,6 +97,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { } mineGuild.setMineTime(newMineTime); + mineGuild.lastWooEditTime = LocalDateTime.now(); ChatManager.chatGuildInfo(playerCharacter, "Mine time updated."); return true; From 7bc09d86bd5d8008a50d06a8cde1af6617e9fe86 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 12:31:22 -0500 Subject: [PATCH 6/8] Saving WOO timer to database for reboot persist. --- src/engine/db/handlers/dbGuildHandler.java | 9 +++++++-- .../net/client/handlers/MineWindowChangeHandler.java | 11 ++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/engine/db/handlers/dbGuildHandler.java b/src/engine/db/handlers/dbGuildHandler.java index 43d43593..b21ad7d1 100644 --- a/src/engine/db/handlers/dbGuildHandler.java +++ b/src/engine/db/handlers/dbGuildHandler.java @@ -19,6 +19,7 @@ import org.pmw.tinylog.Logger; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.LocalDateTime; import java.util.ArrayList; public class dbGuildHandler extends dbHandlerBase { @@ -114,8 +115,12 @@ public class dbGuildHandler extends dbHandlerBase { return outputStr; } - - + public boolean SET_LAST_WOO_UPDATE(Guild guild, LocalDateTime lastEditTime) { + prepareCallable("UPDATE `obj_guild` SET `lastWooEditTime`=? WHERE `UID`=?"); + setLocalDateTime(1, lastEditTime); + setLong(2, (long) guild.getObjectUUID()); + return (executeUpdate() > 0); + } public ArrayList GET_GUILD_ALLIES(final int id) { prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l " diff --git a/src/engine/net/client/handlers/MineWindowChangeHandler.java b/src/engine/net/client/handlers/MineWindowChangeHandler.java index 351faed7..96312545 100644 --- a/src/engine/net/client/handlers/MineWindowChangeHandler.java +++ b/src/engine/net/client/handlers/MineWindowChangeHandler.java @@ -77,7 +77,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { // Enforce 15hr restriction between WOO edits - if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(15))) { + if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(14))) { ErrorPopupMsg.sendErrorMsg(playerCharacter, "You must wait 15 hours between WOO changes."); return true; } @@ -98,6 +98,15 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { mineGuild.setMineTime(newMineTime); mineGuild.lastWooEditTime = LocalDateTime.now(); + + // Update guild WOO timer for reboot persistence + + if (!DbManager.GuildQueries.SET_LAST_WOO_UPDATE(mineGuild, mineGuild.lastWooEditTime)) { + Logger.error("MineWindowChange", "Failed to update woo timer for guild " + mineGuild.getObjectUUID()); + ChatManager.chatGuildError(playerCharacter, "A Serious error has for to occurred."); + return true; + } + ChatManager.chatGuildInfo(playerCharacter, "Mine time updated."); return true; From 52d3d8ee3a8824bc1eb432821c15752d9ed738f4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 13:26:47 -0500 Subject: [PATCH 7/8] Not adding an extraneous day each reboot. --- src/engine/objects/Mine.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index e53c6d86..e2b435f1 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -166,17 +166,11 @@ public class Mine extends AbstractGameObject { if (LocalDateTime.now().isAfter(this.openDate.plusHours(1))) this.openDate = this.openDate.plusDays(1); return; - }else{ + }else this.openDate = mineTimeStamp.toLocalDateTime().withHour(mineTime); - - if (LocalDateTime.now().isAfter(this.openDate.plusHours(1))){ - this.openDate = this.openDate.plusDays(1); - return; - } - } - + //after 1 day... - if(this.openDate.getDayOfYear() - LocalDateTime.now().getDayOfYear() > 1){ + if (this.openDate.getDayOfYear() - LocalDateTime.now().getDayOfYear() > 1){ this.openDate = this.openDate.withDayOfYear(LocalDateTime.now().getDayOfYear()); if (LocalDateTime.now().isAfter(this.openDate.plusHours(1))) this.openDate = this.openDate.plusDays(1); From df09b6e38b74db78eb44451041639e4e2420a85d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 13:49:31 -0500 Subject: [PATCH 8/8] Removed 30 lines of logic that had no business in a result set constructor. --- src/engine/objects/Mine.java | 43 +++++------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/engine/objects/Mine.java b/src/engine/objects/Mine.java index e2b435f1..cd367251 100644 --- a/src/engine/objects/Mine.java +++ b/src/engine/objects/Mine.java @@ -35,6 +35,7 @@ import org.pmw.tinylog.Logger; import java.net.UnknownHostException; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; @@ -141,41 +142,11 @@ public class Mine extends AbstractGameObject { this.lastClaimerID = 0; this.lastClaimerSessionID = null; - java.sql.Timestamp mineTimeStamp = rs.getTimestamp("mine_openDate"); - - - Building building = BuildingManager.getBuildingFromCache(this.buildingID); - - if (mineTimeStamp == null && (this.owningGuild == null || this.owningGuild.isErrant() || building.getRank() < 1)){ - if (building != null){ - String zoneName = building.getParentZone().getName(); - String parentZoneName = building.getParentZone().getParent().getName(); - Logger.info(zoneName + " in " + parentZoneName + " has a dirty mine, setting active."); - } - this.dirtyMine = true; - openDate = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); - return; - }else if (this.owningGuild.isErrant() || nation.isErrant()){ - openDate = LocalDateTime.now().withMinute(0).withSecond(0).withNano(0); - return; - }else if (mineTimeStamp == null){ - - this.openDate = LocalDateTime.now().withHour(mineTime).withMinute(0).withSecond(0).withNano(0); - - if (LocalDateTime.now().isAfter(this.openDate.plusHours(1))) - this.openDate = this.openDate.plusDays(1); - return; - }else - this.openDate = mineTimeStamp.toLocalDateTime().withHour(mineTime); - - //after 1 day... - if (this.openDate.getDayOfYear() - LocalDateTime.now().getDayOfYear() > 1){ - this.openDate = this.openDate.withDayOfYear(LocalDateTime.now().getDayOfYear()); - if (LocalDateTime.now().isAfter(this.openDate.plusHours(1))) - this.openDate = this.openDate.plusDays(1); - return; - } + Timestamp mineOpenDateTime = rs.getTimestamp("mine_openDate"); + + if (mineOpenDateTime != null) + this.openDate = mineOpenDateTime.toLocalDateTime(); } @@ -252,10 +223,6 @@ try{ */ private void initializeMineTime(){ - //Mine time has already been set at loading from the database. skip. - - if (this.openDate != null) - return; Guild nation = null;