use of gg.moonflower.pollen.api.config.PollinatedModConfig in project pollen by MoonflowerTeam.
the class ConfigResourceCondition method test.
@Override
public boolean test(JsonObject json) throws JsonParseException {
ResourceLocation configId = new ResourceLocation(GsonHelper.getAsString(json, "config"));
Optional<PollinatedModConfig> optional = ConfigManager.get(configId.getNamespace(), byName(configId.getPath()));
if (!optional.isPresent() || optional.get().getConfigData() == null)
return false;
String configKey = GsonHelper.getAsString(json, "name");
if (!json.has("value"))
throw new JsonSyntaxException("Expected 'value'");
Object entry = optional.get().getConfigData().get(configKey);
if (entry == null)
throw new JsonSyntaxException("Unknown config key: " + configKey);
return testEntry(entry instanceof PollinatedConfigBuilder.ConfigValue<?> ? ((PollinatedConfigBuilder.ConfigValue<?>) entry).get() : entry, json, json.get("value"));
}
Aggregations