Mark Mods that do not contain a client entrypoint as Server-Only for Sync

This commit is contained in:
Frank 2021-11-06 20:59:06 +01:00
parent 2cbfbe8047
commit 07d8c56e18

View file

@ -143,6 +143,22 @@ public class ModUtil {
final String environment = env.getAsString().toLowerCase(Locale.ROOT);
if (environment.isEmpty() || environment.equals("*") || environment.equals("common")) {
JsonElement entrypoints = data.get("entrypoints");
boolean hasClient = true;
//check if there is an actual client entrypoint
if (entrypoints!=null && entrypoints.isJsonObject()){
JsonElement client = entrypoints.getAsJsonObject().get("client");
if (client!=null && client.isJsonArray()){
hasClient = client.getAsJsonArray().size() > 0;
} else if (client==null || !client.isJsonPrimitive()){
hasClient = false;
} else if (!client.getAsJsonPrimitive().isString()){
hasClient = false;
}
}
if (hasClient == false) return ModEnvironment.SERVER;
return ModEnvironment.UNIVERSAL;
} else if (environment.equals("client")) {
return ModEnvironment.CLIENT;