This commit is contained in:
Haowei Wen
2020-10-14 14:36:17 +08:00
committed by Yuhui Huang
parent c191186023
commit 3f85ac208c
4 changed files with 57 additions and 21 deletions

View File

@@ -21,6 +21,8 @@ import org.jackhuang.hmcl.auth.AuthInfo;
import org.jackhuang.hmcl.auth.AuthenticationException;
import org.jackhuang.hmcl.auth.CharacterSelector;
import org.jackhuang.hmcl.auth.ServerDisconnectException;
import org.jackhuang.hmcl.auth.yggdrasil.CompleteGameProfile;
import org.jackhuang.hmcl.auth.yggdrasil.TextureType;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilSession;
import org.jackhuang.hmcl.game.Arguments;
@@ -33,6 +35,8 @@ import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
public class AuthlibInjectorAccount extends YggdrasilAccount {
private final AuthlibInjectorServer server;
@@ -156,4 +160,22 @@ public class AuthlibInjectorAccount extends YggdrasilAccount {
.append("server", getServer().getUrl())
.toString();
}
public static Set<TextureType> getUploadableTextures(CompleteGameProfile profile) {
String prop = profile.getProperties().get("uploadableTextures");
if (prop == null)
return emptySet();
Set<TextureType> result = EnumSet.noneOf(TextureType.class);
for (String val : prop.split(",")) {
val = val.toUpperCase();
TextureType parsed;
try {
parsed = TextureType.valueOf(val);
} catch (IllegalArgumentException e) {
continue;
}
result.add(parsed);
}
return unmodifiableSet(result);
}
}

View File

@@ -17,11 +17,12 @@
*/
package org.jackhuang.hmcl.auth.authlibinjector;
import static org.jackhuang.hmcl.util.io.NetworkUtils.toURL;
import org.jackhuang.hmcl.auth.AuthenticationException;
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilProvider;
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.UUID;
@@ -55,7 +56,7 @@ public class AuthlibInjectorProvider implements YggdrasilProvider {
@Override
public URL getSkinUploadURL(UUID uuid) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
return toURL(apiRoot + "api/user/profile/" + UUIDTypeAdapter.fromUUID(uuid) + "/skin");
}
@Override
@@ -67,12 +68,4 @@ public class AuthlibInjectorProvider implements YggdrasilProvider {
public String toString() {
return apiRoot;
}
private URL toURL(String url) throws AuthenticationException {
try {
return new URL(url);
} catch (MalformedURLException e) {
throw new AuthenticationException(e);
}
}
}