Launcher/LauncherAuthlib/src/main/java/com/mojang/authlib/yggdrasil/CompatProfile.java

56 lines
1.9 KiB
Java
Raw Normal View History

2018-09-17 10:07:32 +03:00
package com.mojang.authlib.yggdrasil;
2019-06-03 10:58:10 +03:00
import java.util.UUID;
import pro.gravit.launcher.Launcher;
import pro.gravit.launcher.LauncherAPI;
import pro.gravit.launcher.profiles.PlayerProfile;
import pro.gravit.utils.helper.SecurityHelper;
2018-09-17 10:07:32 +03:00
@LauncherAPI
public class CompatProfile {
2018-09-25 17:06:13 +03:00
public static final String SKIN_URL_PROPERTY = Launcher.SKIN_URL_PROPERTY;
public static final String SKIN_DIGEST_PROPERTY = Launcher.SKIN_DIGEST_PROPERTY;
public static final String CLOAK_URL_PROPERTY = Launcher.CLOAK_URL_PROPERTY;
public static final String CLOAK_DIGEST_PROPERTY = Launcher.CLOAK_DIGEST_PROPERTY;
2018-09-17 10:07:32 +03:00
public static CompatProfile fromPlayerProfile(PlayerProfile profile) {
return profile == null ? null : new CompatProfile(profile.uuid, profile.username,
profile.skin == null ? null : profile.skin.url,
profile.skin == null ? null : SecurityHelper.toHex(profile.skin.digest),
profile.cloak == null ? null : profile.cloak.url,
profile.cloak == null ? null : SecurityHelper.toHex(profile.cloak.digest)
);
}
2018-09-22 17:33:00 +03:00
2018-09-17 10:07:32 +03:00
// Instance
public final UUID uuid;
public final String uuidHash, username;
public final String skinURL, skinDigest;
public final String cloakURL, cloakDigest;
public CompatProfile(UUID uuid, String username, String skinURL, String skinDigest, String cloakURL, String cloakDigest) {
this.uuid = uuid;
uuidHash = Launcher.toHash(uuid);
this.username = username;
this.skinURL = skinURL;
this.skinDigest = skinDigest;
this.cloakURL = cloakURL;
this.cloakDigest = cloakDigest;
}
public int countProperties() {
int count = 0;
if (skinURL != null)
2018-09-22 17:33:00 +03:00
count++;
2018-09-17 10:07:32 +03:00
if (skinDigest != null)
2018-09-22 17:33:00 +03:00
count++;
2018-09-17 10:07:32 +03:00
if (cloakURL != null)
2018-09-22 17:33:00 +03:00
count++;
2018-09-17 10:07:32 +03:00
if (cloakDigest != null)
2018-09-22 17:33:00 +03:00
count++;
2018-09-17 10:07:32 +03:00
return count;
}
}