reformat all code

This commit is contained in:
dfsek
2022-07-06 19:28:07 -07:00
parent dc5e71e3de
commit b3a8f375bc
111 changed files with 706 additions and 653 deletions
@@ -4,40 +4,41 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
/**
* So you want to Mixin into Authlib/Brigadier/DataFixerUpper, on Fabric you'll need this guy.
*
* <p>YOU SHOULD ONLY USE THIS CLASS DURING "preLaunch" and ONLY TARGET A CLASS WHICH IS NOT ANY CLASS YOU MIXIN TO.
*
* <p>
* This will likely not work on Gson because FabricLoader has some special logic related to Gson.
*/
public final class AwfulQuiltHacks {
private AwfulQuiltHacks() {}
private static final ClassLoader KNOT_CLASSLOADER = Thread.currentThread().getContextClassLoader();
private static final Method ADD_URL_METHOD;
static {
Method tempAddUrlMethod = null;
try {
tempAddUrlMethod = KNOT_CLASSLOADER.getClass().getMethod("addURL", URL.class);
tempAddUrlMethod.setAccessible(true);
} catch(ReflectiveOperationException e) {
throw new RuntimeException("Failed to load Classloader fields", e);
}
private static final ClassLoader KNOT_CLASSLOADER = Thread.currentThread().getContextClassLoader();
private static final Method ADD_URL_METHOD;
ADD_URL_METHOD = tempAddUrlMethod;
}
static {
Method tempAddUrlMethod = null;
try {
tempAddUrlMethod = KNOT_CLASSLOADER.getClass().getMethod("addURL", URL.class);
tempAddUrlMethod.setAccessible(true);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to load Classloader fields", e);
}
private AwfulQuiltHacks() { }
ADD_URL_METHOD = tempAddUrlMethod;
}
/**
* Hackily load the package which a mixin may exist within.
*
* YOU SHOULD NOT TARGET A CLASS WHICH YOU MIXIN TO.
*
* @param pathOfAClass The path of any class within the package.
*/
public static void hackilyLoadForMixin(String pathOfAClass) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
URL url = Class.forName(pathOfAClass).getProtectionDomain().getCodeSource().getLocation();
ADD_URL_METHOD.invoke(KNOT_CLASSLOADER, url);
}
/**
* Hackily load the package which a mixin may exist within.
* <p>
* YOU SHOULD NOT TARGET A CLASS WHICH YOU MIXIN TO.
*
* @param pathOfAClass The path of any class within the package.
*/
public static void hackilyLoadForMixin(String pathOfAClass)
throws ClassNotFoundException, InvocationTargetException, IllegalAccessException {
URL url = Class.forName(pathOfAClass).getProtectionDomain().getCodeSource().getLocation();
ADD_URL_METHOD.invoke(KNOT_CLASSLOADER, url);
}
}
@@ -3,6 +3,7 @@ package com.dfsek.terra.quilt;
import com.dfsek.terra.mod.MinecraftAddon;
import com.dfsek.terra.mod.ModPlatform;
public class QuiltAddon extends MinecraftAddon {
public QuiltAddon(ModPlatform modPlatform) {
@@ -33,6 +33,7 @@ public class QuiltEntryPoint implements ModInitializer {
private static final Logger logger = LoggerFactory.getLogger(QuiltEntryPoint.class);
private static final QuiltPlatform TERRA_PLUGIN = new QuiltPlatform();
@Override
public void onInitialize(ModContainer container) {
logger.info("Initializing Terra Quilt mod...");
@@ -32,7 +32,6 @@ import java.util.stream.Stream;
import com.dfsek.terra.addon.EphemeralAddon;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.util.generic.Lazy;
import com.dfsek.terra.lifecycle.LifecyclePlatform;
@@ -41,7 +40,7 @@ public class QuiltPlatform extends LifecyclePlatform {
@Override
protected Collection<BaseAddon> getPlatformMods() {
return QuiltLoader.getAllMods().stream().flatMap(mod -> {
return QuiltLoader.getAllMods().stream().flatMap(mod -> {
String id = mod.metadata().id();
if(id.equals("terra") || id.equals("minecraft") || id.equals("java")) return Stream.empty();
try {
@@ -11,7 +11,7 @@ import java.lang.reflect.InvocationTargetException;
public class QuiltPreLaunchEntryPoint implements PreLaunchEntrypoint {
@Override
public void onPreLaunch(ModContainer mod) {
if (QuiltLoader.isDevelopmentEnvironment()) {
if(QuiltLoader.isDevelopmentEnvironment()) {
try {
AwfulQuiltHacks.hackilyLoadForMixin(BrigadierMappingBuilder.class.getName());
} catch(ClassNotFoundException | InvocationTargetException | IllegalAccessException e) {