diff --git a/src/main/java/net/minecraftforge/fml/common/network/NetworkCheckHandler.java b/src/main/java/net/minecraftforge/fml/common/network/NetworkCheckHandler.java index a9b45e36b..e9e55b585 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/NetworkCheckHandler.java +++ b/src/main/java/net/minecraftforge/fml/common/network/NetworkCheckHandler.java @@ -28,8 +28,10 @@ /** * A method annotated with this will be called when a remote network connection is offered. - * The method should have two parameters, of types Map and {@link Side}. It should return a boolean - * true indicating that the remote party is acceptable, or false if not. + * The method should have two parameters, of types Map and {@link Side}. It should return + * a boolean true indicating that the remote party is acceptable, or false if not + * or a String null indicating that the remote party is acceptable, or notnull if not + * * *

* When the method is invoked, the map will contain String keys and values listing all mods and their versions present. @@ -38,6 +40,8 @@ *

* 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. diff --git a/src/main/java/net/minecraftforge/fml/common/network/internal/NetworkModHolder.java b/src/main/java/net/minecraftforge/fml/common/network/internal/NetworkModHolder.java index fb2bc2bc0..49b0b9ea0 100644 --- a/src/main/java/net/minecraftforge/fml/common/network/internal/NetworkModHolder.java +++ b/src/main/java/net/minecraftforge/fml/common/network/internal/NetworkModHolder.java @@ -46,7 +46,7 @@ public class NetworkModHolder /** * Validates that the mods versions on the client and server are compatible with mod. */ - public abstract class NetworkChecker { + public static abstract class NetworkChecker { /** * @deprecated use {@link #checkCompatible(Map, Side)} */ @@ -66,7 +66,7 @@ public String checkCompatible(Map remoteVersions, Side side) } } - private class IgnoredChecker extends NetworkChecker { + private static class IgnoredChecker extends NetworkChecker { @Override public boolean check(Map remoteVersions, Side side) { @@ -151,12 +151,14 @@ public String checkCompatible(Map remoteVersions, Side side) { try { - Boolean result = (Boolean) checkHandler.invoke(container.getMod(), remoteVersions, side); - if (result != null && result) - { - return null; + if (checkHandler.getReturnType() == String.class) { + return (String) checkHandler.invoke(container.getMod(), remoteVersions, side); + } else { + Boolean result = (Boolean) checkHandler.invoke(container.getMod(), remoteVersions, side); + if (result != null && result) { + return null; + } else return String.format("Failed mod's custom NetworkCheckHandler %s", container); } - return String.format("Failed mod's custom NetworkCheckHandler %s", container); } catch (Exception e) { @@ -171,6 +173,7 @@ public String toString() return String.format("Invoking method %s", checkHandler.getName()); } } + private static int assignedIds = 1; private int localId;