minecraft-src/net/minecraft/server/Services.java
2025-07-04 01:41:11 +03:00

33 lines
1.5 KiB
Java

package net.minecraft.server;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.yggdrasil.ServicesKeySet;
import com.mojang.authlib.yggdrasil.ServicesKeyType;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import java.io.File;
import net.minecraft.server.players.GameProfileCache;
import net.minecraft.util.SignatureValidator;
import org.jetbrains.annotations.Nullable;
public record Services(
MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache
) {
private static final String USERID_CACHE_FILE = "usercache.json";
public static Services create(YggdrasilAuthenticationService authenticationService, File profileRepository) {
MinecraftSessionService minecraftSessionService = authenticationService.createMinecraftSessionService();
GameProfileRepository gameProfileRepository = authenticationService.createProfileRepository();
GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, new File(profileRepository, "usercache.json"));
return new Services(minecraftSessionService, authenticationService.getServicesKeySet(), gameProfileRepository, gameProfileCache);
}
@Nullable
public SignatureValidator profileKeySignatureValidator() {
return SignatureValidator.from(this.servicesKeySet, ServicesKeyType.PROFILE_KEY);
}
public boolean canValidateProfileKeys() {
return !this.servicesKeySet.keys(ServicesKeyType.PROFILE_KEY).isEmpty();
}
}