From 1a8fe6c8ada071568f684a475431fcf26725d049 Mon Sep 17 00:00:00 2001 From: "Ansgar [Hiajen]" Date: Mon, 5 Apr 2021 13:46:02 +0200 Subject: [PATCH] edit VoiceLobby Module to support tempData --- src/main/java/Modules/VoiceLobby.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/Modules/VoiceLobby.java b/src/main/java/Modules/VoiceLobby.java index 0c234dc..e21780f 100644 --- a/src/main/java/Modules/VoiceLobby.java +++ b/src/main/java/Modules/VoiceLobby.java @@ -31,7 +31,6 @@ public class VoiceLobby extends SuperModule { private long groupCategory; private long launchpadChannel; - private HashSet tmpChannel = new HashSet<>(); private Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -98,7 +97,7 @@ public class VoiceLobby extends SuperModule { // move User event.getGuild().moveVoiceMember(((GuildMessageReceivedEvent) event).getMember(), newChannel).queue(); - tmpChannel.add(newChannel.getIdLong()); + ((HashSet)getTemporaryData().get("tmpChannel")).add(newChannel.getIdLong()); } else { thisEvent.getChannel().sendMessage("Please Join a Voice Channel first!").queue(e -> e.delete().queueAfter(1, TimeUnit.MINUTES)); @@ -185,7 +184,7 @@ public class VoiceLobby extends SuperModule { //check if user left a temp channel if ((thisEvent.getChannelLeft() != null && thisEvent.getChannelLeft().getParent().getIdLong() == groupCategory)) { //check if channel is now empty - if (thisEvent.getChannelLeft().getMembers().size() < 1 && tmpChannel.contains(thisEvent.getChannelLeft().getIdLong())) { + if (thisEvent.getChannelLeft().getMembers().size() < 1 && ((HashSet)getTemporaryData().get("tmpChannel")).contains(thisEvent.getChannelLeft().getIdLong())) { logger.debug("may remove channel: " + thisEvent.getChannelLeft().getId()); //wait for 30 seconds and check again @@ -197,7 +196,7 @@ public class VoiceLobby extends SuperModule { logger.debug("remove channel: " + thisEvent.getChannelLeft().getId()); thisEvent.getChannelLeft().delete().queue(); - tmpChannel.remove(thisEvent.getChannelLeft().getIdLong()); + ((HashSet)getTemporaryData().get("tmpChannel")).remove(thisEvent.getChannelLeft().getIdLong()); } else { logger.debug("dont remove channel: " + thisEvent.getChannelLeft().getId()); } @@ -215,7 +214,7 @@ public class VoiceLobby extends SuperModule { // move User event.getGuild().moveVoiceMember(thisEvent.getEntity(), newChannel).queue(); - tmpChannel.add(newChannel.getIdLong()); + ((HashSet)getTemporaryData().get("tmpChannel")).add(newChannel.getIdLong()); } } }