mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Log error for invalid entity-per-chunk-save-limit configs (#6522)
This commit is contained in:
parent
e0125b21b7
commit
0294b31e13
@ -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<EntityType<?>, 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;
|
||||
|
Loading…
Reference in New Issue
Block a user