diff --git a/Launcher/source-authlib/yggdrasil/CompatBridge.java b/Launcher/source-authlib/yggdrasil/CompatBridge.java index 86bb45a..ff264fe 100644 --- a/Launcher/source-authlib/yggdrasil/CompatBridge.java +++ b/Launcher/source-authlib/yggdrasil/CompatBridge.java @@ -14,26 +14,19 @@ // Used to bypass Launcher's class name obfuscation and access API @LauncherAPI -public final class CompatBridge -{ +public class CompatBridge { public static final int PROFILES_MAX_BATCH_SIZE = BatchProfileByUsernameRequest.MAX_BATCH_SIZE; - private CompatBridge() - { - } + private CompatBridge() { } @SuppressWarnings("unused") - public static CompatProfile checkServer(String username, String serverID) throws Throwable - { + public static CompatProfile checkServer(String username, String serverID) throws Throwable { LogHelper.debug("CompatBridge.checkServer, Username: '%s', Server ID: %s", username, serverID); - return CompatProfile.fromPlayerProfile(new CheckServerRequest(username, serverID).request()); - } + return CompatProfile.fromPlayerProfile(new CheckServerRequest(username, serverID).request()); } @SuppressWarnings("unused") - public static boolean joinServer(String username, String accessToken, String serverID) throws Throwable - { - if (!ClientLauncher.isLaunched()) - { + public static boolean joinServer(String username, String accessToken, String serverID) throws Throwable { + if (!ClientLauncher.isLaunched()) { throw new IllegalStateException("Bad Login (Cheater)"); } @@ -43,26 +36,22 @@ } @SuppressWarnings("unused") - public static CompatProfile profileByUUID(UUID uuid) throws Throwable - { + public static CompatProfile profileByUUID(UUID uuid) throws Throwable { return CompatProfile.fromPlayerProfile(new ProfileByUUIDRequest(uuid).request()); } @SuppressWarnings("unused") - public static CompatProfile profileByUsername(String username) throws Throwable - { + public static CompatProfile profileByUsername(String username) throws Throwable { return CompatProfile.fromPlayerProfile(new ProfileByUsernameRequest(username).request()); } @SuppressWarnings("unused") - public static CompatProfile[] profilesByUsername(String... usernames) throws Throwable - { + public static CompatProfile[] profilesByUsername(String... usernames) throws Throwable { PlayerProfile[] profiles = new BatchProfileByUsernameRequest(usernames).request(); // Convert profiles CompatProfile[] resultProfiles = new CompatProfile[profiles.length]; - for (int i = 0; i < profiles.length; i++) - { + for (int i = 0; i < profiles.length; i++) { resultProfiles[i] = CompatProfile.fromPlayerProfile(profiles[i]); } diff --git a/Launcher/source-authlib/yggdrasil/CompatProfile.java b/Launcher/source-authlib/yggdrasil/CompatProfile.java index d27cfdb..a5d6b98 100644 --- a/Launcher/source-authlib/yggdrasil/CompatProfile.java +++ b/Launcher/source-authlib/yggdrasil/CompatProfile.java @@ -8,8 +8,7 @@ import java.util.UUID; @LauncherAPI -public final class CompatProfile -{ +public class CompatProfile { public static final String SKIN_URL_PROPERTY = ClientLauncher.SKIN_URL_PROPERTY; public static final String SKIN_DIGEST_PROPERTY = ClientLauncher.SKIN_DIGEST_PROPERTY; public static final String CLOAK_URL_PROPERTY = ClientLauncher.CLOAK_URL_PROPERTY; @@ -21,8 +20,7 @@ public final String skinURL, skinDigest; public final String cloakURL, cloakDigest; - public CompatProfile(UUID uuid, String username, String skinURL, String skinDigest, String cloakURL, String cloakDigest) - { + public CompatProfile(UUID uuid, String username, String skinURL, String skinDigest, String cloakURL, String cloakDigest) { this.uuid = uuid; uuidHash = ClientLauncher.toHash(uuid); this.username = username; @@ -32,8 +30,7 @@ this.cloakDigest = cloakDigest; } - public static CompatProfile fromPlayerProfile(PlayerProfile profile) - { + 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), @@ -42,23 +39,18 @@ ); } - public int countProperties() - { + public int countProperties() { int count = 0; - if (skinURL != null) - { + if (skinURL != null) { count++; } - if (skinDigest != null) - { + if (skinDigest != null) { count++; } - if (cloakURL != null) - { + if (cloakURL != null) { count++; } - if (cloakDigest != null) - { + if (cloakDigest != null) { count++; } return count; diff --git a/Launcher/source-authlib/yggdrasil/LegacyBridge.java b/Launcher/source-authlib/yggdrasil/LegacyBridge.java index 9ad9944..2c01fb3 100644 --- a/Launcher/source-authlib/yggdrasil/LegacyBridge.java +++ b/Launcher/source-authlib/yggdrasil/LegacyBridge.java @@ -10,51 +10,41 @@ // Used by 1.6.4 and below versions @LauncherAPI -public final class LegacyBridge -{ - private LegacyBridge() - { - } +public class LegacyBridge { + private LegacyBridge() { } @SuppressWarnings("unused") - public static boolean checkServer(String username, String serverID) throws Throwable - { + public static boolean checkServer(String username, String serverID) throws Throwable { LogHelper.debug("LegacyBridge.checkServer, Username: '%s', Server ID: %s", username, serverID); return new CheckServerRequest(username, serverID).request() != null; } @SuppressWarnings("unused") - public static String getCloakURL(String username) - { + public static String getCloakURL(String username) { LogHelper.debug("LegacyBridge.getCloakURL: '%s'", username); return CommonHelper.replace(System.getProperty("launcher.legacy.cloaksURL", "http://skins.minecraft.net/MinecraftCloaks/%username%.png"), "username", IOHelper.urlEncode(username)); } @SuppressWarnings("unused") - public static String getSkinURL(String username) - { + public static String getSkinURL(String username) { LogHelper.debug("LegacyBridge.getSkinURL: '%s'", username); return CommonHelper.replace(System.getProperty("launcher.legacy.skinsURL", "http://skins.minecraft.net/MinecraftSkins/%username%.png"), "username", IOHelper.urlEncode(username)); } @SuppressWarnings("unused") - public static String joinServer(String username, String accessToken, String serverID) - { - if (!ClientLauncher.isLaunched()) - { + public static String joinServer(String username, String accessToken, String serverID) { + if (!ClientLauncher.isLaunched()) { return "Bad Login (Cheater)"; } // Join server LogHelper.debug("LegacyBridge.joinServer, Username: '%s', Access token: %s, Server ID: %s", username, accessToken, serverID); - try - { + try { return new JoinServerRequest(username, accessToken, serverID).request() ? "OK" : "Bad Login (Clientside)"; } - catch (Throwable exc) - { + catch (Throwable exc) { return exc.toString(); } } diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java index 11f7b84..e297527 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java @@ -7,8 +7,7 @@ import java.net.Proxy; -public class YggdrasilAuthenticationService implements AuthenticationService -{ +public class YggdrasilAuthenticationService implements AuthenticationService { private final Environment environment; public YggdrasilAuthenticationService(final Proxy proxy) { diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java b/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java index e12de9f..f890d80 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -34,24 +34,19 @@ } @Override - public void findProfilesByNames(String[] usernames, Agent agent, ProfileLookupCallback callback) - { + public void findProfilesByNames(String[] usernames, Agent agent, ProfileLookupCallback callback) { int offset = 0; - while (offset < usernames.length) - { + while (offset < usernames.length) { String[] sliceUsernames = Arrays.copyOfRange(usernames, offset, Math.min(offset + BatchProfileByUsernameRequest.MAX_BATCH_SIZE, usernames.length)); offset += BatchProfileByUsernameRequest.MAX_BATCH_SIZE; // Batch Username-To-UUID request PlayerProfile[] sliceProfiles; - try - { + try { sliceProfiles = new BatchProfileByUsernameRequest(sliceUsernames).request(); } - catch (Throwable exc) - { - for (String username : sliceUsernames) - { + catch (Throwable exc) { + for (String username : sliceUsernames) { LogHelper.debug("Couldn't find profile '%s': %s", username, exc); callback.onProfileLookupFailed(new GameProfile((UUID) null, username), exc instanceof Exception ? (Exception) exc : new Exception(exc)); } @@ -62,11 +57,9 @@ } // Request succeeded! - for (int i = 0; i < sliceProfiles.length; i++) - { + for (int i = 0; i < sliceProfiles.length; i++) { PlayerProfile pp = sliceProfiles[i]; - if (pp == null) - { + if (pp == null) { String username = sliceUsernames[i]; LogHelper.debug("Couldn't find profile '%s'", username); callback.onProfileLookupFailed(new GameProfile((UUID) null, username), new ProfileNotFoundException("Server did not find the requested profile")); diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java b/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java index 0bf68bc..bc6c40b 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java @@ -29,13 +29,21 @@ import java.util.Map; import java.util.UUID; -public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService -{ +public class YggdrasilMinecraftSessionService extends BaseMinecraftSessionService { public static final JsonParser JSON_PARSER = new JsonParser(); public static final boolean NO_TEXTURES = Boolean.parseBoolean("launcher.authlib.noTextures"); - public YggdrasilMinecraftSessionService(AuthenticationService service) - { + public YggdrasilMinecraftSessionService(AuthenticationService service) { + super(service); + LogHelper.debug("Patched MinecraftSessionService created"); + } + + public YggdrasilMinecraftSessionService(YggdrasilAuthenticationService service) { + super(service); + LogHelper.debug("Patched MinecraftSessionService created"); + } + + public YggdrasilMinecraftSessionService(YggdrasilAuthenticationService service, Environment environment) { super(service); LogHelper.debug("Patched MinecraftSessionService created"); } @@ -45,8 +53,7 @@ LogHelper.debug("Patched MinecraftSessionService created"); } - public static void fillTextureProperties(GameProfile profile, PlayerProfile pp) - { + public static void fillTextureProperties(GameProfile profile, PlayerProfile pp) { LogHelper.debug("fillTextureProperties, Username: '%s'", profile.getName()); if (NO_TEXTURES) { @@ -69,15 +76,13 @@ } } - public static GameProfile toGameProfile(PlayerProfile pp) - { + public static GameProfile toGameProfile(PlayerProfile pp) { GameProfile profile = new GameProfile(pp.uuid, pp.username); fillTextureProperties(profile, pp); return profile; } - private static void getTexturesMojang(Map textures, String texturesBase64, GameProfile profile) - { + private static void getTexturesMojang(Map textures, String texturesBase64, GameProfile profile) { // Decode textures payload JsonObject texturesJSON; try @@ -114,31 +119,26 @@ } @Override - public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) - { + public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) { // Verify has UUID UUID uuid = profile.getUUID(); LogHelper.debug("fillProfileProperties, UUID: %s", uuid); - if (uuid == null) - { + if (uuid == null) { return profile; } // Make profile request PlayerProfile pp; - try - { + try { pp = new ProfileByUUIDRequest(uuid).request(); } - catch (Throwable exc) - { + catch (Throwable exc) { LogHelper.debug("Couldn't fetch profile properties for '%s': %s", profile, exc); return profile; } // Verify is found - if (pp == null) - { + if (pp == null) { LogHelper.debug("Couldn't fetch profile properties for '%s' as the profile does not exist", profile); return profile; } @@ -150,36 +150,30 @@ } @Override - public Map getTextures(GameProfile profile, boolean requireSecure) - { + public Map getTextures(GameProfile profile, boolean requireSecure) { LogHelper.debug("getTextures, Username: '%s', UUID: '%s'", profile.getName(), profile.getUUID()); Map textures = new EnumMap<>(Type.class); // Add textures - if (!NO_TEXTURES) - { + if (!NO_TEXTURES) { // Add skin URL to textures map Property skinURL = Iterables.getFirst(profile.getProperties().get(ClientLauncher.SKIN_URL_PROPERTY), null); Property skinDigest = Iterables.getFirst(profile.getProperties().get(ClientLauncher.SKIN_DIGEST_PROPERTY), null); - if (skinURL != null && skinDigest != null) - { + if (skinURL != null && skinDigest != null) { textures.put(Type.SKIN, new MinecraftProfileTexture(skinURL.getValue(), skinDigest.getValue())); } // Add cloak URL to textures map Property cloakURL = Iterables.getFirst(profile.getProperties().get(ClientLauncher.CLOAK_URL_PROPERTY), null); Property cloakDigest = Iterables.getFirst(profile.getProperties().get(ClientLauncher.CLOAK_DIGEST_PROPERTY), null); - if (cloakURL != null && cloakDigest != null) - { + if (cloakURL != null && cloakDigest != null) { textures.put(Type.CAPE, new MinecraftProfileTexture(cloakURL.getValue(), cloakDigest.getValue())); } // Try to find missing textures in textures payload (now always true because launcher is not passing elytra skins) - if (textures.size() != MinecraftProfileTexture.PROFILE_TEXTURE_COUNT) - { + if (textures.size() != MinecraftProfileTexture.PROFILE_TEXTURE_COUNT) { Property texturesMojang = Iterables.getFirst(profile.getProperties().get("textures"), null); - if (texturesMojang != null) - { + if (texturesMojang != null) { getTexturesMojang(textures, texturesMojang.getValue(), profile); } } @@ -190,19 +184,16 @@ } @Override - public GameProfile hasJoinedServer(GameProfile profile, String serverID) throws AuthenticationUnavailableException - { + public GameProfile hasJoinedServer(GameProfile profile, String serverID) throws AuthenticationUnavailableException { String username = profile.getName(); LogHelper.debug("checkServer, Username: '%s', Server ID: %s", username, serverID); // Make checkServer request PlayerProfile pp; - try - { + try { pp = new CheckServerRequest(username, serverID).request(); } - catch (Throwable exc) - { + catch (Throwable exc) { LogHelper.error(exc); throw new AuthenticationUnavailableException(exc); } @@ -212,16 +203,13 @@ } @Override - public GameProfile hasJoinedServer(GameProfile profile, String serverID, InetAddress address) throws AuthenticationUnavailableException - { + public GameProfile hasJoinedServer(GameProfile profile, String serverID, InetAddress address) throws AuthenticationUnavailableException { return hasJoinedServer(profile, serverID); } @Override - public void joinServer(GameProfile profile, String accessToken, String serverID) throws AuthenticationException - { - if (!ClientLauncher.isLaunched()) - { + public void joinServer(GameProfile profile, String accessToken, String serverID) throws AuthenticationException { + if (!ClientLauncher.isLaunched()) { throw new AuthenticationException("Bad Login (Cheater)"); } @@ -231,18 +219,15 @@ // Make joinServer request boolean success; - try - { + try { success = new JoinServerRequest(username, accessToken, serverID).request(); } - catch (Throwable exc) - { + catch (Throwable exc) { throw new AuthenticationUnavailableException(exc); } // Verify is success - if (!success) - { + if (!success) { throw new AuthenticationException("Bad Login (Clientside)"); } } diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java b/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java index 7388c06..f0f6833 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java @@ -5,8 +5,7 @@ import com.mojang.authlib.exceptions.*; import java.util.*; -public class YggdrasilSocialInteractionsService implements SocialInteractionsService -{ +public class YggdrasilSocialInteractionsService implements SocialInteractionsService { public YggdrasilSocialInteractionsService(final YggdrasilAuthenticationService authenticationService, final String accessToken, final Environment env) throws AuthenticationException { }