Maybe fixing server crash.

This commit is contained in:
Flanks255 2024-03-10 17:41:48 -05:00
parent be1bb6632a
commit 2a4e966659

View file

@ -23,9 +23,15 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public final class PlayerData { public final class PlayerData {
private static PlayerSave clientData = null;
public static PlayerSave getDataFromPlayer(Player player) { public static PlayerSave getDataFromPlayer(Player player) {
WorldData worldData = WorldData.get((ServerLevel) player.getCommandSenderWorld()); if (!(player.getCommandSenderWorld() instanceof ServerLevel)) {
if (clientData == null) {
clientData = new PlayerSave(player.getUUID());
}
return clientData;
}
WorldData worldData = WorldData.get(player.getCommandSenderWorld());
ConcurrentHashMap<UUID, PlayerSave> data = worldData.playerSaveData; ConcurrentHashMap<UUID, PlayerSave> data = worldData.playerSaveData;
UUID id = player.getUUID(); UUID id = player.getUUID();