Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,26 @@
return configHandle.get(configNodes.enforceFlight);
}

@ApiStatus.AvailableSince("5.3")

Check warning on line 193 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java:193:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
public Try<Void> setApplyEntitySpawnRate(boolean applyEntitySpawnRate) {
return configHandle.set(configNodes.applyEntitySpawnRate, applyEntitySpawnRate);
}

@ApiStatus.AvailableSince("5.3")
public boolean getApplyEntitySpawnRate() {
return configHandle.get(configNodes.applyEntitySpawnRate);
}

@ApiStatus.AvailableSince("5.3")

Check warning on line 203 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfig.java:203:5: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
public Try<Void> setApplyEntitySpawnLimit(boolean applyEntitySpawnLimit) {
return configHandle.set(configNodes.applyEntitySpawnLimit, applyEntitySpawnLimit);
}

@ApiStatus.AvailableSince("5.3")
public boolean getApplyEntitySpawnLimit() {
return configHandle.get(configNodes.applyEntitySpawnLimit);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@
.name("enforce-flight")
.build());

final ConfigNode<Boolean> applyEntitySpawnRate = node(ConfigNode.builder("world.apply-entity-spawn-rate", Boolean.class)

Check warning on line 140 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Line is longer than 120 characters (found 124). Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java:140:0: warning: Line is longer than 120 characters (found 124). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
.comment("")
.comment("Sets whether Multiverse will apply the world's entity `tick-rate` config in worlds.yml.")
.comment("If disabled, the `tick-rate` config in worlds.yml will be ignored.")
.comment("Disable this if you want paper-world.yml or another plugin to handle entity spawn rate per world.")

Check warning on line 144 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Line is longer than 120 characters (found 121). Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java:144:0: warning: Line is longer than 120 characters (found 121). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
.defaultValue(true)
.name("apply-entity-spawn-rate")
.build());

final ConfigNode<Boolean> applyEntitySpawnLimit = node(ConfigNode.builder("world.apply-entity-spawn-limit", Boolean.class)

Check warning on line 149 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Line is longer than 120 characters (found 126). Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java:149:0: warning: Line is longer than 120 characters (found 126). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
.comment("")
.comment("Sets whether Multiverse will apply the world's entity `spawn-limit` config when a world is loaded.")

Check warning on line 151 in src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Line is longer than 120 characters (found 122). Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/config/CoreConfigNodes.java:151:0: warning: Line is longer than 120 characters (found 122). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
.comment("If disabled, the `spawn-limit` config in worlds.yml will be ignored.")
.comment("Disable this if you want paper-world.yml or another plugin to handle entity limits per world.")
.defaultValue(true)
.name("apply-entity-spawn-limit")
.build());

final ConfigNode<Boolean> autoPurgeEntities = node(ConfigNode.builder("world.auto-purge-entities", Boolean.class)
.comment("")
.comment("Sets whether Multiverse will purge entities on world load based world's entity spawn config.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.SpawnCategory;
import org.mvplugins.multiverse.core.MultiverseCoreApi;

Check warning on line 10 in src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 'org.mvplugins.multiverse.core.MultiverseCoreApi' should be separated from previous imports. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/world/entity/SpawnCategoryConfig.java:10:1: warning: 'org.mvplugins.multiverse.core.MultiverseCoreApi' should be separated from previous imports. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import org.mvplugins.multiverse.core.config.handle.MemoryConfigurationHandle;
import org.mvplugins.multiverse.core.config.handle.StringPropertyHandle;
import org.mvplugins.multiverse.core.config.node.ConfigNode;
Expand Down Expand Up @@ -57,21 +58,37 @@
return;
}
loadedWorld.getBukkitWorld().peek(bukkitWorld -> {
if (!isSpawn()) {
if (getExceptions().isEmpty()) {
Logging.finer("World %s %s setTicksPerSpawns: 0", world.getName(), spawnCategory);
bukkitWorld.setTicksPerSpawns(spawnCategory, 0);
} else {
Logging.finer("World %s %s setTicksPerSpawns: -1", world.getName(), spawnCategory);
bukkitWorld.setTicksPerSpawns(spawnCategory, -1);
}
applyTickPerSpawns(bukkitWorld);
applySpawnLimit(bukkitWorld);
});
}

private void applyTickPerSpawns(World bukkitWorld) {
if (!MultiverseCoreApi.get().getCoreConfig().getApplyEntitySpawnLimit()) {
Logging.finer("World %s %s skipping setTicksPerSpawns due to core config", world.getName(), spawnCategory);
return;
}
if (!isSpawn()) {
if (getExceptions().isEmpty()) {
Logging.finer("World %s %s setTicksPerSpawns: 0", world.getName(), spawnCategory);
bukkitWorld.setTicksPerSpawns(spawnCategory, 0);
} else {
Logging.finer("World %s %s setTicksPerSpawns: %d", world.getName(), spawnCategory, getTickRate());
bukkitWorld.setTicksPerSpawns(spawnCategory, getTickRate());
Logging.finer("World %s %s setTicksPerSpawns: -1", world.getName(), spawnCategory);
bukkitWorld.setTicksPerSpawns(spawnCategory, -1);
}
Logging.finer("World %s %s setSpawnLimit: %d", world.getName(), spawnCategory, getSpawnLimit());
bukkitWorld.setSpawnLimit(spawnCategory, getSpawnLimit());
});
} else {
Logging.finer("World %s %s setTicksPerSpawns: %d", world.getName(), spawnCategory, getTickRate());
bukkitWorld.setTicksPerSpawns(spawnCategory, getTickRate());
}
}

private void applySpawnLimit(World bukkitWorld) {
if (!MultiverseCoreApi.get().getCoreConfig().getApplyEntitySpawnLimit()) {
Logging.finer("Skipping World %s %s setSpawnLimit due to core config", world.getName(), spawnCategory);
return;
}
Logging.finer("World %s %s setSpawnLimit: %d", world.getName(), spawnCategory, getSpawnLimit());
bukkitWorld.setSpawnLimit(spawnCategory, getSpawnLimit());
}

public StringPropertyHandle getStringPropertyHandle() {
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/configs/fresh_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ world:
enforce-access: false
enforce-gamemode: true
enforce-flight: true
apply-entity-spawn-rate: true
apply-entity-spawn-limit: true
auto-purge-entities: false
world-name-format:
nether: '%overworld%_nether'
Expand Down
Loading