mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-17 02:55:02 +00:00
reformat code
This commit is contained in:
21 files changed
+731
-498
No files matched your search
@@ -1,14 +1,6 @@
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.internal.CoreLoadingPlugin;
|
||||
import lombok.val;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -18,16 +10,19 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.val;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
|
||||
import static java.nio.file.Files.walk;
|
||||
|
||||
public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
Path MODS_DIRECTORY_PATH = CoreLoadingPlugin.mcDir.toPath().resolve("mods");
|
||||
|
||||
Logger getLogger();
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
static Logger createLogger(String modName) {
|
||||
return LogManager.getLogger(modName + " Mixin Loader");
|
||||
}
|
||||
@@ -57,15 +52,13 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
val isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
val targetedMods = getTargetedModEnumValues();
|
||||
val loadedMods = Arrays.stream(targetedMods)
|
||||
.filter(mod -> (mod.isLoadInDevelopment() && isDevelopmentEnvironment)
|
||||
|| loadJarOf(mod))
|
||||
.filter(mod -> (mod.isLoadInDevelopment() && isDevelopmentEnvironment) || loadJarOf(mod))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (val mod : targetedMods) {
|
||||
if(loadedMods.contains(mod)) {
|
||||
if (loadedMods.contains(mod)) {
|
||||
getLogger().info("Found " + mod.getModName() + "! Integrating now...");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
getLogger().info("Could not find " + mod.getModName() + "! Skipping integration....");
|
||||
}
|
||||
}
|
||||
@@ -81,27 +74,19 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return mixins;
|
||||
}
|
||||
|
||||
@Override
|
||||
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
|
||||
default boolean loadJarOf(final ITargetedMod mod) {
|
||||
boolean success = false;
|
||||
try {
|
||||
File jar = findJarOf(mod);
|
||||
if(jar == null) {
|
||||
if (jar == null) {
|
||||
getLogger().info("Jar not found for " + mod);
|
||||
return false;
|
||||
}
|
||||
getLogger().info("Attempting to add " + jar + " to the URL Class Path");
|
||||
success = true;
|
||||
if(!jar.exists()) {
|
||||
if (!jar.exists()) {
|
||||
success = false;
|
||||
throw new FileNotFoundException(jar.toString());
|
||||
}
|
||||
@@ -112,17 +97,26 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return success;
|
||||
}
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
static File findJarOf(final ITargetedMod mod) {
|
||||
try {
|
||||
return walk(MODS_DIRECTORY_PATH)
|
||||
.filter(mod::isMatchingJar)
|
||||
.map(Path::toFile)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
return walk(MODS_DIRECTORY_PATH).filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user