From a554846e577dd756c24e56a54668e6e22552901f Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 2 Oct 2012 20:26:47 -0400 Subject: [PATCH] Add in some bukkit supporting code. Most of this is unimplemented until the bukkit coremod is complete. --- .../cpw/mods/fml/common/BukkitPluginRef.java | 29 +++++++++++++++++++ .../cpw/mods/fml/common/BukkitProxy.java | 12 ++++++++ fml/common/cpw/mods/fml/common/Mod.java | 7 +++++ .../src/cpw/mods/mockmod/MockMod.java | 2 +- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 fml/common/cpw/mods/fml/common/BukkitPluginRef.java create mode 100644 fml/common/cpw/mods/fml/common/BukkitProxy.java diff --git a/fml/common/cpw/mods/fml/common/BukkitPluginRef.java b/fml/common/cpw/mods/fml/common/BukkitPluginRef.java new file mode 100644 index 000000000..9f63db5c8 --- /dev/null +++ b/fml/common/cpw/mods/fml/common/BukkitPluginRef.java @@ -0,0 +1,29 @@ +package cpw.mods.fml.common; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Declare a variable to be populated by a Bukkit Plugin proxy instance if the bukkit coremod + * is available. It can only be applied to field typed as {@link BukkitProxy} + * Generally it should be used in conjunction with {@link Mod#bukkitPlugin()} specifying the + * plugin to load. + * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface BukkitPluginRef +{ + /** + * A reference (possibly version specific) to a Bukkit Plugin by name, using the name@versionbound + * specification. If this is a bukkit enabled environment the field annotated by this + * will be populated with a {@link BukkitProxy} instance if possible. This proxy will be gotten by + * reflectively calling the "getModProxy" method on the bukkit plugin instance. + * @return + */ + String value(); +} diff --git a/fml/common/cpw/mods/fml/common/BukkitProxy.java b/fml/common/cpw/mods/fml/common/BukkitProxy.java new file mode 100644 index 000000000..d0dcfb382 --- /dev/null +++ b/fml/common/cpw/mods/fml/common/BukkitProxy.java @@ -0,0 +1,12 @@ +package cpw.mods.fml.common; + +/** + * A marker interface for retrieving a proxy to a bukkit plugin. + * Fields associated with {@link BukkitPluginRef} annotations should be should probably + * declare this type and cast down if the target is available (not null) + * @author cpw + * + */ +public interface BukkitProxy +{ +} diff --git a/fml/common/cpw/mods/fml/common/Mod.java b/fml/common/cpw/mods/fml/common/Mod.java index 640c2d7b0..d2d086dd2 100644 --- a/fml/common/cpw/mods/fml/common/Mod.java +++ b/fml/common/cpw/mods/fml/common/Mod.java @@ -59,6 +59,13 @@ public @interface Mod * @return A version range as specified by the maven version range specification or the empty string */ String acceptedMinecraftVersions() default ""; + /** + * An optional bukkit plugin that will be injected into the bukkit plugin framework if + * this mod is loaded into the FML framework and the bukkit coremod is present. + * Instances of the bukkit plugin can be obtained via the {@link BukkitPluginRef} annotation on fields. + * @return + */ + String bukkitPlugin() default ""; /** * Mark the designated method as being called at the "pre-initialization" phase * @author cpw diff --git a/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java b/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java index d844d5ad9..3980506a1 100644 --- a/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java +++ b/fml/eclipse/FML-MockMod/src/cpw/mods/mockmod/MockMod.java @@ -22,7 +22,7 @@ import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.ModMetadata; -@Mod(modid="MockMod", name="Mock Mod",version="1.2.3", dependencies="after:FML@[3.1.29,)", useMetadata=true,acceptedMinecraftVersions="[1.4,),[12w27a,)") +@Mod(modid="MockMod", name="Mock Mod",version="1.2.3", dependencies="after:FML@[3.1.29,)", useMetadata=true,acceptedMinecraftVersions="[1.3,),[12w27a,)") @NetworkMod(channels={"MockMod"},clientSideRequired=true,packetHandler=MockMod.PacketHandler.class,clientPacketHandlerSpec= @SidedPacketHandler(packetHandler=TestClass.class,channels={"Fish"}),tinyPacketHandler=MockMod.PacketHandler.class) public class MockMod