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
5 changes: 5 additions & 0 deletions src/main/java/world/bentobox/caveblock/CaveBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ public void onReload()
{
super.onReload();
this.loadSettings();
// Refresh the generators so reloaded settings (world depth, materials, etc.)
// apply to newly generated chunks without a server restart.
this.chunkNormalGenerator.reload();
this.chunkNetherGenerator.reload();
this.chunkEndGenerator.reload();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
// -------------------------------------------------------------------------

private final CaveBlock addon;
private final Settings settings;
private Settings settings;
private final World.Environment environment;
private final List<BlockPopulator> blockPopulators;

Expand All @@ -65,9 +65,13 @@ public ChunkGeneratorWorld(CaveBlock addon, World.Environment environment) {
// -------------------------------------------------------------------------

/**
* Called when config is reloaded. Rebuilds block populators.
* Called when config is reloaded. Re-reads the live settings (a reload replaces
* the {@link Settings} instance) and rebuilds block populators so that changes
* such as world depth, roof/floor and main blocks take effect on newly
* generated chunks without a full server restart.
*/
public void reload() {
this.settings = addon.getSettings();
this.blockPopulators.clear();
// Overworld uses vanilla decorations (shouldGenerateDecorations = true).
// Nether and End use NewMaterialPopulator for ore/block placement.
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/world/bentobox/caveblock/CaveBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ void testOnEnable() {
*/
@Test
void testOnReload() {
// onReload refreshes the generators, which are created in onLoad().
addon.onLoad();
addon.onReload();
File check = new File("addons/CaveBlock", "config.yml");
assertTrue(check.exists());
Expand Down
Loading