Browse Source

Saving WOO timer to database for reboot persist.

master
MagicBot 2 years ago
parent
commit
7bc09d86bd
  1. 9
      src/engine/db/handlers/dbGuildHandler.java
  2. 11
      src/engine/net/client/handlers/MineWindowChangeHandler.java

9
src/engine/db/handlers/dbGuildHandler.java

@ -19,6 +19,7 @@ import org.pmw.tinylog.Logger; @@ -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 { @@ -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<Guild> GET_GUILD_ALLIES(final int id) {
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "

11
src/engine/net/client/handlers/MineWindowChangeHandler.java

@ -77,7 +77,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler { @@ -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 { @@ -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;

Loading…
Cancel
Save