aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/internal
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-05 23:39:09 +0900
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-07-05 23:39:09 +0900
commit54d915940ee0856bc7cac4a37687cb7783e07cee (patch)
treef5952503eb3bc095914f4f77b81531ab2c050d90 /src/main/java/cc/polyfrost/oneconfig/internal
parent6cafd268d486a930c7e8bec229c30eb6a50fe436 (diff)
parent206063acf3a6e0edc0d16b07d206aa36207b42d4 (diff)
downloadOneConfig-54d915940ee0856bc7cac4a37687cb7783e07cee.tar.gz
OneConfig-54d915940ee0856bc7cac4a37687cb7783e07cee.tar.bz2
OneConfig-54d915940ee0856bc7cac4a37687cb7783e07cee.zip
Merge branch 'self' of https://github.com/nxtdaydelivery/OneConfig into nextdaydelivery-self
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/internal')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java129
1 files changed, 0 insertions, 129 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
deleted file mode 100644
index 6999d60..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package cc.polyfrost.oneconfig.internal.plugin;
-
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-import org.spongepowered.asm.lib.tree.*;
-import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
-import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
-
-import java.io.File;
-import java.util.List;
-import java.util.Set;
-
-public class OneConfigMixinPlugin implements IMixinConfigPlugin {
- private static boolean isVigilance = false;
-
- @Override
- public void onLoad(String mixinPackage) {
- try {
- Class.forName("gg.essential.vigilance.Vigilant");
- isVigilance = true;
- } catch (Exception e) {
- isVigilance = false;
- }
- }
-
- @Override
- public String getRefMapperConfig() {
- return null;
- }
-
- @Override
- public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
- return !targetClassName.contains("vigilance") || isVigilance;
- }
-
- @Override
- public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
-
- }
-
- @Override
- public List<String> getMixins() {
- return null;
- }
-
- @Override
- public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
-
- }
-
- @Override
- public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
- if (mixinClassName.equals("cc.polyfrost.oneconfig.internal.mixin.VigilantMixin")) {
- transform(targetClass);
- }
- }
-
- /**
- * If anything here is changed, edit the corresponding method in OneConfigMixinPlugin!
- */
- private void transform(ClassNode node) {
- if (!node.interfaces.contains("cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilantAccessor")) {
- node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC, "oneconfig$config", "Lcc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig;", null, null));
- node.fields.add(new FieldNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, "oneconfig$file", Type.getDescriptor(File.class), null, null));
-
- node.interfaces.add("cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilantAccessor");
- MethodNode methodNode = new MethodNode(Opcodes.ACC_PUBLIC, "getPropertyCollector", "()Lgg/essential/vigilance/data/PropertyCollector;", null, null);
- LabelNode labelNode = new LabelNode();
- methodNode.instructions.add(labelNode);
- methodNode.instructions.add(new LineNumberNode(421421, labelNode));
- methodNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "propertyCollector", "Lgg/essential/vigilance/data/PropertyCollector;"));
- methodNode.instructions.add(new InsnNode(Opcodes.ARETURN));
- node.methods.add(methodNode);
-
- MethodNode methodNode2 = new MethodNode(Opcodes.ACC_PUBLIC, "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", null, null);
- LabelNode labelNode2 = new LabelNode();
- LabelNode labelNode3 = new LabelNode();
- LabelNode labelNode4 = new LabelNode();
- methodNode2.instructions.add(labelNode2);
- methodNode2.instructions.add(new LineNumberNode(15636436, labelNode2));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig;"));
-
- methodNode2.instructions.add(new JumpInsnNode(Opcodes.IFNULL, labelNode4));
-
- methodNode2.instructions.add(labelNode3);
- methodNode2.instructions.add(new LineNumberNode(15636437, labelNode3));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
- methodNode2.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig;"));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
- methodNode2.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
- methodNode2.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "cc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig", "addDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
-
- methodNode2.instructions.add(labelNode4);
- methodNode2.instructions.add(new LineNumberNode(15636438, labelNode4));
- methodNode2.instructions.add(new InsnNode(Opcodes.RETURN));
- node.methods.add(methodNode2);
-
- for (MethodNode method : node.methods) {
- if (method.name.equals("initialize")) {
- InsnList list = new InsnList();
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new FieldInsnNode(Opcodes.GETFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
- list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "cc/polyfrost/oneconfig/internal/plugin/hooks/VigilantHook", "returnNewConfig", "(Lgg/essential/vigilance/Vigilant;Ljava/io/File;)Lcc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig;", false));
- list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$config", "Lcc/polyfrost/oneconfig/internal/config/compatibility/vigilance/VigilanceConfig;"));
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
- } else if (method.name.equals("addDependency") && method.desc.equals("(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V")) {
- InsnList list = new InsnList();
-
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 1));
- list.add(new VarInsnNode(Opcodes.ALOAD, 2));
- list.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "gg/essential/vigilance/Vigilant", "handleOneConfigDependency", "(Lgg/essential/vigilance/data/PropertyData;Lgg/essential/vigilance/data/PropertyData;)V", false));
-
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
- } else if (method.name.equals("<init>") && method.desc.equals("(Ljava/io/File;Ljava/lang/String;Lgg/essential/vigilance/data/PropertyCollector;Lgg/essential/vigilance/data/SortingBehavior;)V")) {
- InsnList list = new InsnList();
- list.add(new VarInsnNode(Opcodes.ALOAD, 0));
- list.add(new VarInsnNode(Opcodes.ALOAD, 1));
- list.add(new FieldInsnNode(Opcodes.PUTFIELD, "gg/essential/vigilance/Vigilant", "oneconfig$file", Type.getDescriptor(File.class)));
- method.instructions.insertBefore(method.instructions.getLast().getPrevious(), list);
- }
- }
- }
- }
-}