Add any offline uuid data to debug reports

This commit is contained in:
Vankka 2022-12-27 23:43:12 +02:00
parent cfcbada10d
commit 9f6b2ef9fd
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
2 changed files with 12 additions and 0 deletions

View File

@ -127,6 +127,7 @@ public class DebugReport {
values.put("jdaStatus", jda != null ? jda.getStatus().name() : "JDA null");
values.put("platformLogger", discordSRV.platformLogger().getClass().getName());
values.put("onlineMode", discordSRV.onlineMode().name());
values.put("offlineModeUuid", discordSRV.playerProvider().isAnyOffline());
values.put("javaVersion", System.getProperty("java.version"));
values.put("javaVendor", System.getProperty("java.vendor")

View File

@ -31,23 +31,34 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
public abstract class AbstractPlayerProvider<T extends IPlayer, DT extends DiscordSRV> implements PlayerProvider<T> {
private final Map<UUID, T> players = new ConcurrentHashMap<>();
private final List<T> allPlayers = new CopyOnWriteArrayList<>();
protected final DT discordSRV;
private final AtomicBoolean anyOffline = new AtomicBoolean(false);
public AbstractPlayerProvider(DT discordSRV) {
this.discordSRV = discordSRV;
}
public boolean isAnyOffline() {
return anyOffline.get();
}
public abstract void subscribe();
protected void addPlayer(UUID uuid, T player, boolean initial) {
this.players.put(uuid, player);
this.allPlayers.add(player);
discordSRV.scheduler().run(() -> discordSRV.eventBus().publish(new PlayerConnectedEvent(player, initial)));
if (uuid.getLeastSignificantBits() != 0 /* Not Geyser */
&& uuid.version() == 3 /* Offline */) {
anyOffline.set(true);
}
}
protected void removePlayer(UUID uuid) {