Correct stats bug
This commit is contained in:
parent
f6e556078c
commit
cd29d6748f
@ -122,8 +122,15 @@ public class BotListener extends ListenerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
|
public void onGuildVoiceJoin(GuildVoiceJoinEvent event) {
|
||||||
super.onGuildVoiceJoin(event);
|
super.onGuildVoiceJoin(event);
|
||||||
if(!event.getMember().getUser().isBot())
|
if(!event.getMember().getUser().isBot()){
|
||||||
new UserStatsUtils.VoicePresenceCounter(event.getMember()).start();
|
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
|
@Override
|
||||||
@ -131,7 +138,7 @@ public class BotListener extends ListenerAdapter {
|
|||||||
super.onGuildVoiceLeave(event);
|
super.onGuildVoiceLeave(event);
|
||||||
if(event.getGuild().getAudioManager().isConnected())
|
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){
|
if(event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() == 1){
|
||||||
logger.debug("I'm alone, close audio connection.");
|
logger.debug("I'm alone, close audio connection.");
|
||||||
|
@ -18,6 +18,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UserStatsUtils {
|
public class UserStatsUtils {
|
||||||
@ -34,6 +35,9 @@ public class UserStatsUtils {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public HashMap<Member, VoicePresenceCounter> runningCounters = new HashMap<>();
|
||||||
|
|
||||||
private UserStatsRepository userStatsRepository;
|
private UserStatsRepository userStatsRepository;
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
private PasswordEncoder passwordEncoder;
|
private PasswordEncoder passwordEncoder;
|
||||||
@ -194,6 +198,7 @@ public class UserStatsUtils {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserStatsUtils.getINSTANCE().runningCounters.remove(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user