From 3bd41af20044b035698c4bf1a758c0245293d3d8 Mon Sep 17 00:00:00 2001 From: BenCodez Date: Fri, 13 Dec 2024 09:43:04 -0600 Subject: [PATCH] Add extra checks on proxy time changes --- .../bencodez/votingplugin/BungeeHandler.java | 10 +++++++++ .../bungee/VotingPluginBungee.java | 22 ++++++++++++++----- .../bungee/velocity/VotingPluginVelocity.java | 19 ++++++++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java b/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java index 1f0658fdb..7c252c506 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/BungeeHandler.java @@ -228,6 +228,11 @@ public void debug(Exception e) { public void debug(String text) { plugin.debug(text); } + + @Override + public void info(String text) { + plugin.getLogger().info(text); + } }); } else { globalDataHandler = new GlobalDataHandler( @@ -253,6 +258,11 @@ public void debug(Exception e) { public void debug(String text) { plugin.debug(text); } + + @Override + public void info(String text) { + plugin.getLogger().info(text); + } }); } globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)"); diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java index c53b30ec0..60fe0c0f9 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/VotingPluginBungee.java @@ -355,6 +355,12 @@ public void debug(Exception e) { public void debug(String text) { debug2(text); } + + @Override + public void info(String text) { + getLogger().info(text); + + } }, servers) { @Override @@ -412,6 +418,12 @@ public void debug(Exception e) { public void debug(String text) { debug2(text); } + + @Override + public void info(String text) { + getLogger().info(text); + + } }, servers) { @Override @@ -632,6 +644,7 @@ public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) checkVoteCacheTime(); } if (!config.getGlobalDataEnabled()) { + getLogger().warning("Global data not enabled, ignoring time change event"); return; } for (String s : getAvailableAllServers()) { @@ -751,7 +764,6 @@ public void debug(String text) { bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass()); bungeeTimeChecker.loadTimer(); - nonVotedPlayersCache = new NonVotedPlayersCache(this); nonVotedPlayersCache.load(); @@ -1380,10 +1392,10 @@ public synchronized void vote(String player, String service, boolean realVote, b getLogger().info("No name from vote on " + service); return; } - - if (timeQueue) { - if (getConfig().getGlobalDataEnabled()) { - if (getGlobalDataHandler().isTimeChangedHappened()) { + if (getConfig().getGlobalDataEnabled()) { + if (getGlobalDataHandler().isTimeChangedHappened()) { + getGlobalDataHandler().checkForFinishedTimeChanges(); + if (timeQueue) { timeChangeQueue.add(new VoteTimeQueue(player, service, LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())); getLogger().info("Cachcing vote from " + player + "/" + service diff --git a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java index d6e978104..dd4635529 100644 --- a/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java +++ b/VotingPlugin/src/com/bencodez/votingplugin/bungee/velocity/VotingPluginVelocity.java @@ -364,6 +364,11 @@ public void debug(Exception e) { public void debug(String text) { debug2(text); } + + @Override + public void info(String text) { + logger.info(text); + } }, servers) { @Override @@ -417,6 +422,11 @@ public void debug(Exception e) { public void debug(String text) { debug2(text); } + + @Override + public void info(String text) { + logger.info(text); + } }, servers) { @Override @@ -683,6 +693,7 @@ public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) checkVoteCacheTime(); } if (!config.getGlobalDataEnabled()) { + getLogger().warn("Global data not enabled, ignoring time change event"); return; } for (RegisteredServer s : getAvailableAllServers()) { @@ -1454,10 +1465,10 @@ public synchronized void vote(String player, String service, boolean realVote, b logger.info("No name from vote on " + service); return; } - - if (timeQueue) { - if (getConfig().getGlobalDataEnabled()) { - if (getGlobalDataHandler().isTimeChangedHappened()) { + if (getConfig().getGlobalDataEnabled()) { + if (getGlobalDataHandler().isTimeChangedHappened()) { + getGlobalDataHandler().checkForFinishedTimeChanges(); + if (timeQueue) { timeChangeQueue.add(new VoteTimeQueue(player, service, LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli())); getLogger().info("Cachcing vote from " + player + "/" + service