Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<String,String> 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<String,String> 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
*
*
* <p>
* When the method is invoked, the map will contain String keys and values listing all mods and their versions present.
Expand All @@ -38,6 +40,8 @@
* <p>
* This method will be invoked both when querying the status of the remote server, and when connecting to the remote server.
*
*
*
* <p>
* <strong>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.</strong>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
*/
Expand All @@ -66,7 +66,7 @@ public String checkCompatible(Map<String,String> remoteVersions, Side side)
}
}

private class IgnoredChecker extends NetworkChecker {
private static class IgnoredChecker extends NetworkChecker {
@Override
public boolean check(Map<String, String> remoteVersions, Side side)
{
Expand Down Expand Up @@ -151,12 +151,14 @@ public String checkCompatible(Map<String, String> 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)
{
Expand All @@ -171,6 +173,7 @@ public String toString()
return String.format("Invoking method %s", checkHandler.getName());
}
}

private static int assignedIds = 1;

private int localId;
Expand Down