-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added protection around no WorldGeneratorAPI plugin
- Loading branch information
1 parent
9c714e1
commit d33f932
Showing
3 changed files
with
72 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/world/bentobox/boxed/generators/BoxedChunkGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package world.bentobox.boxed.generators; | ||
|
||
import org.bukkit.generator.ChunkGenerator; | ||
|
||
import nl.rutgerkok.worldgeneratorapi.WorldGeneratorApi; | ||
import nl.rutgerkok.worldgeneratorapi.WorldRef; | ||
import nl.rutgerkok.worldgeneratorapi.decoration.DecorationType; | ||
import world.bentobox.boxed.Boxed; | ||
|
||
/** | ||
* @author tastybento | ||
* | ||
*/ | ||
public class BoxedChunkGenerator { | ||
|
||
private final WorldRef wordRef; | ||
private final Boxed addon; | ||
|
||
public BoxedChunkGenerator(Boxed addon) { | ||
this.addon = addon; | ||
wordRef = WorldRef.ofName(addon.getSettings().getWorldName()); | ||
} | ||
|
||
public ChunkGenerator getGenerator() { | ||
return WorldGeneratorApi | ||
.getInstance(addon.getPlugin(), 0, 5) | ||
.createCustomGenerator(wordRef, generator -> { | ||
// Set the noise generator | ||
generator.setBaseNoiseGenerator(new BasicWorldGenerator(addon, addon.getSettings().getSeed())); | ||
if (addon.getSettings().isAllowStructures()) { | ||
generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.SURFACE_STRUCTURES); | ||
} | ||
if (addon.getSettings().isAllowStrongholds()) { | ||
generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.STRONGHOLDS); | ||
} | ||
generator.setBiomeGenerator(new BoxedBiomeGenerator(addon)); | ||
}); | ||
} | ||
|
||
} |