Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.5.0 #69

Merged
merged 9 commits into from
Apr 2, 2024
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>2.4.0</build.version>
<build.version>2.5.0</build.version>

<sonar.projectKey>BentoBoxWorld_Boxed</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down
85 changes: 33 additions & 52 deletions src/main/java/world/bentobox/boxed/Boxed.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ public class Boxed extends GameModeAddon {
private static final String SEED = "seed";
private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
private static final String BASE = "_base";

// Settings
private Settings settings;
private AbstractBoxedChunkGenerator chunkGenerator;
private AbstractBoxedChunkGenerator worldGen;
private BoxedSeedChunkGenerator seedGen;
private AbstractBoxedChunkGenerator netherGen;
private BoxedSeedChunkGenerator netherSeedGen;


private final Config<Settings> configObject = new Config<>(this, Settings.class);
private AdvancementsManager advManager;
private AbstractBoxedChunkGenerator netherChunkGenerator;
private World seedWorld;
private final Map<World, ChunkGenerator> generatorMap = new HashMap<>();
//private World seedWorldEnd;
private final Map<String, ChunkGenerator> generatorMaps = new HashMap<>();
private BiomeProvider boxedBiomeProvider;

@Override
Expand Down Expand Up @@ -101,8 +104,21 @@ private boolean loadSettings() {
return false;
}
// Initialize the Generator because createWorlds will be run after onLoad
this.chunkGenerator = new BoxedChunkGenerator(this);
this.netherChunkGenerator = new BoxedChunkGenerator(this);
this.worldGen = new BoxedChunkGenerator(this);
generatorMaps.put(settings.getWorldName(), worldGen);

seedGen = new BoxedSeedChunkGenerator(this, Environment.NORMAL,
new SeedBiomeGenerator(this));
generatorMaps.put(settings.getWorldName() + "/" + SEED, seedGen);

// Nether generators
this.netherGen = new BoxedChunkGenerator(this);
generatorMaps.put(settings.getWorldName() + NETHER, netherGen);

netherSeedGen = new BoxedSeedChunkGenerator(this, Environment.NETHER,
new NetherSeedBiomeGenerator(this));
generatorMaps.put(settings.getWorldName() + "/" + SEED + NETHER, netherSeedGen);

return true;
}

Expand Down Expand Up @@ -180,35 +196,18 @@ public void createWorlds() {
private void createNether(String worldName) {
// Create vanilla seed nether world
log("Creating Boxed Seed Nether world ...");
// This creates a vanilla base world with biomes
AbstractBoxedChunkGenerator seedBaseGen = new BoxedSeedChunkGenerator(this, Environment.NETHER);
World baseWorldNether = WorldCreator
.name(worldName + "/" + SEED + NETHER + BASE)
.generator(seedBaseGen)
.environment(Environment.NETHER)
.seed(getSettings().getSeed())
.createWorld();
baseWorldNether.setDifficulty(Difficulty.PEACEFUL);
baseWorldNether.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());
generatorMap.put(baseWorldNether, seedBaseGen);
getPlugin().getIWM().addWorld(baseWorldNether, this);
copyChunks(baseWorldNether, seedBaseGen);
// Create seed world
// This copies a base world with custom biomes
log("Creating Boxed Biomed Nether world ...");
BoxedSeedChunkGenerator seedWorldNetherGenerator = new BoxedSeedChunkGenerator(this, Environment.NETHER, new NetherSeedBiomeGenerator(this, seedBaseGen));
World seedWorldNether = WorldCreator
.name(worldName + "/" + SEED + NETHER)
.generator(seedWorldNetherGenerator)
.generator(netherSeedGen)
.environment(Environment.NETHER)
.seed(getSettings().getSeed())
.createWorld();
seedWorldNether.setDifficulty(Difficulty.EASY);

seedWorldNether.setSpawnLocation(settings.getNetherSeedX(), 64, settings.getNetherSeedZ());
generatorMap.put(seedWorldNether, seedWorldNetherGenerator);
generatorMap.put(seedWorldNether, netherSeedGen);
getPlugin().getIWM().addWorld(seedWorldNether, this);
copyChunks(seedWorldNether, netherChunkGenerator);
copyChunks(seedWorldNether, netherGen);

if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating Boxed's Nether...");
Expand All @@ -219,38 +218,19 @@ private void createNether(String worldName) {
private void createOverWorld(String worldName) {
// Create vanilla seed world
log("Creating Boxed Seed world ...");
// This creates a vanilla base world with biomes
AbstractBoxedChunkGenerator seedBaseGen = new BoxedSeedChunkGenerator(this, Environment.NORMAL);
World baseWorld = WorldCreator
.name(worldName + "/" + SEED + BASE)
.generator(seedBaseGen)
.environment(Environment.NORMAL)
.seed(getSettings().getSeed())
.createWorld();
baseWorld.setDifficulty(Difficulty.PEACEFUL);
baseWorld.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());
generatorMap.put(baseWorld, seedBaseGen);
getPlugin().getIWM().addWorld(baseWorld, this);
copyChunks(baseWorld, seedBaseGen);
// Create seed world
// This copies a base world with custom biomes
log("Creating Boxed Biomed world ...");
BoxedSeedChunkGenerator seedWorldGenerator = new BoxedSeedChunkGenerator(this, Environment.NORMAL, new SeedBiomeGenerator(this, seedBaseGen));
seedWorld = WorldCreator
.name(worldName + "/" + SEED)
.generator(seedWorldGenerator)
.generator(seedGen)
.environment(Environment.NORMAL)
.seed(getSettings().getSeed())
.createWorld();
seedWorld.setDifficulty(Difficulty.EASY);

seedWorld.setSpawnLocation(settings.getSeedX(), 64, settings.getSeedZ());

generatorMap.put(seedWorld, seedWorldGenerator);
generatorMap.put(seedWorld, seedGen);
getPlugin().getIWM().addWorld(seedWorld, this);
copyChunks(seedWorld, chunkGenerator);


copyChunks(seedWorld, worldGen);

if (getServer().getWorld(worldName) == null) {
log("Creating Boxed world ...");
Expand Down Expand Up @@ -308,7 +288,8 @@ private void copyChunks(World world, AbstractBoxedChunkGenerator gen) {
int p = (int) (count / percent * 100);
if (p % 10 == 0 && p != last) {
last = p;
this.log("Pregenrating seed chunks for " + world.getName() + "'s " + world.getEnvironment() + " " + p + "% done");
this.log("Pregenerating seed chunks for " + world.getName() + "'s " + world.getEnvironment() + " "
+ p + "% done");
}

}
Expand All @@ -321,7 +302,7 @@ private void copyChunks(World world, AbstractBoxedChunkGenerator gen) {
* @return the chunkGenerator for the environment
*/
public AbstractBoxedChunkGenerator getChunkGenerator(Environment env) {
return env.equals(Environment.NORMAL) ? chunkGenerator : netherChunkGenerator;
return env.equals(Environment.NORMAL) ? worldGen : netherGen;
}

/**
Expand Down Expand Up @@ -386,8 +367,8 @@ public WorldSettings getWorldSettings() {

@Override
public @Nullable ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
for (Entry<World, ChunkGenerator> en : generatorMap.entrySet()) {
if (en.getKey().getName().equalsIgnoreCase(worldName)) {
for (Entry<String, ChunkGenerator> en : generatorMaps.entrySet()) {
if (en.getKey().equalsIgnoreCase(worldName)) {
return en.getValue();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/boxed/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class Settings implements WorldSettings {
@ConfigEntry(path = "world.max-areas")
private int maxIslands = -1;

@ConfigComment("Area height - Lowest is 5.")
@ConfigComment("Area height")
@ConfigComment("It is the y coordinate of the bedrock block in the blueprint.")
@ConfigEntry(path = "world.area-height")
private int islandHeight = 8;
Expand Down
Loading
Loading