Correct stats bug

This commit is contained in:
Sebastien 2018-12-28 16:48:13 +01:00
parent f6e556078c
commit cd29d6748f
2 changed files with 15 additions and 3 deletions

View File

@ -122,8 +122,15 @@ public class BotListener extends ListenerAdapter {
@Override
public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
super.onGuildVoiceJoin(event);
if(!event.getMember().getUser().isBot())
new UserStatsUtils.VoicePresenceCounter(event.getMember()).start();
if(!event.getMember().getUser().isBot()){
UserStatsUtils userStatsUtils = UserStatsUtils.getINSTANCE();
if(!userStatsUtils.runningCounters.containsKey(event.getMember())){
UserStatsUtils.VoicePresenceCounter temp = new UserStatsUtils.VoicePresenceCounter(event.getMember());
temp.start();
userStatsUtils.runningCounters.put(event.getMember(), temp);
}
}
}
@Override
@ -131,7 +138,7 @@ public class BotListener extends ListenerAdapter {
super.onGuildVoiceLeave(event);
if(event.getGuild().getAudioManager().isConnected())
{
logger.debug("User disconnected from voice channel.");
logger.trace("User disconnected from voice channel.");
if(event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() == 1){
logger.debug("I'm alone, close audio connection.");

View File

@ -18,6 +18,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
public class UserStatsUtils {
@ -34,6 +35,9 @@ public class UserStatsUtils {
return INSTANCE;
}
public HashMap<Member, VoicePresenceCounter> runningCounters = new HashMap<>();
private UserStatsRepository userStatsRepository;
private UserRepository userRepository;
private PasswordEncoder passwordEncoder;
@ -194,6 +198,7 @@ public class UserStatsUtils {
e.printStackTrace();
}
}
UserStatsUtils.getINSTANCE().runningCounters.remove(member);
}
}