From 544320b8d239df4a5ee2b3a7ec331ce2ec0a2c09 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 20 Jan 2014 22:27:03 -0500 Subject: [PATCH] Beginning of a saveinspectionhandler. --- src/main/java/cpw/mods/fml/common/Mod.java | 11 +++++++++- .../fml/common/SaveInspectionHandler.java | 20 +++++++++++++++++++ .../common/network/NetworkCheckHandler.java | 20 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java diff --git a/src/main/java/cpw/mods/fml/common/Mod.java b/src/main/java/cpw/mods/fml/common/Mod.java index cab2511ade..1e25d03d92 100644 --- a/src/main/java/cpw/mods/fml/common/Mod.java +++ b/src/main/java/cpw/mods/fml/common/Mod.java @@ -103,9 +103,18 @@ public @interface Mod * * This is ignored if there is a {@link NetworkCheckHandler} annotation on a method in this class. * - * @return + * @return A version range as specified by the maven version range specification or the empty string */ String acceptableRemoteVersions() default ""; + + /** + * A version range specifying compatible save version information. If your mod follows good version numbering + * practice Like this (http://semver.org/) then this should be sufficient. + * + * Advanced users can specify a {@link SaveInspectionHandler} instead. + * @return A version range as specified by the maven version range specification or the empty string + */ + String acceptableSaveVersions() 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. diff --git a/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java b/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java new file mode 100644 index 0000000000..4c339e0b78 --- /dev/null +++ b/src/main/java/cpw/mods/fml/common/SaveInspectionHandler.java @@ -0,0 +1,20 @@ +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; + +/** + * A method annotated with this on the {@link Mod} will be called whenever a local save is listed in + * the save games list. + * + * @author cpw + * + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface SaveInspectionHandler +{ + +} diff --git a/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java b/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java index 4ea3629691..f0efa3fd5a 100644 --- a/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java +++ b/src/main/java/cpw/mods/fml/common/network/NetworkCheckHandler.java @@ -4,7 +4,27 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import cpw.mods.fml.relauncher.Side; +/** + * A method annotated with this will be called when a remote network connection is offered. + * The method should have two parameters, of types {@link Map} and {@link Side}. It should return a boolean + * true indicating that the remote party is acceptable, or false if not. + * + *

+ * When the method is invoked, the map will contain String keys and values listing all mods and their versions present. + * The side represents the side of the remote party. So if you're on the server, it'll be CLIENT, and vice versa. + * + *

+ * This method will be invoked both when querying the status of the remote server, and when connecting to the remote server. + * + *

+ * NOTE: the server will not be setup at any point when this method is called. Do not try and interact with the server + * or the client in any way, except to accept or reject the list of mods. + * + * @author cpw + * + */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface NetworkCheckHandler