mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-17 23:55:00 +00:00
cleanup code
This commit is contained in:
51 files changed
+637
-373
No files matched your search
@@ -116,15 +116,20 @@ public class CoreLoadingPlugin implements IFMLLoadingPlugin {
|
||||
public static void validateGasStation() {
|
||||
Share.LOG.info("Got any gas?");
|
||||
//Make sure everything is loaded correctly, crash if gasstation is bugged
|
||||
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") || //Validate core class
|
||||
!isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") || //Validate the mixingasm compat
|
||||
!isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") || //Validate the spongemixins compat
|
||||
!isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") || //Validate the MBL compat
|
||||
(!isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") || isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")) //Validate correct mixins class
|
||||
// @formatter:off
|
||||
if (!isClassPresentSafe("com.falsepattern.gasstation.core.GasStationCore") //Validate core class
|
||||
|| !isClassPresentSafe("makamys.mixingasm.api.TransformerInclusions") //Validate the mixingasm compat
|
||||
|| !isClassPresentSafe("ru.timeconqueror.spongemixins.core.SpongeMixinsCore") //Validate the spongemixins compat
|
||||
|| !isClassPresentSafe("io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin") //Validate the MBL compat
|
||||
|| !isClassPresentSafe("org.spongepowered.asm.lib.Opcodes") //Validate correct mixins class
|
||||
|| isClassPresentSafe("org.spongepowered.libraries.org.objectweb.asm.Opcodes")
|
||||
) {
|
||||
Share.LOG.fatal("Somebody put diesel in my gas tank!");
|
||||
throw new Error("Failed to validate your GasStation mixin plugin installation. Please make sure you have the latest GasStation installed from the official source: https://github.com/FalsePattern/GasStation");
|
||||
throw new Error("Failed to validate your GasStation mixin plugin installation. "
|
||||
+ "Please make sure you have the latest GasStation installed from the official source: "
|
||||
+ "https://github.com/FalsePattern/GasStation");
|
||||
}
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-5
@@ -33,6 +33,7 @@ public class ConfigOrderTransformer implements IClassNodeTransformer {
|
||||
private static final String DESC_CONFIG = Type.getDescriptor(Config.class);
|
||||
private static final String DESC_CONFIG_IGNORE = Type.getDescriptor(Config.Ignore.class);
|
||||
private static final String DESC_ORDER = Type.getDescriptor(DeclOrderInternal.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ConfigOrderTransformer";
|
||||
@@ -54,11 +55,11 @@ public class ConfigOrderTransformer implements IClassNodeTransformer {
|
||||
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
int order = 0;
|
||||
outer:
|
||||
for (val field: cn.fields) {
|
||||
if ((field.access & Opcodes.ACC_PUBLIC) == 0 ||
|
||||
(field.access & Opcodes.ACC_STATIC) == 0 ||
|
||||
(field.access & Opcodes.ACC_FINAL) != 0) {
|
||||
continue;
|
||||
for (val field : cn.fields) {
|
||||
if ((field.access & Opcodes.ACC_PUBLIC) == 0
|
||||
|| (field.access & Opcodes.ACC_STATIC) == 0
|
||||
|| (field.access & Opcodes.ACC_FINAL) != 0) {
|
||||
continue;
|
||||
} else if (field.visibleAnnotations != null) {
|
||||
for (val ann : field.visibleAnnotations) {
|
||||
if (DESC_CONFIG_IGNORE.equals(ann.desc)) {
|
||||
|
||||
+8
-7
@@ -61,10 +61,11 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
|
||||
@Override
|
||||
public boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
return IMIXINPLUGIN.equals(transformedName) ||
|
||||
IMIXINCONFIGPLUGIN.equals(transformedName) ||
|
||||
cn.interfaces.stream().anyMatch((i) -> IMIXINPLUGIN_INTERNAL.equals(i) ||
|
||||
IMIXINCONFIGPLUGIN_INTERNAL.equals(i));
|
||||
return IMIXINPLUGIN.equals(transformedName)
|
||||
|| IMIXINCONFIGPLUGIN.equals(transformedName)
|
||||
|| cn.interfaces.stream()
|
||||
.anyMatch((i) -> IMIXINPLUGIN_INTERNAL.equals(i)
|
||||
|| IMIXINCONFIGPLUGIN_INTERNAL.equals(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +90,7 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
continue;
|
||||
}
|
||||
if (CLASSNODE_REAL != null) {
|
||||
for (val local: method.localVariables) {
|
||||
for (val local : method.localVariables) {
|
||||
if (local.desc.contains("ClassNode;")) {
|
||||
local.desc = local.desc.replaceAll("L[a-zA-Z/$]+[a-zA-Z$]+/ClassNode;", CLASSNODE_REAL);
|
||||
}
|
||||
@@ -119,10 +120,10 @@ public class IMixinPluginTransformer implements IClassNodeTransformer {
|
||||
}
|
||||
|
||||
private static String extractMethodWithReflection(String m) {
|
||||
for (val method: IMixinConfigPlugin.class.getDeclaredMethods()) {
|
||||
for (val method : IMixinConfigPlugin.class.getDeclaredMethods()) {
|
||||
if (method.getName().equals(m)) {
|
||||
StringBuilder b = new StringBuilder("(");
|
||||
for (val param: method.getParameterTypes()) {
|
||||
for (val param : method.getParameterTypes()) {
|
||||
if (param.getName().contains("ClassNode")) {
|
||||
CLASSNODE_REAL = "L" + param.getName().replace('.', '/') + ";";
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class ITypeDiscovererTransformer implements IClassNodeTransformer {
|
||||
|
||||
@Override
|
||||
public void transform(ClassNode cn, String transformedName, boolean obfuscated) {
|
||||
for (val method: cn.methods) {
|
||||
for (val method : cn.methods) {
|
||||
if (!method.name.equals("<clinit>")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user