From 2cd02e91a417f676d2dbc73c7c8436257e65bf8f Mon Sep 17 00:00:00 2001 From: Mumfrey Date: Fri, 17 Jun 2016 22:28:05 +0100 Subject: [PATCH] Make tweaker/manifest constants public for @Minecrell --- .../asm/launch/MixinLaunchAgentDefault.java | 15 ++++++--------- .../spongepowered/asm/launch/MixinTweaker.java | 4 ++-- .../org/spongepowered/asm/util/Constants.java | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/spongepowered/asm/launch/MixinLaunchAgentDefault.java b/src/main/java/org/spongepowered/asm/launch/MixinLaunchAgentDefault.java index 87da8172..b9949c6e 100644 --- a/src/main/java/org/spongepowered/asm/launch/MixinLaunchAgentDefault.java +++ b/src/main/java/org/spongepowered/asm/launch/MixinLaunchAgentDefault.java @@ -26,6 +26,8 @@ package org.spongepowered.asm.launch; import java.net.URI; +import org.spongepowered.asm.util.Constants.ManifestAttributes; + import net.minecraft.launchwrapper.LaunchClassLoader; /** @@ -33,11 +35,6 @@ import net.minecraft.launchwrapper.LaunchClassLoader; */ public class MixinLaunchAgentDefault extends MixinLaunchAgentAbstract { - protected static final String MFATT_MIXINCONFIGS = "MixinConfigs"; - protected static final String MFATT_TOKENPROVIDERS = "MixinTokenProviders"; - protected static final String MFATT_MAINCLASS = "Main-Class"; - protected static final String MFATT_COMPATIBILITY = "MixinCompatibilityLevel"; - public MixinLaunchAgentDefault(URI uri) { super(uri); } @@ -45,21 +42,21 @@ public class MixinLaunchAgentDefault extends MixinLaunchAgentAbstract { @SuppressWarnings("deprecation") @Override public void prepare() { - String compatibilityLevel = this.attributes.get(MixinLaunchAgentDefault.MFATT_COMPATIBILITY); + String compatibilityLevel = this.attributes.get(ManifestAttributes.COMPATIBILITY); if (compatibilityLevel != null) { MixinLaunchAgentAbstract.logger.warn("{} Setting mixin compatibility level via manifest is deprecated, " + "use 'compatibilityLevel' key in config instead", this.container); MixinTweaker.setCompatibilityLevel(compatibilityLevel); } - String mixinConfigs = this.attributes.get(MixinLaunchAgentDefault.MFATT_MIXINCONFIGS); + String mixinConfigs = this.attributes.get(ManifestAttributes.MIXINCONFIGS); if (mixinConfigs != null) { for (String config : mixinConfigs.split(",")) { MixinTweaker.addConfig(config.trim()); } } - String tokenProviders = this.attributes.get(MixinLaunchAgentDefault.MFATT_TOKENPROVIDERS); + String tokenProviders = this.attributes.get(ManifestAttributes.TOKENPROVIDERS); if (tokenProviders != null) { for (String provider : tokenProviders.split(",")) { MixinTweaker.addTokenProvider(provider.trim()); @@ -77,7 +74,7 @@ public class MixinLaunchAgentDefault extends MixinLaunchAgentAbstract { @Override public String getLaunchTarget() { - return this.attributes.get(MixinLaunchAgentDefault.MFATT_MAINCLASS); + return this.attributes.get(ManifestAttributes.MAINCLASS); } } diff --git a/src/main/java/org/spongepowered/asm/launch/MixinTweaker.java b/src/main/java/org/spongepowered/asm/launch/MixinTweaker.java index e4ba4d5a..621df793 100644 --- a/src/main/java/org/spongepowered/asm/launch/MixinTweaker.java +++ b/src/main/java/org/spongepowered/asm/launch/MixinTweaker.java @@ -38,6 +38,7 @@ import org.spongepowered.asm.mixin.MixinEnvironment; import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel; import org.spongepowered.asm.mixin.MixinEnvironment.Phase; import org.spongepowered.asm.mixin.Mixins; +import org.spongepowered.asm.util.Constants.ManifestAttributes; import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.Launch; @@ -50,7 +51,6 @@ import net.minecraft.launchwrapper.LaunchClassLoader; */ public class MixinTweaker implements ITweaker { - private static final String MFATT_TWEAKER = "TweakClass"; private static final String DEFAULT_MAIN_CLASS = "net.minecraft.client.main.Main"; /** @@ -174,7 +174,7 @@ public class MixinTweaker implements ITweaker { continue; } MainAttributes attributes = MainAttributes.of(uri); - String tweaker = attributes.get(MixinTweaker.MFATT_TWEAKER); + String tweaker = attributes.get(ManifestAttributes.TWEAKER); if (MixinTweaker.class.getName().equals(tweaker)) { MixinTweaker.logger.debug("{} contains a mixin tweaker, adding agents", uri); this.addContainer(uri); diff --git a/src/main/java/org/spongepowered/asm/util/Constants.java b/src/main/java/org/spongepowered/asm/util/Constants.java index 4f940293..e3cb559d 100644 --- a/src/main/java/org/spongepowered/asm/util/Constants.java +++ b/src/main/java/org/spongepowered/asm/util/Constants.java @@ -43,4 +43,20 @@ public abstract class Constants { public static final String CLASS = "Ljava/lang/Class;"; private Constants() {} + + /** + * Shared Jar Manifest Attributes + */ + public abstract static class ManifestAttributes { + + public static final String TWEAKER = "TweakClass"; + public static final String MAINCLASS = "Main-Class"; + public static final String MIXINCONFIGS = "MixinConfigs"; + public static final String TOKENPROVIDERS = "MixinTokenProviders"; + + @Deprecated + public static final String COMPATIBILITY = "MixinCompatibilityLevel"; + + private ManifestAttributes() {} + } }