@@ -152,6 +152,31 @@ private static YamlConfiguration rootWithLegacyListRewards() {
152152 return root ;
153153 }
154154
155+ private static MemoryConfiguration rootWithThreeStreaks () {
156+ MemoryConfiguration root = new MemoryConfiguration ();
157+ ConfigurationSection voteStreaks = root .createSection ("VoteStreaks" );
158+
159+ addStreak (voteStreaks , "Daily3" , "DAILY" , true , 3 , 1 , 1 , 7 );
160+ addStreak (voteStreaks , "Daily7" , "DAILY" , true , 7 , 1 , 1 , 7 );
161+ addStreak (voteStreaks , "Weekly2" , "WEEKLY" , true , 2 , 1 , 0 , 0 );
162+
163+ return root ;
164+ }
165+
166+ private static void addStreak (ConfigurationSection voteStreaks , String id , String type , boolean enabled ,
167+ int intervalAmount , int votesRequired , int allowMissedAmount , int allowMissedPeriod ) {
168+ ConfigurationSection def = voteStreaks .createSection (id );
169+ def .set ("Type" , type );
170+ def .set ("Enabled" , enabled );
171+
172+ ConfigurationSection req = def .createSection ("Requirements" );
173+ req .set ("Amount" , intervalAmount );
174+ req .set ("VotesRequired" , votesRequired );
175+
176+ def .set ("AllowMissedAmount" , allowMissedAmount );
177+ def .set ("AllowMissedPeriod" , allowMissedPeriod );
178+ }
179+
155180 /**
156181 * periodKey|streakCount|votesThisPeriod|countedThisPeriod|missWindowStartKey|missesUsed
157182 *
@@ -265,6 +290,74 @@ void shouldReward_respectsRecurringFlag() throws Exception {
265290 assertTrue (shouldReward (recurring , 6 ));
266291 }
267292
293+ @ Test
294+ void resetVoteStreaks_resetsAllConfiguredDefinitions () {
295+ loadFromRoot (rootWithThreeStreaks ());
296+
297+ Map <String , String > backing = new HashMap <>();
298+ VotingPluginUser user = mapBackedUser (UUID .randomUUID (), "Ben" , backing );
299+ for (VoteStreakDefinition def : handler .getDefinitions ()) {
300+ backing .put (handler .getColumnName (def ), "2026-01-10|5|1|true||0" );
301+ }
302+
303+ int reset = handler .resetVoteStreaks (user );
304+
305+ assertEquals (3 , reset );
306+ for (VoteStreakDefinition def : handler .getDefinitions ()) {
307+ assertEquals ("" , backing .get (handler .getColumnName (def )));
308+ }
309+ }
310+
311+ @ Test
312+ void resetVoteStreaks_byTypeResetsOnlyMatchingDefinitions () {
313+ loadFromRoot (rootWithThreeStreaks ());
314+
315+ Map <String , String > backing = new HashMap <>();
316+ VotingPluginUser user = mapBackedUser (UUID .randomUUID (), "Ben" , backing );
317+ VoteStreakDefinition daily3 = handler .getDefinition ("Daily3" );
318+ VoteStreakDefinition daily7 = handler .getDefinition ("Daily7" );
319+ VoteStreakDefinition weekly2 = handler .getDefinition ("Weekly2" );
320+
321+ backing .put (handler .getColumnName (daily3 ), "2026-01-10|3|1|true||0" );
322+ backing .put (handler .getColumnName (daily7 ), "2026-01-10|7|1|true||0" );
323+ backing .put (handler .getColumnName (weekly2 ), "2026-W02|2|1|true||0" );
324+
325+ int reset = handler .resetVoteStreaks (user , VoteStreakType .DAILY );
326+
327+ assertEquals (2 , reset );
328+ assertEquals ("" , backing .get (handler .getColumnName (daily3 )));
329+ assertEquals ("" , backing .get (handler .getColumnName (daily7 )));
330+ assertEquals ("2026-W02|2|1|true||0" , backing .get (handler .getColumnName (weekly2 )));
331+ }
332+
333+ @ Test
334+ void resetVoteStreak_byIdResetsOnlyMatchingDefinition () {
335+ loadFromRoot (rootWithThreeStreaks ());
336+
337+ Map <String , String > backing = new HashMap <>();
338+ VotingPluginUser user = mapBackedUser (UUID .randomUUID (), "Ben" , backing );
339+ VoteStreakDefinition daily3 = handler .getDefinition ("Daily3" );
340+ VoteStreakDefinition weekly2 = handler .getDefinition ("Weekly2" );
341+
342+ backing .put (handler .getColumnName (daily3 ), "2026-01-10|3|1|true||0" );
343+ backing .put (handler .getColumnName (weekly2 ), "2026-W02|2|1|true||0" );
344+
345+ assertTrue (handler .resetVoteStreak (user , "daily3" ));
346+ assertEquals ("" , backing .get (handler .getColumnName (daily3 )));
347+ assertEquals ("2026-W02|2|1|true||0" , backing .get (handler .getColumnName (weekly2 )));
348+ }
349+
350+ @ Test
351+ void resetVoteStreak_unknownIdReturnsFalse () {
352+ loadFromRoot (rootWithThreeStreaks ());
353+
354+ Map <String , String > backing = new HashMap <>();
355+ VotingPluginUser user = mapBackedUser (UUID .randomUUID (), "Ben" , backing );
356+
357+ assertFalse (handler .resetVoteStreak (user , "missing" ));
358+ assertTrue (backing .isEmpty ());
359+ }
360+
268361 @ Test
269362 void migrateLegacyConfigManually_migratesOnlyEnabledLegacyEntries () {
270363 YamlConfiguration root = rootWithLegacyVoteStreaks ();
0 commit comments