Skip to content

Commit

Permalink
Fix Sonar issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal-Spider committed Aug 31, 2024
1 parent 1e71fda commit 41bc436
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,33 +154,14 @@ private static void registerFire(ResourceLocation fireType, Fire fire) {
}
}

@Override
protected void apply(Map<ResourceLocation, JsonElement> fires, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller profilerFiller) {
unregisterFires();
for (Map.Entry<ResourceLocation, JsonElement> fire : fires.entrySet()) {
String jsonIdentifier = fire.getKey().getPath();
try {
JsonObject jsonData = getJsonObject(jsonIdentifier, fire.getValue());
String mod = parse(jsonIdentifier, "mod", jsonData, JsonElement::getAsString);
if (Services.PLATFORM.isModLoaded(mod)) {
parse(jsonIdentifier, "fires", jsonData, JsonElement::getAsJsonArray).forEach(element -> registerFire(getJsonObject(jsonIdentifier, element), mod, jsonIdentifier));
} else {
Constants.LOGGER.warn("Registering of ddfires for [{}] is canceled: {} is not loaded.", mod, mod);
}
} catch (NullPointerException | UnsupportedOperationException | IllegalStateException | NumberFormatException e) {
Constants.LOGGER.error("Registering of ddfires for [{}] is canceled.", jsonIdentifier);
}
}
}

/**
* Builds and registers a DDFire.
*
* @param jsonFire JSON fire data.
* @param mod related mod.
* @param jsonIdentifier JSON ID.
*/
private void registerFire(JsonObject jsonFire, String mod, String jsonIdentifier) {
private static void registerFire(JsonObject jsonFire, String mod, String jsonIdentifier) {
ResourceLocation fireType = ResourceLocation.fromNamespaceAndPath(mod, parse(jsonIdentifier, "fire", jsonFire, JsonElement::getAsString));
Fire.Builder builder = FireManager.fireBuilder(fireType)
.setDamage(parse(fireType.toString(), "damage", jsonFire, JsonElement::getAsFloat, Fire.Builder.DEFAULT_DAMAGE))
Expand Down Expand Up @@ -210,4 +191,23 @@ private void registerFire(JsonObject jsonFire, String mod, String jsonIdentifier
}
registerFire(fireType, builder.build());
}

@Override
protected void apply(Map<ResourceLocation, JsonElement> fires, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller profilerFiller) {
unregisterFires();
for (Map.Entry<ResourceLocation, JsonElement> fire : fires.entrySet()) {
String jsonIdentifier = fire.getKey().getPath();
try {
JsonObject jsonData = getJsonObject(jsonIdentifier, fire.getValue());
String mod = parse(jsonIdentifier, "mod", jsonData, JsonElement::getAsString);
if (Services.PLATFORM.isModLoaded(mod)) {
parse(jsonIdentifier, "fires", jsonData, JsonElement::getAsJsonArray).forEach(element -> registerFire(getJsonObject(jsonIdentifier, element), mod, jsonIdentifier));
} else {
Constants.LOGGER.warn("Registering of ddfires for [{}] is canceled: {} is not loaded.", mod, mod);
}
} catch (NullPointerException | UnsupportedOperationException | IllegalStateException | NumberFormatException e) {
Constants.LOGGER.error("Registering of ddfires for [{}] is canceled.", jsonIdentifier);
}
}
}
}

0 comments on commit 41bc436

Please sign in to comment.