diff --git a/.idea/artifacts/Launcher.xml b/.idea/artifacts/Launcher.xml index e5fae0e..4aa8fca 100644 --- a/.idea/artifacts/Launcher.xml +++ b/.idea/artifacts/Launcher.xml @@ -8,6 +8,7 @@ + \ No newline at end of file diff --git a/.idea/libraries/jsr305_3_0_2.xml b/.idea/libraries/jsr305_3_0_2.xml new file mode 100644 index 0000000..e4637c4 --- /dev/null +++ b/.idea/libraries/jsr305_3_0_2.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Launcher/Launcher.iml b/Launcher/Launcher.iml index e32da62..166a81d 100644 --- a/Launcher/Launcher.iml +++ b/Launcher/Launcher.iml @@ -38,5 +38,6 @@ + \ No newline at end of file diff --git a/Launcher/source-authlib/exceptions/AuthenticationException.java b/Launcher/source-authlib/exceptions/AuthenticationException.java new file mode 100644 index 0000000..59aa19a --- /dev/null +++ b/Launcher/source-authlib/exceptions/AuthenticationException.java @@ -0,0 +1,18 @@ +package com.mojang.authlib.exceptions; + +public class AuthenticationException extends Exception { + public AuthenticationException() { + } + + public AuthenticationException(final String message) { + super(message); + } + + public AuthenticationException(final String message, final Throwable cause) { + super(message, cause); + } + + public AuthenticationException(final Throwable cause) { + super(cause); + } +} diff --git a/Launcher/source-authlib/exceptions/AuthenticationUnavailableException.java b/Launcher/source-authlib/exceptions/AuthenticationUnavailableException.java new file mode 100644 index 0000000..a245faa --- /dev/null +++ b/Launcher/source-authlib/exceptions/AuthenticationUnavailableException.java @@ -0,0 +1,18 @@ +package com.mojang.authlib.exceptions; + +public class AuthenticationUnavailableException extends AuthenticationException { + public AuthenticationUnavailableException() { + } + + public AuthenticationUnavailableException(final String message) { + super(message); + } + + public AuthenticationUnavailableException(final String message, final Throwable cause) { + super(message, cause); + } + + public AuthenticationUnavailableException(final Throwable cause) { + super(cause); + } +} diff --git a/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java b/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java index 30eb4ec..9f80a17 100644 --- a/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java +++ b/Launcher/source-authlib/exceptions/InsufficientPrivilegesException.java @@ -1,15 +1,18 @@ package com.mojang.authlib.exceptions; public class InsufficientPrivilegesException extends AuthenticationException { + public InsufficientPrivilegesException() { + } - public InsufficientPrivilegesException() {} - public InsufficientPrivilegesException(String message) { + public InsufficientPrivilegesException(final String message) { super(message); } - public InsufficientPrivilegesException(String message, Throwable cause) { + + public InsufficientPrivilegesException(final String message, final Throwable cause) { super(message, cause); } - public InsufficientPrivilegesException(Throwable cause) { + + public InsufficientPrivilegesException(final Throwable cause) { super(cause); } } diff --git a/Launcher/source-authlib/exceptions/InvalidCredentialsException.java b/Launcher/source-authlib/exceptions/InvalidCredentialsException.java new file mode 100644 index 0000000..5430118 --- /dev/null +++ b/Launcher/source-authlib/exceptions/InvalidCredentialsException.java @@ -0,0 +1,18 @@ +package com.mojang.authlib.exceptions; + +public class InvalidCredentialsException extends AuthenticationException { + public InvalidCredentialsException() { + } + + public InvalidCredentialsException(final String message) { + super(message); + } + + public InvalidCredentialsException(final String message, final Throwable cause) { + super(message, cause); + } + + public InvalidCredentialsException(final Throwable cause) { + super(cause); + } +} diff --git a/Launcher/source-authlib/exceptions/MinecraftClientException.java b/Launcher/source-authlib/exceptions/MinecraftClientException.java new file mode 100644 index 0000000..db632e0 --- /dev/null +++ b/Launcher/source-authlib/exceptions/MinecraftClientException.java @@ -0,0 +1,30 @@ +package com.mojang.authlib.exceptions; + +public class MinecraftClientException extends RuntimeException { + + public enum ErrorType { + SERVICE_UNAVAILABLE, + HTTP_ERROR, + JSON_ERROR + } + + protected final ErrorType type; + + protected MinecraftClientException(final ErrorType type, final String message) { + super(message); + this.type = type; + } + + public MinecraftClientException(final ErrorType type, final String message, final Throwable cause) { + super(message, cause); + this.type = type; + } + + public ErrorType getType() { + return type; + } + + public AuthenticationException toAuthenticationException() { + return new AuthenticationException(this); + } +} diff --git a/Launcher/source-authlib/exceptions/UserMigratedException.java b/Launcher/source-authlib/exceptions/UserMigratedException.java index 018aa2b..6c5e869 100644 --- a/Launcher/source-authlib/exceptions/UserMigratedException.java +++ b/Launcher/source-authlib/exceptions/UserMigratedException.java @@ -1,8 +1,18 @@ 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 + public UserMigratedException() { + } + + public UserMigratedException(final String message) { + super(message); + } + + public UserMigratedException(final String message, final Throwable cause) { + super(message, cause); + } + + public UserMigratedException(final Throwable cause) { + super(cause); + } +} diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java index e297527..13459f9 100644 --- a/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java +++ b/Launcher/source-authlib/yggdrasil/YggdrasilAuthenticationService.java @@ -3,6 +3,7 @@ import com.mojang.authlib.*; import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.minecraft.UserApiService; import launcher.helper.LogHelper; import java.net.Proxy; @@ -10,6 +11,8 @@ public class YggdrasilAuthenticationService implements AuthenticationService { private final Environment environment; + private Proxy proxy; + public YggdrasilAuthenticationService(final Proxy proxy) { this(proxy, determineEnvironment()); } @@ -24,11 +27,12 @@ public YggdrasilAuthenticationService(final Proxy proxy, final String clientToken, final Environment environment) { this.environment = environment; - LogHelper.debug("Patched AuthenticationService created: '%s'", new Object[] { clientToken }); + this.proxy = proxy; + LogHelper.debug("Patched AuthenticationService created: '%s'", clientToken); } private static Environment determineEnvironment() { - return EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD); + return EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD.getEnvironment()); } public UserAuthentication createUserAuthentication(final Agent agent) { @@ -44,6 +48,10 @@ } public YggdrasilSocialInteractionsService createSocialInteractionsService(final String accessToken) throws AuthenticationException { - return new YggdrasilSocialInteractionsService(this, accessToken, this.environment); + return (YggdrasilSocialInteractionsService)new YggdrasilSocialInteractionsService(this, accessToken, this.environment); + } + + public UserApiService createUserApiService(final String accessToken) throws AuthenticationException { + return (UserApiService)new YggdrasilUserApiService(accessToken, proxy, environment); } } diff --git a/Launcher/source-authlib/yggdrasil/YggdrasilUserApiService.java b/Launcher/source-authlib/yggdrasil/YggdrasilUserApiService.java new file mode 100644 index 0000000..77dc7c0 --- /dev/null +++ b/Launcher/source-authlib/yggdrasil/YggdrasilUserApiService.java @@ -0,0 +1,83 @@ +package com.mojang.authlib.yggdrasil; + +import com.google.common.collect.ImmutableSet; +import com.mojang.authlib.Environment; +import com.mojang.authlib.HttpAuthenticationService; +import com.mojang.authlib.exceptions.AuthenticationException; +import com.mojang.authlib.minecraft.TelemetrySession; +import com.mojang.authlib.minecraft.UserApiService; +import com.mojang.authlib.minecraft.client.MinecraftClient; +import com.mojang.authlib.yggdrasil.response.BlockListResponse; +import com.mojang.authlib.yggdrasil.response.UserAttributesResponse; + +import javax.annotation.Nullable; +import java.net.Proxy; +import java.net.URL; +import java.time.Instant; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Executor; + +public class YggdrasilUserApiService implements UserApiService { + private static final long BLOCKLIST_REQUEST_COOLDOWN_SECONDS = 120; + private static final UUID ZERO_UUID = new UUID(0, 0); + +// private final URL routePrivileges; +// private final URL routeBlocklist; +// +// private final MinecraftClient minecraftClient; +// private final Environment environment; + private UserProperties properties = OFFLINE_PROPERTIES; + + @Nullable + private Instant nextAcceptableBlockRequest; + + @Nullable + private Set blockList; + + public YggdrasilUserApiService(final String accessToken, final Proxy proxy, final Environment env) throws AuthenticationException { + // Заглушка + } + + @Override + public UserProperties properties() { + return properties; + } + + @Override + public TelemetrySession newTelemetrySession(final Executor executor) { + return TelemetrySession.DISABLED; + } + + @Override + public boolean isBlockedPlayer(final UUID playerID) { + return false; + } + + @Override + public void refreshBlockList() {} + + @Nullable + private Set fetchBlockList() { + return null; + } + + private boolean canMakeBlockListRequest() { + return nextAcceptableBlockRequest == null || Instant.now().isAfter(nextAcceptableBlockRequest); + } + + @Nullable + private Set forceFetchBlockList() { + return null; + } + + private void fetchProperties() throws AuthenticationException { + // Заглушка + } + + private static void addFlagIfUserHasPrivilege(final boolean privilege, final UserFlag value, final ImmutableSet.Builder output) { + if (privilege) { + output.add(value); + } + } +} diff --git a/Launcher/source/client/ClientLauncher.java b/Launcher/source/client/ClientLauncher.java index c4f6929..345cdd1 100644 --- a/Launcher/source/client/ClientLauncher.java +++ b/Launcher/source/client/ClientLauncher.java @@ -119,6 +119,8 @@ args.add(jvmProperty("os.version", "10.0")); } + // A fucking shitty fix + args.add(jvmProperty(JVMHelper.JAVA_LIBRARY_PATH, params.clientDir.resolve(NATIVES_DIR).toString())); // Add classpath and main class Collections.addAll(args, profile.object.getJvmArgs()); @@ -325,9 +327,6 @@ private static void launch(ClientProfile profile, Params params) throws Throwable { - // Add natives path - JVMHelper.addNativePath(params.clientDir.resolve(NATIVES_DIR)); - // Add client args Collection args = new LinkedList<>(); if (Version.compare(profile.getVersion(), "1.6.0") >= 0) diff --git a/Launcher/source/helper/JVMHelper.java b/Launcher/source/helper/JVMHelper.java index b4cd461..8826cf0 100644 --- a/Launcher/source/helper/JVMHelper.java +++ b/Launcher/source/helper/JVMHelper.java @@ -4,7 +4,6 @@ import launcher.LauncherAPI; import sun.misc.Unsafe; -import java.io.File; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles.Lookup; @@ -13,7 +12,6 @@ import java.lang.management.RuntimeMXBean; import java.lang.reflect.Field; import java.net.URL; -import java.nio.file.Path; import java.security.cert.Certificate; import java.util.Arrays; import java.util.Locale; @@ -50,9 +48,7 @@ public static final ClassLoader LOADER = ClassLoader.getSystemClassLoader(); // Useful internal fields and constants - private static final String JAVA_LIBRARY_PATH = "java.library.path"; - private static final MethodHandle MH_SET_USR_PATHS; - private static final MethodHandle MH_SET_SYS_PATHS; + public static final String JAVA_LIBRARY_PATH = "java.library.path"; private static final Object UCP; private static final MethodHandle MH_UCP_ADDURL_METHOD; private static final MethodHandle MH_UCP_GETURLS_METHOD; @@ -73,8 +69,6 @@ // Get trusted lookup and other stuff Field implLookupField = Lookup.class.getDeclaredField("IMPL_LOOKUP"); LOOKUP = (Lookup) UNSAFE.getObject(UNSAFE.staticFieldBase(implLookupField), UNSAFE.staticFieldOffset(implLookupField)); - MH_SET_USR_PATHS = LOOKUP.findStaticSetter(ClassLoader.class, "usr_paths", String[].class); - MH_SET_SYS_PATHS = LOOKUP.findStaticSetter(ClassLoader.class, "sys_paths", String[].class); // Get UCP stuff1 Class ucpClass = firstClass("jdk.internal.loader.URLClassPath", "sun.misc.URLClassPath"); @@ -110,35 +104,6 @@ } @LauncherAPI - public static void addNativePath(Path path) - { - String stringPath = path.toString(); - - // Add to library path - String libraryPath = System.getProperty(JAVA_LIBRARY_PATH); - if (libraryPath == null || libraryPath.isEmpty()) - { - libraryPath = stringPath; - } - else - { - libraryPath += File.pathSeparatorChar + stringPath; - } - System.setProperty(JAVA_LIBRARY_PATH, libraryPath); - - // Reset usrPaths and sysPaths cache - try - { - MH_SET_USR_PATHS.invoke((Object) null); - MH_SET_SYS_PATHS.invoke((Object) null); - } - catch (Throwable exc) - { - throw new InternalError(exc); - } - } - - @LauncherAPI @SuppressWarnings("CallToSystemGC") public static void fullGC() { diff --git a/build/libraries/input/jsr305-3.0.2.jar b/build/libraries/input/jsr305-3.0.2.jar new file mode 100644 index 0000000..59222d9 --- /dev/null +++ b/build/libraries/input/jsr305-3.0.2.jar Binary files differ diff --git a/buildnumber b/buildnumber index da284d5..19b4d5e 100644 --- a/buildnumber +++ b/buildnumber @@ -1 +1 @@ -573, 14.11.2021 \ No newline at end of file +583, 08.01.2022 \ No newline at end of file diff --git a/compat/authlib/authlib-clean-old.jar b/compat/authlib/authlib-clean-old.jar new file mode 100644 index 0000000..75b527e --- /dev/null +++ b/compat/authlib/authlib-clean-old.jar Binary files differ diff --git a/compat/authlib/authlib-clean.jar b/compat/authlib/authlib-clean.jar index 75b527e..0b32f3f 100644 --- a/compat/authlib/authlib-clean.jar +++ b/compat/authlib/authlib-clean.jar Binary files differ