From 9c714e10ba7fc78b39b9b0d48b167caf59844694 Mon Sep 17 00:00:00 2001 From: tastybento Date: Wed, 3 Mar 2021 20:51:31 -0800 Subject: [PATCH] Code cleanup. --- .../bentobox/boxed/AdvancementsManager.java | 2 +- src/main/java/world/bentobox/boxed/Boxed.java | 53 +++++++++---------- .../java/world/bentobox/boxed/Settings.java | 4 -- .../boxed/generators/BasicWorldGenerator.java | 3 +- .../bentobox/boxed/generators/DeleteGen.java | 2 - 5 files changed, 26 insertions(+), 38 deletions(-) diff --git a/src/main/java/world/bentobox/boxed/AdvancementsManager.java b/src/main/java/world/bentobox/boxed/AdvancementsManager.java index db3e61c..8991bc8 100644 --- a/src/main/java/world/bentobox/boxed/AdvancementsManager.java +++ b/src/main/java/world/bentobox/boxed/AdvancementsManager.java @@ -67,7 +67,7 @@ public class AdvancementsManager { */ @NonNull protected IslandAdvancements getIsland(Island island) { - return cache.computeIfAbsent(island.getUniqueId(), k -> getFromDb(k)); + return cache.computeIfAbsent(island.getUniqueId(), this::getFromDb); } diff --git a/src/main/java/world/bentobox/boxed/Boxed.java b/src/main/java/world/bentobox/boxed/Boxed.java index 0aa6948..17df340 100644 --- a/src/main/java/world/bentobox/boxed/Boxed.java +++ b/src/main/java/world/bentobox/boxed/Boxed.java @@ -64,7 +64,7 @@ public class Boxed extends GameModeAddon { .getInstance(getPlugin(), 0, 5) .createCustomGenerator(wordRef, generator -> { // Set the noise generator - generator.setBaseNoiseGenerator(new BasicWorldGenerator(this, wordRef, getSettings().getSeed())); + generator.setBaseNoiseGenerator(new BasicWorldGenerator(this, getSettings().getSeed())); if (getSettings().isAllowStructures()) { generator.getWorldDecorator().withoutDefaultDecorations(DecorationType.SURFACE_STRUCTURES); } @@ -74,15 +74,8 @@ public class Boxed extends GameModeAddon { generator.setBiomeGenerator(new BoxedBiomeGenerator(this)); }); // Register commands - playerCommand = new DefaultPlayerCommand(this) + playerCommand = new DefaultPlayerCommand(this) {}; - { - @Override - public void setup() - { - super.setup(); - } - }; adminCommand = new DefaultAdminCommand(this) {}; // Register listeners @@ -104,8 +97,6 @@ public class Boxed extends GameModeAddon { @Override public void onEnable(){ - // Register this - //registerListener(new JoinListener(this)); // Advancements manager advManager = new AdvancementsManager(this); // Get delete chunk generator @@ -180,29 +171,33 @@ public class Boxed extends GameModeAddon { } // Set spawn rates if (w != null) { - if (getSettings().getSpawnLimitMonsters() > 0) { - w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters()); - } - if (getSettings().getSpawnLimitAmbient() > 0) { - w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient()); - } - if (getSettings().getSpawnLimitAnimals() > 0) { - w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals()); - } - if (getSettings().getSpawnLimitWaterAnimals() > 0) { - w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals()); - } - if (getSettings().getTicksPerAnimalSpawns() > 0) { - w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns()); - } - if (getSettings().getTicksPerMonsterSpawns() > 0) { - w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns()); - } + setSpawnRates(w); } return w; } + private void setSpawnRates(World w) { + if (getSettings().getSpawnLimitMonsters() > 0) { + w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters()); + } + if (getSettings().getSpawnLimitAmbient() > 0) { + w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient()); + } + if (getSettings().getSpawnLimitAnimals() > 0) { + w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals()); + } + if (getSettings().getSpawnLimitWaterAnimals() > 0) { + w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals()); + } + if (getSettings().getTicksPerAnimalSpawns() > 0) { + w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns()); + } + if (getSettings().getTicksPerMonsterSpawns() > 0) { + w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns()); + } + } + @Override public WorldSettings getWorldSettings() { return getSettings(); diff --git a/src/main/java/world/bentobox/boxed/Settings.java b/src/main/java/world/bentobox/boxed/Settings.java index 4567060..5c66768 100644 --- a/src/main/java/world/bentobox/boxed/Settings.java +++ b/src/main/java/world/bentobox/boxed/Settings.java @@ -1615,10 +1615,6 @@ public class Settings implements WorldSettings { this.defaultEndBiome = defaultEndBiome; } - public float getNoiseScaleHorizontal() { - return 10; - } - /** * @return the seed */ diff --git a/src/main/java/world/bentobox/boxed/generators/BasicWorldGenerator.java b/src/main/java/world/bentobox/boxed/generators/BasicWorldGenerator.java index 2c82aa8..ef87206 100644 --- a/src/main/java/world/bentobox/boxed/generators/BasicWorldGenerator.java +++ b/src/main/java/world/bentobox/boxed/generators/BasicWorldGenerator.java @@ -8,7 +8,6 @@ import org.bukkit.util.noise.SimplexNoiseGenerator; import nl.rutgerkok.worldgeneratorapi.BaseNoiseGenerator; import nl.rutgerkok.worldgeneratorapi.BiomeGenerator; -import nl.rutgerkok.worldgeneratorapi.WorldRef; import world.bentobox.boxed.Boxed; /** @@ -22,7 +21,7 @@ public class BasicWorldGenerator implements BaseNoiseGenerator { private final YamlConfiguration config; - public BasicWorldGenerator(Boxed addon, WorldRef world, long seed) { + public BasicWorldGenerator(Boxed addon, long seed) { this.addon = addon; // Initialize the noise generator based on the world seed this.mainNoiseGenerator = new SimplexNoiseGenerator(seed); diff --git a/src/main/java/world/bentobox/boxed/generators/DeleteGen.java b/src/main/java/world/bentobox/boxed/generators/DeleteGen.java index 6fce403..1a7c9fd 100644 --- a/src/main/java/world/bentobox/boxed/generators/DeleteGen.java +++ b/src/main/java/world/bentobox/boxed/generators/DeleteGen.java @@ -24,8 +24,6 @@ public class DeleteGen extends ChunkGenerator { public DeleteGen(Boxed addon) { backMap = new HashMap<>(); backMap.put(addon.getOverWorld(), Bukkit.getWorld(addon.getOverWorld().getName() + "_bak")); - //backMap.put(addon.getNetherWorld(), Bukkit.getWorld(addon.getNetherWorld().getName() + "_bak")); - //backMap.put(addon.getEndWorld(), Bukkit.getWorld(addon.getEndWorld().getName() + "_bak")); } @Override