mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
fix GameProfileRepository interface impl
This commit is contained in:
@@ -5,6 +5,8 @@ import com.google.common.cache.CacheLoader;
|
|||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import com.mojang.authlib.GameProfileRepository;
|
||||||
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||||
import com.mojang.util.UndashedUuid;
|
import com.mojang.util.UndashedUuid;
|
||||||
@@ -46,13 +48,26 @@ public final class MojangSkinProvider implements SkinProvider {
|
|||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE_CACHE = new GameProfileCache((names, callback) -> {
|
PROFILE_CACHE = new GameProfileCache(new GameProfileRepository() {
|
||||||
for (var name : names) {
|
@Override
|
||||||
|
public void findProfilesByNames(String[] names, ProfileLookupCallback callback) {
|
||||||
|
for (var name : names) {
|
||||||
|
try {
|
||||||
|
var profile = MojangSkinProvider.getProfile(name);
|
||||||
|
callback.onProfileLookupSucceeded(profile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
callback.onProfileLookupFailed(name, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<GameProfile> findProfileByName(String name) {
|
||||||
try {
|
try {
|
||||||
var profile = MojangSkinProvider.getProfile(name);
|
var profile = MojangSkinProvider.getProfile(name);
|
||||||
callback.onProfileLookupSucceeded(profile);
|
return Optional.of(profile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
callback.onProfileLookupFailed(name, e);
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
||||||
|
|||||||
Reference in New Issue
Block a user