Skip to content

Commit

Permalink
null generator check
Browse files Browse the repository at this point in the history
fixed wrong name for flat generation in the biome provider
  • Loading branch information
sh0inx committed Jan 2, 2025
1 parent d5eec9a commit 62cb9da
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions src/main/java/com/iridium/iridiumskyblock/IridiumSkyblock.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.nio.file.StandardCopyOption;
import java.sql.SQLException;
import java.util.*;
import java.util.stream.Collectors;

@Getter
public class IridiumSkyblock extends IridiumTeams<Island, User> {
Expand Down Expand Up @@ -114,13 +115,7 @@ public void onEnable() {
if(IridiumSkyblock.getInstance().getConfiguration().generatorType.equalsIgnoreCase("vanilla")) {
this.chunkGenerator = null;
} else {
for (IridiumChunkGenerator generator : IridiumSkyblock.getInstance().getIridiumChunkGenerators()) {
if (!IridiumSkyblock.getInstance().getConfiguration().generatorType.equalsIgnoreCase(generator.getName())) {
continue;
}

this.chunkGenerator = generator;
}
this.chunkGenerator = validateGenerator(IridiumSkyblock.getInstance().getConfiguration().generatorType);
}

this.teamManager.createWorld(World.Environment.NORMAL, configuration.worldName);
Expand Down Expand Up @@ -428,15 +423,32 @@ private void setBlockPopulators() {
}

private void registerGenerators() {
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new VoidGenerator("skyblock", false, true));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new OceanGenerator("ocean", true, false));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new OceanGeneratorLegacy("ocean-legacy", true, false));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new FlatGenerator("superflat", true, true));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new FlatGeneratorLegacy("superflat-legacy", true, true));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new VoidGenerator("skyblock", false, true));
IridiumSkyblock.getInstance().getIridiumChunkGenerators().add(new VoidGenerator("skyblock", false, true));
// Vanilla chunkGenerator = null
}

private IridiumChunkGenerator validateGenerator(String name) {

List<String> generatorNames = IridiumSkyblock.getInstance().getIridiumChunkGenerators().stream().map(IridiumChunkGenerator::getName).collect(Collectors.toList());
if(generatorNames.stream().noneMatch(generatorName -> generatorName.equalsIgnoreCase(name))) {
IridiumSkyblock.getInstance().getLogger().warning("Generator type \""
+ IridiumSkyblock.getInstance().getConfiguration().generatorType
+ "\" is not a valid type.");
IridiumSkyblock.getInstance().getLogger().info("Generator options available: " + generatorNames);
IridiumSkyblock.getInstance().getLogger().warning("Defaulting to \"skyblock\"...");
return IridiumSkyblock.getInstance().getIridiumChunkGenerators().get(0);
} else {
return IridiumSkyblock.getInstance().getIridiumChunkGenerators().stream()
.filter(generator -> generator.getName().equalsIgnoreCase(name))
.findAny()
.get();
}
}

@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return this.chunkGenerator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ private Biome getBiomeFromNoise(WorldInfo worldInfo, int x, int z) {

private List<Generators.BiomeDataConfig> getBiomeDataConfig(@NotNull World.Environment environment) {
switch(IridiumSkyblock.getInstance().getConfiguration().generatorType.toLowerCase()) {
case "flat": {}
case "flat-legacy": { return getFlatGenerator(environment).biomeDataConfig; }
case "superflat": {}
case "superflat-legacy": { return getFlatGenerator(environment).biomeDataConfig; }
case "ocean": {}
case "ocean-legacy": { return getOceanGenerator(environment).biomeDataConfig; }
default: { return getSkyblockGenerator(environment).biomeDataConfig; }
Expand Down

0 comments on commit 62cb9da

Please sign in to comment.