mirror of
https://github.com/unmojang/authlib-injector.git
synced 2025-10-02 15:51:31 -04:00
Remove org.to2mbn. prefix of options
This commit is contained in:
parent
25f3f069d7
commit
e4d23117ed
@ -30,6 +30,35 @@ public final class AuthlibInjector {
|
|||||||
"com.ibm.", "joptsimple.", "moe.yushi.authlibinjector.", "org.graalvm.", "org.GNOME.", "it.unimi.dsi.fastutil.",
|
"com.ibm.", "joptsimple.", "moe.yushi.authlibinjector.", "org.graalvm.", "org.GNOME.", "it.unimi.dsi.fastutil.",
|
||||||
"oshi." };
|
"oshi." };
|
||||||
|
|
||||||
|
// ==== System Properties ===
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the API root, should be set before {@link #bootstrap(Consumer)} is invoked.
|
||||||
|
*/
|
||||||
|
public static final String PROP_API_ROOT = "authlibinjector.yggdrasil";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores the prefetched API root response, should be set by the launcher.
|
||||||
|
*/
|
||||||
|
public static final String PROP_PREFETCHED_DATA = "authlibinjector.yggdrasil.prefetched";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see #PROP_PREFETCHED_DATA
|
||||||
|
*/
|
||||||
|
public static final String PROP_PREFETCHED_DATA_OLD = "org.to2mbn.authlibinjector.config.prefetched";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to disable the local httpd server.
|
||||||
|
*/
|
||||||
|
public static final String PROP_DISABLE_HTTPD = "authlibinjector.httpd.disable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to turn on debug logging.
|
||||||
|
*/
|
||||||
|
public static final String PROP_DEBUG = "authlibinjector.debug";
|
||||||
|
|
||||||
|
// ====
|
||||||
|
|
||||||
private AuthlibInjector() {}
|
private AuthlibInjector() {}
|
||||||
|
|
||||||
private static AtomicBoolean booted = new AtomicBoolean(false);
|
private static AtomicBoolean booted = new AtomicBoolean(false);
|
||||||
@ -50,15 +79,26 @@ public final class AuthlibInjector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Optional<String> getPrefetchedResponse() {
|
||||||
|
String prefetched = System.getProperty(PROP_PREFETCHED_DATA);
|
||||||
|
if (prefetched == null) {
|
||||||
|
prefetched = System.getProperty(PROP_PREFETCHED_DATA_OLD);
|
||||||
|
if (prefetched != null) {
|
||||||
|
info("warning: org.to2mbn.authlibinjector.config.prefetched option is deprecated and will be removed in a future release.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.ofNullable(prefetched);
|
||||||
|
}
|
||||||
|
|
||||||
private static Optional<YggdrasilConfiguration> configure() {
|
private static Optional<YggdrasilConfiguration> configure() {
|
||||||
String apiRoot = System.getProperty("org.to2mbn.authlibinjector.config");
|
String apiRoot = System.getProperty(PROP_API_ROOT);
|
||||||
if (apiRoot == null) return empty();
|
if (apiRoot == null) return empty();
|
||||||
info("api root: {0}", apiRoot);
|
info("api root: {0}", apiRoot);
|
||||||
|
|
||||||
String metadataResponse;
|
String metadataResponse;
|
||||||
|
|
||||||
String prefetched = System.getProperty("org.to2mbn.authlibinjector.config.prefetched");
|
Optional<String> prefetched = getPrefetchedResponse();
|
||||||
if (prefetched == null) {
|
if (!prefetched.isPresent()) {
|
||||||
info("fetching metadata");
|
info("fetching metadata");
|
||||||
try {
|
try {
|
||||||
metadataResponse = asString(getURL(apiRoot));
|
metadataResponse = asString(getURL(apiRoot));
|
||||||
@ -70,11 +110,11 @@ public final class AuthlibInjector {
|
|||||||
} else {
|
} else {
|
||||||
info("prefetched metadata detected");
|
info("prefetched metadata detected");
|
||||||
try {
|
try {
|
||||||
metadataResponse = new String(Base64.getDecoder().decode(removeNewLines(prefetched)), UTF_8);
|
metadataResponse = new String(Base64.getDecoder().decode(removeNewLines(prefetched.get())), UTF_8);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
info("unable to decode metadata: {0}\n"
|
info("unable to decode metadata: {0}\n"
|
||||||
+ "metadata to decode:\n"
|
+ "metadata to decode:\n"
|
||||||
+ "{1}", e, prefetched);
|
+ "{1}", e, prefetched.get());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +141,7 @@ public final class AuthlibInjector {
|
|||||||
for (String ignore : nonTransformablePackages)
|
for (String ignore : nonTransformablePackages)
|
||||||
transformer.ignores.add(ignore);
|
transformer.ignores.add(ignore);
|
||||||
|
|
||||||
if (!"true".equals(System.getProperty("org.to2mbn.authlibinjector.httpd.disable"))) {
|
if (!"true".equals(System.getProperty(PROP_DISABLE_HTTPD))) {
|
||||||
transformer.units.add(DeprecatedApiHandle.createTransformUnit(config));
|
transformer.units.add(DeprecatedApiHandle.createTransformUnit(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package moe.yushi.authlibinjector.javaagent;
|
package moe.yushi.authlibinjector.javaagent;
|
||||||
|
|
||||||
|
import static moe.yushi.authlibinjector.AuthlibInjector.PROP_API_ROOT;
|
||||||
import static moe.yushi.authlibinjector.AuthlibInjector.bootstrap;
|
import static moe.yushi.authlibinjector.AuthlibInjector.bootstrap;
|
||||||
import static moe.yushi.authlibinjector.AuthlibInjector.nonTransformablePackages;
|
import static moe.yushi.authlibinjector.AuthlibInjector.nonTransformablePackages;
|
||||||
import static moe.yushi.authlibinjector.util.LoggingUtils.debug;
|
import static moe.yushi.authlibinjector.util.LoggingUtils.debug;
|
||||||
@ -50,7 +51,7 @@ public class AuthlibInjectorPremain {
|
|||||||
|
|
||||||
private static void setupConfig(String arg) {
|
private static void setupConfig(String arg) {
|
||||||
if (arg != null && !arg.isEmpty()) {
|
if (arg != null && !arg.isEmpty()) {
|
||||||
System.setProperty("org.to2mbn.authlibinjector.config", arg);
|
System.setProperty(PROP_API_ROOT, arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package moe.yushi.authlibinjector.util;
|
package moe.yushi.authlibinjector.util;
|
||||||
|
|
||||||
|
import static moe.yushi.authlibinjector.AuthlibInjector.PROP_DEBUG;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
public final class LoggingUtils {
|
public final class LoggingUtils {
|
||||||
|
|
||||||
private static boolean debug = "true".equals(System.getProperty("org.to2mbn.authlibinjector.debug"));
|
private static boolean debug = "true".equals(System.getProperty(PROP_DEBUG));
|
||||||
|
|
||||||
public static void info(String message, Object... args) {
|
public static void info(String message, Object... args) {
|
||||||
System.err.println("[authlib-injector] " + MessageFormat.format(message, args));
|
System.err.println("[authlib-injector] " + MessageFormat.format(message, args));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user