From d953e631b92c23530af93540cc26d36f46bca096 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 16 Aug 2026 18:20:44 -0600 Subject: [PATCH] Preserve send-to-all routing in dedicated mode AI disclosure: This commit message was written with assistance from ChatGPT. --- .../votingplugin/proxy/VotingPluginProxy.java | 11 ++++++++++- .../votingplugin/tests/VotingPluginProxyTest.java | 11 +++++++++++ .../votingplugin/tests/VotingPluginProxyTestImpl.java | 4 ++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/proxy/VotingPluginProxy.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/proxy/VotingPluginProxy.java index 162d3303a..fe623a7db 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/proxy/VotingPluginProxy.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/proxy/VotingPluginProxy.java @@ -2953,7 +2953,7 @@ private synchronized QueuedVoteResult vote(String player, String service, boolea // =========================== // Send vote(s) to backend(s) // =========================== - if (getConfig().getSendVotesToAllServers()) { + if (shouldSendVoteToAllServers()) { for (String s : getAllAvailableServers()) { boolean forceCache = getConfig().getWaitForUserOnline() @@ -3094,6 +3094,15 @@ private synchronized QueuedVoteResult vote(String player, String service, boolea } } + /** + * Keeps vote fan-out independent from dedicated-presence routing and backend + * reward-storage settings. The proxy obeys SendVotesToAllServers exactly as + * configured; each backend applies its own reward behavior on receipt. + */ + protected boolean shouldSendVoteToAllServers() { + return getConfig().getSendVotesToAllServers(); + } + private static final class PendingPresenceHandoff { private UUID requestId; private final UUID playerUuid; diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTest.java index 3c03997bf..6be771e7a 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTest.java @@ -191,6 +191,17 @@ void dedicatedVotingProxyDoesNotUsePluginMessagingPresence() { assertEquals("Server1", votingPluginProxy.getCurrentPlayerServerForVoteRoutingForTest("Player")); } + @Test + void dedicatedVotingProxyPreservesSendVotesToAllServersSetting() { + Mockito.when(votingPluginProxy.getConfig().getDedicatedVotingProxy()).thenReturn(true); + votingPluginProxy.setMethod(BungeeMethod.MQTT); + Mockito.when(votingPluginProxy.getConfig().getSendVotesToAllServers()).thenReturn(true); + assertTrue(votingPluginProxy.shouldSendVoteToAllServersForTest()); + + Mockito.when(votingPluginProxy.getConfig().getSendVotesToAllServers()).thenReturn(false); + assertFalse(votingPluginProxy.shouldSendVoteToAllServersForTest()); + } + @Test void dedicatedSnapshotDrainsCachedVotesForConfirmedPlayers() { Mockito.when(votingPluginProxy.getConfig().getDedicatedVotingProxy()).thenReturn(true); diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTestImpl.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTestImpl.java index 500c04370..ac3b0ad41 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTestImpl.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginProxyTestImpl.java @@ -269,6 +269,10 @@ public void processDedicatedSnapshotLoginsForTest(String server, Set hando processDedicatedSnapshotLogins(server, handoffPlayers); } + public boolean shouldSendVoteToAllServersForTest() { + return shouldSendVoteToAllServers(); + } + @Override public void setVoteCacheLastUpdated() { // TODO Auto-generated method stub