From 7bc09d86bd5d8008a50d06a8cde1af6617e9fe86 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 12:31:22 -0500 Subject: [PATCH] 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;