1919import technobot .util .enums .Cards ;
2020
2121import java .util .*;
22+ import java .util .concurrent .ScheduledFuture ;
2223import java .util .concurrent .TimeUnit ;
2324
2425/**
@@ -31,6 +32,7 @@ public class BlackjackCommand extends Command {
3132 public static final String CARDBACK_EMOJI = "<:cardback:992575657320140801>" ;
3233 public static final Map <String , Blackjack > games = new HashMap <>();
3334 public static final Map <String , Stack <Cards >> decks = new HashMap <>();
35+ public static final Map <String , ScheduledFuture > resetTimers = new HashMap <>();
3436
3537 public BlackjackCommand (TechnoBot bot ) {
3638 super (bot );
@@ -90,10 +92,10 @@ public void execute(SlashCommandInteractionEvent event) {
9092 event .replyEmbeds (embed ).addActionRow (buttons ).queue (interactionHook -> {
9193 // Delete all game data if no response for 3 min
9294 ButtonListener .disableButtons (uuid , interactionHook );
93- ButtonListener .executor .schedule (() -> {
95+ resetTimers . put ( userID , ButtonListener .executor .schedule (() -> {
9496 decks .remove (userID );
9597 games .remove (userID );
96- }, 3 , TimeUnit .MINUTES );
98+ }, 3 , TimeUnit .MINUTES )) ;
9799 });
98100 }
99101
@@ -280,6 +282,7 @@ public static MessageEmbed stand(Guild guild, User user, long bet, String uuid)
280282 */
281283 public static void endGame (String userID , String uuid ) {
282284 games .remove (userID );
285+ resetTimers .remove (userID ).cancel (true );
283286 List <Button > old = ButtonListener .buttons .get (uuid );
284287 List <Button > components = new ArrayList <>();
285288 components .add (old .get (0 ).asDisabled ());
0 commit comments