diff --git a/patches/server/Entity-load-save-limit-per-chunk.patch b/patches/server/Entity-load-save-limit-per-chunk.patch index aa96eb541b..421ff84a9c 100644 --- a/patches/server/Entity-load-save-limit-per-chunk.patch +++ b/patches/server/Entity-load-save-limit-per-chunk.patch @@ -37,12 +37,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + getInt("entity-per-chunk-save-limit.arrow", -1); + getInt("entity-per-chunk-save-limit.fireball", -1); + getInt("entity-per-chunk-save-limit.small_fireball", -1); -+ EntityType.getEntityNameList().forEach(name -> { -+ final EntityType type = EntityType.byString(name.getPath()).orElseThrow(() -> new IllegalStateException("Unknown Entity Type: " + name.toString())); -+ final String path = ".entity-per-chunk-save-limit." + name.getPath(); -+ final int value = config.getInt("world-settings." + worldName + path, config.getInt("world-settings.default" + path, -1)); // get without setting defaults -+ if (value != -1) entityPerChunkSaveLimits.put(type, value); -+ }); ++ ++ addEntityPerChunkSaveLimitsFromSection(config.getConfigurationSection("world-settings.default.entity-per-chunk-save-limit"), entityPerChunkSaveLimits); ++ addEntityPerChunkSaveLimitsFromSection(config.getConfigurationSection("world-settings." + worldName + ".entity-per-chunk-save-limit"), entityPerChunkSaveLimits); ++ } ++ ++ private static void addEntityPerChunkSaveLimitsFromSection(final ConfigurationSection section, final Map, Integer> limitMap) { ++ if (section == null) { ++ return; ++ } ++ for (final String key : section.getKeys(false)) { ++ final int value = section.getInt(key); ++ final EntityType type = EntityType.byString(key).orElse(null); ++ if (type == null) { ++ logError("Invalid entity-per-chunk-save-limit config, '" + key+ "' is not a valid entity type. Correct this in paper.yml."); ++ continue; ++ } ++ if (value >= 0) { ++ limitMap.put(type, value); ++ } else { ++ limitMap.remove(type); ++ } ++ } + } + public short keepLoadedRange;