diff --git a/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java b/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java new file mode 100644 index 0000000..30eb4ec --- /dev/null +++ b/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java @@ -0,0 +1,15 @@ +package com.mojang.authlib.exceptions; + +public class InsufficientPrivilegesException extends AuthenticationException { + + public InsufficientPrivilegesException() {} + public InsufficientPrivilegesException(String message) { + super(message); + } + public InsufficientPrivilegesException(String message, Throwable cause) { + super(message, cause); + } + public InsufficientPrivilegesException(Throwable cause) { + super(cause); + } +} diff --git a/Launcher/source-authlib/exceptions/UserMigratedException.java b/Launcher/source-authlib/exceptions/UserMigratedException.java new file mode 100644 index 0000000..018aa2b --- /dev/null +++ b/Launcher/source-authlib/exceptions/UserMigratedException.java @@ -0,0 +1,8 @@ +package com.mojang.authlib.exceptions; + +public class UserMigratedException extends InvalidCredentialsException { + public UserMigratedException() {} + public UserMigratedException(String message) {super(message);} + public UserMigratedException(String message, Throwable cause) { super(message, cause); } + public UserMigratedException(Throwable cause) { super(cause);} +} \ No newline at end of file diff --git a/Launcher/source-authlib/minecraft/MinecraftProfileTexture.java b/Launcher/source-authlib/minecraft/MinecraftProfileTexture.java index ced4a3b..b0daaef 100644 --- a/Launcher/source-authlib/minecraft/MinecraftProfileTexture.java +++ b/Launcher/source-authlib/minecraft/MinecraftProfileTexture.java @@ -4,67 +4,52 @@ import java.util.EnumSet; import java.util.Set; -public final class MinecraftProfileTexture -{ +public class MinecraftProfileTexture { public static final Set PROFILE_TEXTURE_TYPES = Collections.unmodifiableSet(EnumSet.allOf(Type.class)); public static final int PROFILE_TEXTURE_COUNT = PROFILE_TEXTURE_TYPES.size(); - // Instance private final String url; private final String hash; - public MinecraftProfileTexture(String url) - { + public MinecraftProfileTexture(String url) { this(url, baseName(url)); } - public MinecraftProfileTexture(String url, String hash) - { + public MinecraftProfileTexture(String url, String hash) { this.url = url; this.hash = hash; } - private static String baseName(String url) - { + private static String baseName(String url) { String name = url.substring(url.lastIndexOf('/') + 1); // Remove index int extensionIndex = name.lastIndexOf('.'); if (extensionIndex >= 0) - { name = name.substring(0, extensionIndex); - } // We're done return name; } - @Override - public String toString() - { - return String.format("MinecraftProfileTexture{url='%s',hash=%s}", url, hash); - } - - @SuppressWarnings("unused") - public String getHash() - { + public String getHash() { return hash; } - @SuppressWarnings({"unused", "SameReturnValue"}) - public String getMetadata(String key) - { + public String getMetadata(String key) { return null; } - @SuppressWarnings("unused") - public String getUrl() - { + public String getUrl() { return url; } - public enum Type - { + @Override + public String toString() { + return String.format("MinecraftProfileTexture{url='%s',hash=%s}", url, hash); + } + + public enum Type { SKIN, CAPE, ELYTRA diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java index 19c9922..11f7b84 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java @@ -1,9 +1,7 @@ package com.mojang.authlib.yggdrasil; -import com.mojang.authlib.Agent; -import com.mojang.authlib.AuthenticationService; -import com.mojang.authlib.GameProfileRepository; -import com.mojang.authlib.UserAuthentication; +import com.mojang.authlib.*; +import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.MinecraftSessionService; import launcher.helper.LogHelper; @@ -11,27 +9,42 @@ public class YggdrasilAuthenticationService implements AuthenticationService { - @SuppressWarnings("UnusedParameters") - public YggdrasilAuthenticationService(Proxy proxy, String clientToken) - { - LogHelper.debug("Patched AuthenticationService created: '%s'", clientToken); + private final Environment environment; + + public YggdrasilAuthenticationService(final Proxy proxy) { + this(proxy, determineEnvironment()); } - @Override - public MinecraftSessionService createMinecraftSessionService() - { - return new YggdrasilMinecraftSessionService(this); + public YggdrasilAuthenticationService(final Proxy proxy, final Environment environment) { + this(proxy, null, environment); } - @Override - public GameProfileRepository createProfileRepository() - { - return new YggdrasilGameProfileRepository(); + public YggdrasilAuthenticationService(final Proxy proxy, final String clientToken) { + this(proxy, clientToken, determineEnvironment()); } - @Override - public UserAuthentication createUserAuthentication(Agent agent) - { + public YggdrasilAuthenticationService(final Proxy proxy, final String clientToken, final Environment environment) { + this.environment = environment; + LogHelper.debug("Patched AuthenticationService created: '%s'", new Object[] { clientToken }); + } + + private static Environment determineEnvironment() { + return EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD); + } + + public UserAuthentication createUserAuthentication(final Agent agent) { throw new UnsupportedOperationException("createUserAuthentication is used only by Mojang Launcher"); } + + public MinecraftSessionService createMinecraftSessionService() { + return (MinecraftSessionService)new YggdrasilMinecraftSessionService((AuthenticationService)this, this.environment); + } + + public GameProfileRepository createProfileRepository() { + return (GameProfileRepository)new YggdrasilGameProfileRepository(this, this.environment); + } + + public YggdrasilSocialInteractionsService createSocialInteractionsService(final String accessToken) throws AuthenticationException { + return new YggdrasilSocialInteractionsService(this, accessToken, this.environment); + } } diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java b/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java index 01ccbe8..e12de9f 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -8,37 +8,27 @@ import launcher.helper.LogHelper; import launcher.helper.VerifyHelper; import launcher.request.uuid.BatchProfileByUsernameRequest; +import com.mojang.authlib.Environment; import java.util.Arrays; import java.util.UUID; -public class YggdrasilGameProfileRepository implements GameProfileRepository -{ +public class YggdrasilGameProfileRepository implements GameProfileRepository { private static final long BUSY_WAIT_MS = VerifyHelper.verifyLong( - Long.parseLong(System.getProperty("launcher.authlib.busyWait", Long.toString(100L))), - VerifyHelper.L_NOT_NEGATIVE, "launcher.authlib.busyWait can't be < 0"); + Long.parseLong(System.getProperty("launcher.com.mojang.authlib.busyWait", Long.toString(100L))), + VerifyHelper.L_NOT_NEGATIVE, "launcher.com.mojang.authlib.busyWait can't be < 0"); private static final long ERROR_BUSY_WAIT_MS = VerifyHelper.verifyLong( - Long.parseLong(System.getProperty("launcher.authlib.errorBusyWait", Long.toString(500L))), - VerifyHelper.L_NOT_NEGATIVE, "launcher.authlib.errorBusyWait can't be < 0"); + Long.parseLong(System.getProperty("launcher.com.mojang.authlib.errorBusyWait", Long.toString(500L))), + VerifyHelper.L_NOT_NEGATIVE, "launcher.com.mojang.authlib.errorBusyWait can't be < 0"); - public YggdrasilGameProfileRepository() - { + public YggdrasilGameProfileRepository(YggdrasilAuthenticationService service, Environment environment) { LogHelper.debug("Patched GameProfileRepository created"); } - public YggdrasilGameProfileRepository(YggdrasilAuthenticationService authenticationService) - { - this(); - } - - private static void busyWait(long ms) - { - try - { + private static void busyWait(long ms) { + try { Thread.sleep(ms); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { LogHelper.error(e); } } @@ -92,4 +82,4 @@ busyWait(BUSY_WAIT_MS); } } -} +} \ No newline at end of file diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java b/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java index c417b54..0bf68bc 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilMinecraftSessionService.java @@ -21,6 +21,7 @@ import launcher.request.auth.CheckServerRequest; import launcher.request.auth.JoinServerRequest; import launcher.request.uuid.ProfileByUUIDRequest; +import com.mojang.authlib.Environment; import java.net.InetAddress; import java.util.Base64; @@ -39,9 +40,9 @@ LogHelper.debug("Patched MinecraftSessionService created"); } - public YggdrasilMinecraftSessionService(YggdrasilAuthenticationService service) - { - this((AuthenticationService) service); + public YggdrasilMinecraftSessionService(AuthenticationService service, Environment environment) { + super(service); + LogHelper.debug("Patched MinecraftSessionService created"); } public static void fillTextureProperties(GameProfile profile, PlayerProfile pp) @@ -245,4 +246,4 @@ throw new AuthenticationException("Bad Login (Clientside)"); } } -} +} \ No newline at end of file diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java b/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java new file mode 100644 index 0000000..7388c06 --- /dev/null +++ b/Launcher/source-authlib/yggdrasil/YggdrasilSocialInteractionsService.java @@ -0,0 +1,28 @@ +package com.mojang.authlib.yggdrasil; + +import com.mojang.authlib.minecraft.*; +import com.mojang.authlib.*; +import com.mojang.authlib.exceptions.*; +import java.util.*; + +public class YggdrasilSocialInteractionsService implements SocialInteractionsService +{ + public YggdrasilSocialInteractionsService(final YggdrasilAuthenticationService authenticationService, final String accessToken, final Environment env) throws AuthenticationException { + } + + public boolean serversAllowed() { + return true; + } + + public boolean realmsAllowed() { + return false; + } + + public boolean chatAllowed() { + return true; + } + + public boolean isBlockedPlayer(final UUID uuid) { + return false; + } +} \ No newline at end of file diff --git a/compat/authlib/authlib-clean.jar b/compat/authlib/authlib-clean.jar index 0a934fe..75b527e 100644 --- a/compat/authlib/authlib-clean.jar +++ b/compat/authlib/authlib-clean.jar Binary files differ