-
-
Notifications
You must be signed in to change notification settings - Fork 82
Enforce vote delay for proxy votes #1545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a261674
a0e254a
2bc3963
c126a9f
424cf9a
707c654
ad94404
b9a0ef6
9f73e37
d12de4a
617dd90
6a71c47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Comment on lines
+656
to
+657
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
|
|
||
| if (plugin.getBungeeSettings().isPerServerPoints()) { | ||
| user.addPoints(plugin.getConfigFile().getPointsOnVote()); | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Comment on lines
+262
to
+263
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Changing this public method's descriptor from seven parameters to eight removes the method that already-compiled integrations link against. The project publishes the plugin as a Maven dependency and generates API documentation, so any downstream plugin calling the former Useful? React with 👍 / 👎. |
||
| 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); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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()); | ||
| } | ||
| } |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
VoteOnlinesubchannel plus any non-null wire-supplied UUID does not prove that this message is the current delivery of anOnlineCacheentry. AfterprocessedWireVotesexpires the UUID in 30 minutes (or after a backend restart), replaying a previously acceptedVoteOnlinereserves the ID again; its timestamp still equalsLastVotes, so this classification causes the listener to skipWaitUntilVoteDelayand process duplicate rewards/totals. A forgedVoteOnlinewith a fresh UUID and the stored timestamp has the same result. Bind the exception to actual queue-delivery provenance rather than these forgeable fields.Useful? React with 👍 / 👎.