From bb6f1318a8d8f4b11c0648304317f4bf02c0f85c Mon Sep 17 00:00:00 2001 From: Wyvest <45589059+Wyvest@users.noreply.github.com> Date: Sun, 19 Jun 2022 19:41:06 +0700 Subject: exclude internal package from sources jar as well remove debug stuff from mixin plugin use try with resources for mixin things --- .../internal/plugin/OneConfigMixinPlugin.java | 2 -- .../internal/plugin/OneConfigTweaker.java | 23 +++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src/main/java/cc/polyfrost/oneconfig') diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java index 888cca3..1e0d432 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java @@ -48,9 +48,7 @@ public class OneConfigMixinPlugin implements IMixinConfigPlugin { @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - System.out.println(mixinClassName); if (mixinClassName.equals("cc.polyfrost.oneconfig.internal.mixin.VigilantMixin")) { - System.out.println("A"); VigilantTransformer.transform(targetClass); } } diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigTweaker.java b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigTweaker.java index 0a709f6..5c57ca7 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigTweaker.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigTweaker.java @@ -22,17 +22,18 @@ import java.util.jar.JarFile; public class OneConfigTweaker implements ITweaker { public OneConfigTweaker() { - doMagicMixinStuff(); + for (URL url : Launch.classLoader.getSources()) { + doMagicMixinStuff(url); + } } - private void doMagicMixinStuff() { - for (URL url : Launch.classLoader.getSources()) { - try { - URI uri = url.toURI(); - if (Objects.equals(uri.getScheme(), "file")) { - File file = new File(uri); - if (file.exists() && file.isFile()) { - JarFile jarFile = new JarFile(file); + private void doMagicMixinStuff(URL url) { + try { + URI uri = url.toURI(); + if (Objects.equals(uri.getScheme(), "file")) { + File file = new File(uri); + if (file.exists() && file.isFile()) { + try (JarFile jarFile = new JarFile(file)) { if (jarFile.getManifest() != null) { Attributes attributes = jarFile.getManifest().getMainAttributes(); String tweakerClass = attributes.getValue("TweakClass"); @@ -62,9 +63,9 @@ public class OneConfigTweaker implements ITweaker { } } } - } catch (Exception ignored) { - } + } catch (Exception ignored) { + } } -- cgit