From 4b5ce5bdb1f223220355c3856d05e8d7d845b8a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 7 Jan 2023 11:22:38 -0500 Subject: [PATCH] 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"); }