diff --git a/VotingPlugin/pom.xml b/VotingPlugin/pom.xml index 8b4ac385a..dec1ab171 100644 --- a/VotingPlugin/pom.xml +++ b/VotingPlugin/pom.xml @@ -1,663 +1,684 @@ - - 4.0.0 - com.bencodez - votingplugin - 7.1.2-SNAPSHOT - jar - VotingPlugin - - github - UTF-8 - NOTSET - 21 - 21 - 21 - 3.4.0 - - - - - src/main/resources - true - - plugin.yml - bungee.yml - votingpluginversion.yml - - - - src/main/resources - false - - plugin.yml - bungee.yml - votingpluginversion.yml - - - - src/main/java - src/test/java - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.projectlombok - lombok-maven-plugin - [1,) - - delombok - - - - - - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 21 - - - org.projectlombok - lombok - 1.18.42 - - - com.velocitypowered - velocity-api - ${velocity.version} - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.2 - - false - false - - - mysql-connector-java - - ** - - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - - - com.tcoded.folialib - - ${project.groupId}.votingplugin.simpleapi.folialib - - - com.bencodez.simpleapi - - ${project.groupId}.votingplugin.simpleapi - - - com.bencodez.advancedcore - - ${project.groupId}.votingplugin.advancedcore - - - net.pl3x.bukkit.chatapi - ${project.groupId}.votingplugin - - - me.mrten.mysqlapi - - ${project.groupId}.votingplugin.mysqlapi - - - com.zaxxer.hikari - ${project.groupId}.votingplugin.simpleapi.hikari - - - org.bstats - - ${project.groupId}.votingplugin.bstats - - - xyz.upperlevel.spigot - - ${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot - - - org.spongepowered.configurate - ${project.groupId}.simpleapi.configurate - - - io.leangen.geantyref - ${project.groupId}.simpleapi.geantyref - - - - - - package - - shade - - - - - - com.google.*:* - - - false - false - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - module-info.class - - - - - - - - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - maven-central - https://oss.sonatype.org/content/groups/public - - - bungeecord-repo - https://oss.sonatype.org/content/repositories/snapshots - - - velocity - https://nexus.velocitypowered.com/repository/maven-public/ - - - bencodez repo - https://nexus.bencodez.com/repository/maven-public/ - - - papermc - https://repo.papermc.io/repository/maven-public/ - - - placeholderapi - - https://repo.extendedclip.com/content/repositories/placeholderapi/ - - - scarsz - https://nexus.scarsz.me/content/groups/public/ - - - - - org.spigotmc - spigot-api - 26.2-R0.1-SNAPSHOT - provided - - - org.projectlombok - lombok - 1.18.42 - provided - - - net.md-5 - bungeecord-api - 1.21-R0.4 - provided - - - com.vexsoftware - nuvotifier-universal - 2.7.2 - provided - - - be.maximvdw - mvdwplaceholderapi - 3.1.1 - provided - - - com.velocitypowered - velocity-api - ${velocity.version} - provided - - - org.bstats - bstats-velocity - 3.2.1 - compile - - - me.clip - placeholderapi - 2.12.2 - provided - - - com.bencodez - advancedcore - 3.8.2-SNAPSHOT - compile - - - org.junit.jupiter - junit-jupiter-engine - 5.12.2 - test - - - org.mockito - mockito-core - 5.21.0 - test - - - org.junit.jupiter - junit-jupiter-api - 5.12.2 - test - - - org.mockito - mockito-junit-jupiter - 5.23.0 - test - - - com.discordsrv - discordsrv - 1.30.4 - provided - - - org.spongepowered - configurate-core - 4.2.0 - - - org.spongepowered - configurate-yaml - 4.2.0 - - - org.spongepowered - configurate-gson - 4.2.0 - - - - - default - - default - - - true - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.5.0 - - - - mojang - - - ${project.name} - - - - - - - deploy-snapshot - - dev-snapshot - - - - nexus - https://nexus.bencodez.com/repository/maven-snapshots/ - - - nexus - https://nexus.bencodez.com/repository/maven-releases/ - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.5.0 - - - - mojang - - - - ${project.name}-${build.number} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.12.0 - - - attach-javadocs - - jar - - deploy - - false - none - - ${project.basedir}/target/delombok - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.4 - - true - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.7.0 - - - default-deploy - deploy - - deploy - - - - - nexus - https://nexus.bencodez.com/nexus/ - true - - - - - - - javadoc - - javadoc - - - - internal.repo - Temporary Staging Repository - file://${project.build.directory}/mvn-repo - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.5.0 - - - - mojang - - - ${project.name} - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.12.0 - - - attach-javadocs - - jar - - deploy - - - ${project.basedir}/target/delombok - - ${project.basedir}/target/apidocs - - - - - - com.coderplus.maven.plugins - copy-rename-maven-plugin - 1.0.1 - - - copy-file - deploy - - copy - - - - ${project.basedir}/target/${project.name}.jar - - ${project.basedir}/target/${project.name}-${project.version}.jar - - - - - - - - - dev - - dev - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.5.0 - - - - mojang - - - ${project.name} - - - - maven-resources-plugin - 3.4.0 - - - copy-resources - install - - copy-resources - - - - ${user.home}/Documents/Test_Server/plugins - - - ${basedir}/target - - VotingPlugin.jar - - - - true - - - - - - - - - deploy - - deploy - - - - nexus - https://nexus.bencodez.com/repository/maven-snapshots/ - - - nexus - https://nexus.bencodez.com/repository/maven-releases/ - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.5.0 - - - - mojang - - - ${project.name} - - - - com.coderplus.maven.plugins - copy-rename-maven-plugin - 1.0.1 - - - copy-file - deploy - - copy - - - - ${project.basedir}/target/${project.name}.jar - - ${project.basedir}/target/${project.name}-${project.version}.jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.12.0 - - - attach-javadocs - - jar - - deploy - - - ${project.basedir}/target/delombok - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.4 - - true - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.7.0 - - - default-deploy - deploy - - deploy - - - - - nexus - https://nexus.bencodez.com/nexus/ - true - - - - - - + + 4.0.0 + com.bencodez + votingplugin + 7.1.2-SNAPSHOT + jar + VotingPlugin + + github + UTF-8 + NOTSET + 21 + 21 + 21 + 3.4.0 + + + + + src/main/resources + true + + plugin.yml + bungee.yml + votingpluginversion.yml + + + + src/main/resources + false + + plugin.yml + bungee.yml + votingpluginversion.yml + + + + src/main/java + src/test/java + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.projectlombok + lombok-maven-plugin + [1,) + + delombok + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 21 + + + org.projectlombok + lombok + 1.18.42 + + + com.velocitypowered + velocity-api + ${velocity.version} + + + com.velocitypowered + velocity-brigadier + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.2 + + false + false + + + mysql-connector-java + + ** + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + com.tcoded.folialib + + ${project.groupId}.votingplugin.simpleapi.folialib + + + com.bencodez.simpleapi + + ${project.groupId}.votingplugin.simpleapi + + + com.bencodez.advancedcore + + ${project.groupId}.votingplugin.advancedcore + + + net.pl3x.bukkit.chatapi + ${project.groupId}.votingplugin + + + me.mrten.mysqlapi + + ${project.groupId}.votingplugin.mysqlapi + + + com.zaxxer.hikari + ${project.groupId}.votingplugin.simpleapi.hikari + + + org.bstats + + ${project.groupId}.votingplugin.bstats + + + xyz.upperlevel.spigot + + ${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot + + + org.spongepowered.configurate + ${project.groupId}.simpleapi.configurate + + + io.leangen.geantyref + ${project.groupId}.simpleapi.geantyref + + + + + + package + + shade + + + + + + com.google.*:* + + + false + false + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + module-info.class + + + + + + + + + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + maven-central + https://oss.sonatype.org/content/groups/public + + + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + + + velocity + https://nexus.velocitypowered.com/repository/maven-public/ + + + bencodez repo + https://nexus.bencodez.com/repository/maven-public/ + + + papermc + https://repo.papermc.io/repository/maven-public/ + + false + + + + placeholderapi + + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + scarsz + https://nexus.scarsz.me/content/groups/public/ + + + + + org.spigotmc + spigot-api + 26.2-R0.1-SNAPSHOT + provided + + + com.velocitypowered + velocity-brigadier + + + + + org.projectlombok + lombok + 1.18.42 + provided + + + net.md-5 + bungeecord-api + 1.21-R0.4 + provided + + + com.vexsoftware + nuvotifier-universal + 2.7.2 + provided + + + be.maximvdw + mvdwplaceholderapi + 3.1.1 + provided + + + com.velocitypowered + velocity-api + ${velocity.version} + provided + + + com.velocitypowered + velocity-brigadier + + + + + org.bstats + bstats-velocity + 3.2.1 + compile + + + me.clip + placeholderapi + 2.12.2 + provided + + + com.bencodez + advancedcore + 3.8.2-SNAPSHOT + compile + + + org.junit.jupiter + junit-jupiter-engine + 5.12.2 + test + + + org.mockito + mockito-core + 5.21.0 + test + + + org.junit.jupiter + junit-jupiter-api + 5.12.2 + test + + + org.mockito + mockito-junit-jupiter + 5.23.0 + test + + + com.discordsrv + discordsrv + 1.30.4 + provided + + + org.spongepowered + configurate-core + 4.2.0 + + + org.spongepowered + configurate-yaml + 4.2.0 + + + org.spongepowered + configurate-gson + 4.2.0 + + + + + default + + default + + + true + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + mojang + + + ${project.name} + + + + + + + deploy-snapshot + + dev-snapshot + + + + nexus + https://nexus.bencodez.com/repository/maven-snapshots/ + + + nexus + https://nexus.bencodez.com/repository/maven-releases/ + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + mojang + + + + ${project.name}-${build.number} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.12.0 + + + attach-javadocs + + jar + + deploy + + false + none + + ${project.basedir}/target/delombok + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.4 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.7.0 + + + default-deploy + deploy + + deploy + + + + + nexus + https://nexus.bencodez.com/nexus/ + true + + + + + + + javadoc + + javadoc + + + + internal.repo + Temporary Staging Repository + file://${project.build.directory}/mvn-repo + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + mojang + + + ${project.name} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.12.0 + + + attach-javadocs + + jar + + deploy + + + ${project.basedir}/target/delombok + + ${project.basedir}/target/apidocs + + + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0.1 + + + copy-file + deploy + + copy + + + + ${project.basedir}/target/${project.name}.jar + + ${project.basedir}/target/${project.name}-${project.version}.jar + + + + + + + + + dev + + dev + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + mojang + + + ${project.name} + + + + maven-resources-plugin + 3.4.0 + + + copy-resources + install + + copy-resources + + + + ${user.home}/Documents/Test_Server/plugins + + + ${basedir}/target + + VotingPlugin.jar + + + + true + + + + + + + + + deploy + + deploy + + + + nexus + https://nexus.bencodez.com/repository/maven-snapshots/ + + + nexus + https://nexus.bencodez.com/repository/maven-releases/ + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.5.0 + + + + mojang + + + ${project.name} + + + + com.coderplus.maven.plugins + copy-rename-maven-plugin + 1.0.1 + + + copy-file + deploy + + copy + + + + ${project.basedir}/target/${project.name}.jar + + ${project.basedir}/target/${project.name}-${project.version}.jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.12.0 + + + attach-javadocs + + jar + + deploy + + + ${project.basedir}/target/delombok + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.4 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.7.0 + + + default-deploy + deploy + + deploy + + + + + nexus + https://nexus.bencodez.com/nexus/ + true + + + + + + \ No newline at end of file diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/BungeeHandler.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/BungeeHandler.java index 04009bac3..e6c7223e6 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/BungeeHandler.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/BungeeHandler.java @@ -651,7 +651,10 @@ private void handleWireVote(JsonEnvelope msg) { boolean setTotalsOnBackend = !v.manageTotals; - user.bungeeVotePluginMessaging(service, v.time, text, setTotalsOnBackend, v.wasOnline, v.broadcast, v.num); + boolean identifiedQueuedDelivery = VotingPluginWire.SUB_VOTE_ONLINE.equals(msg.getSubChannel()) + && v.voteId != null; + user.bungeeVotePluginMessaging(service, v.time, text, setTotalsOnBackend, v.wasOnline, v.broadcast, v.num, + identifiedQueuedDelivery); if (plugin.getBungeeSettings().isPerServerPoints()) { user.addPoints(plugin.getConfigFile().getPointsOnVote()); diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/events/PlayerVoteEvent.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/events/PlayerVoteEvent.java index 209fa68bb..c3c9d431e 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/events/PlayerVoteEvent.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/events/PlayerVoteEvent.java @@ -75,6 +75,11 @@ public static HandlerList getHandlerList() { @Getter @Setter private boolean wasOnline; + + /** Whether this event is the identified delivery of a queued proxy vote. */ + @Getter + @Setter + private boolean queuedProxyVote; @Getter @Setter diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/PlayerVoteListener.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/PlayerVoteListener.java index b6a47837e..79fac5628 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/PlayerVoteListener.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/PlayerVoteListener.java @@ -162,8 +162,8 @@ public void onplayerVote(PlayerVoteEvent event) { } } - boolean queuedProxyVoteAlreadyRecorded = ProxyVoteDelayCheck.isQueuedVoteAlreadyRecorded(event.isBungee(), - event.getTime(), user.getTime(voteSite)); + boolean queuedProxyVoteAlreadyRecorded = event.isBungee() && event.isQueuedProxyVote() + && event.getTime() > 0L && event.getTime() == user.getTime(voteSite); if (voteSite.isWaitUntilVoteDelay() && !queuedProxyVoteAlreadyRecorded && !user.canVoteSite(voteSite)) { if (!event.isRealVote()) { plugin.getLogger().info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay"); @@ -183,11 +183,6 @@ public void onplayerVote(PlayerVoteEvent event) { .info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing"); } } - if (queuedProxyVoteAlreadyRecorded) { - plugin.debug("Allowing queued proxy vote for " + user.getPlayerName() + " on " + voteSite.getKey() - + "; proxy vote time already matches LastVotes: " + event.getTime()); - } - UUID voteUUID = UUID.randomUUID(); if (event.isBungee() && event.getBungeeTextTotals() != null) { voteUUID = event.getBungeeTextTotals().getVoteUUID(); diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/ProxyVoteDelayCheck.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/ProxyVoteDelayCheck.java deleted file mode 100644 index 48a52e406..000000000 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/listeners/ProxyVoteDelayCheck.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.bencodez.votingplugin.listeners; - -/** - * Handles the WaitUntilVoteDelay exception for votes queued by a proxy. - */ -public final class ProxyVoteDelayCheck { - - private ProxyVoteDelayCheck() { - } - - /** - * A proxy stores the real vote timestamp before its queued message reaches the - * backend. The backend must accept that one delivery when the stored timestamp - * is the same timestamp carried by the message. - * - * @param proxyVote true when the vote was forwarded by VotingPlugin's proxy - * @param messageVoteTime real vote time included in the proxy message - * @param storedVoteTime current backend last-vote time for the site - * @return true when the delay check should allow the queued delivery - */ - public static boolean isQueuedVoteAlreadyRecorded(boolean proxyVote, long messageVoteTime, long storedVoteTime) { - return proxyVote && messageVoteTime > 0L && messageVoteTime == storedVoteTime; - } -} diff --git a/VotingPlugin/src/main/java/com/bencodez/votingplugin/user/VotingPluginUser.java b/VotingPlugin/src/main/java/com/bencodez/votingplugin/user/VotingPluginUser.java index c7907b0f4..4b860e970 100644 --- a/VotingPlugin/src/main/java/com/bencodez/votingplugin/user/VotingPluginUser.java +++ b/VotingPlugin/src/main/java/com/bencodez/votingplugin/user/VotingPluginUser.java @@ -259,8 +259,8 @@ public void addWeekVoteStreak() { * @param broadcast whether to broadcast the vote * @param num the vote number */ - public void bungeeVotePluginMessaging(String service, long time, VoteTotalsSnapshot text, boolean setTotals, - boolean wasOnline, boolean broadcast, int num) { + public void bungeeVotePluginMessaging(String service, long time, VoteTotalsSnapshot text, boolean setTotals, + boolean wasOnline, boolean broadcast, int num, boolean queuedProxyVote) { if (plugin.getBungeeSettings().isUseBungeecoord()) { plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service); @@ -275,6 +275,7 @@ public void bungeeVotePluginMessaging(String service, long time, VoteTotalsSnaps voteEvent.setWasOnline(wasOnline); voteEvent.setBroadcast(broadcast); voteEvent.setVoteNumber(num); + voteEvent.setQueuedProxyVote(queuedProxyVote); plugin.getServer().getPluginManager().callEvent(voteEvent); } } diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/PlayerVoteEventTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/PlayerVoteEventTest.java new file mode 100644 index 000000000..12b4078a7 --- /dev/null +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/PlayerVoteEventTest.java @@ -0,0 +1,30 @@ +package com.bencodez.votingplugin.tests; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +import com.bencodez.votingplugin.events.PlayerVoteEvent; + +/** + * Tests queue-delivery metadata carried by proxy vote events. + */ +public class PlayerVoteEventTest { + + @Test + public void eventIsNotQueuedByDefault() { + PlayerVoteEvent event = new PlayerVoteEvent(null, "Player", "Service", true); + + assertFalse(event.isQueuedProxyVote()); + } + + @Test + public void eventCanMarkAnIdentifiedQueuedProxyDelivery() { + PlayerVoteEvent event = new PlayerVoteEvent(null, "Player", "Service", true); + + event.setQueuedProxyVote(true); + + assertTrue(event.isQueuedProxyVote()); + } +} diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/ProxyVoteDelayCheckTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/ProxyVoteDelayCheckTest.java deleted file mode 100644 index 2e2c67add..000000000 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/ProxyVoteDelayCheckTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.bencodez.votingplugin.tests; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import org.junit.jupiter.api.Test; - -import com.bencodez.votingplugin.listeners.ProxyVoteDelayCheck; - -class ProxyVoteDelayCheckTest { - - @Test - void acceptsQueuedProxyVoteWhenTheProxyTimestampIsAlreadyStored() { - assertTrue(ProxyVoteDelayCheck.isQueuedVoteAlreadyRecorded(true, 12345L, 12345L)); - } - - @Test - void doesNotBypassTheDelayForDirectOrStaleProxyVotes() { - assertFalse(ProxyVoteDelayCheck.isQueuedVoteAlreadyRecorded(false, 12345L, 12345L)); - assertFalse(ProxyVoteDelayCheck.isQueuedVoteAlreadyRecorded(true, 12344L, 12345L)); - assertFalse(ProxyVoteDelayCheck.isQueuedVoteAlreadyRecorded(true, 0L, 0L)); - } -} diff --git a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginWireTest.java b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginWireTest.java index 78c0a3534..b4d031e59 100644 --- a/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginWireTest.java +++ b/VotingPlugin/src/test/java/com/bencodez/votingplugin/tests/VotingPluginWireTest.java @@ -27,6 +27,7 @@ public void voteRoundTripPreservesVoteId() { Vote vote = VotingPluginWire.readVote(envelope); assertEquals(voteId, vote.voteId); + assertEquals(VotingPluginWire.SUB_VOTE, envelope.getSubChannel()); assertEquals("Player", vote.player); assertEquals("Service", vote.service); } @@ -39,6 +40,20 @@ public void voteOnlineRoundTripAllowsMissingVoteId() { Vote vote = VotingPluginWire.readVote(envelope); assertNull(vote.voteId); + assertEquals(VotingPluginWire.SUB_VOTE_ONLINE, envelope.getSubChannel()); + } + + @Test + public void voteOnlineRoundTripPreservesIdentifiedQueuedVote() { + UUID voteId = UUID.randomUUID(); + + JsonEnvelope envelope = VotingPluginWire.voteOnline("Player", UUID.randomUUID().toString(), "Service", + 100L, true, true, "totals", voteId, true, false, 1, 1); + + Vote vote = VotingPluginWire.readVote(envelope); + + assertEquals(VotingPluginWire.SUB_VOTE_ONLINE, envelope.getSubChannel()); + assertEquals(voteId, vote.voteId); } @Test