From 52b1ae40562ae138f8e79e9769d396af180ce59f Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 26 Nov 2022 23:23:01 -0800 Subject: [PATCH] Code cleanup. Remove debug. --- src/main/java/world/bentobox/boxed/Boxed.java | 11 +--- .../world/bentobox/boxed/BoxedPladdon.java | 9 --- .../world/bentobox/boxed/DebugListener.java | 40 ----------- .../boxed/generators/BoxedBiomeProvider.java | 66 ------------------- .../boxed/generators/SimpleBiomeProvider.java | 35 ---------- 5 files changed, 3 insertions(+), 158 deletions(-) delete mode 100644 src/main/java/world/bentobox/boxed/DebugListener.java delete mode 100644 src/main/java/world/bentobox/boxed/generators/BoxedBiomeProvider.java delete mode 100644 src/main/java/world/bentobox/boxed/generators/SimpleBiomeProvider.java diff --git a/src/main/java/world/bentobox/boxed/Boxed.java b/src/main/java/world/bentobox/boxed/Boxed.java index 6e2fe90..0f3d7d4 100644 --- a/src/main/java/world/bentobox/boxed/Boxed.java +++ b/src/main/java/world/bentobox/boxed/Boxed.java @@ -3,6 +3,7 @@ package world.bentobox.boxed; import java.util.Collections; import org.bukkit.ChunkSnapshot; +import org.bukkit.Difficulty; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.World.Environment; @@ -149,17 +150,11 @@ public class Boxed extends GameModeAddon { .generateStructures(false) .seed(getSettings().getSeed()) .createWorld(); + seedWorld.setDifficulty(Difficulty.PEACEFUL); // No damage wanted in this world. saveChunks(seedWorld); - String worldName = settings.getWorldName().toLowerCase(); - /* - if (getServer().getWorld(worldName) == null) { - log("Creating Boxed Seed world ..."); - } - seedWorld = WorldCreator.name(worldName + "_bak").seed(settings.getSeed()).createWorld(); - seedWorld.setDifficulty(Difficulty.PEACEFUL); // No damage wanted in this world. - */ + if (getServer().getWorld(worldName) == null) { log("Creating Boxed world ..."); } diff --git a/src/main/java/world/bentobox/boxed/BoxedPladdon.java b/src/main/java/world/bentobox/boxed/BoxedPladdon.java index f438e44..95455df 100644 --- a/src/main/java/world/bentobox/boxed/BoxedPladdon.java +++ b/src/main/java/world/bentobox/boxed/BoxedPladdon.java @@ -1,12 +1,7 @@ package world.bentobox.boxed; -import org.bukkit.generator.BiomeProvider; -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; - import world.bentobox.bentobox.api.addons.Addon; import world.bentobox.bentobox.api.addons.Pladdon; -import world.bentobox.boxed.generators.SimpleBiomeProvider; public class BoxedPladdon extends Pladdon { @@ -15,8 +10,4 @@ public class BoxedPladdon extends Pladdon { return new Boxed(); } - @Override - public BiomeProvider getDefaultBiomeProvider(@NonNull String worldName, @Nullable String id) { - return new SimpleBiomeProvider(); - } } diff --git a/src/main/java/world/bentobox/boxed/DebugListener.java b/src/main/java/world/bentobox/boxed/DebugListener.java deleted file mode 100644 index f9ac1ee..0000000 --- a/src/main/java/world/bentobox/boxed/DebugListener.java +++ /dev/null @@ -1,40 +0,0 @@ -package world.bentobox.boxed; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerMoveEvent; - -import world.bentobox.bentobox.BentoBox; - -/** - * @author tastybento - * - */ -public class DebugListener implements Listener { - - private final Boxed addon; - private int size; - - /** - * @param addon - */ - public DebugListener(Boxed addon) { - this.addon = addon; - this.size = addon.getSettings().getIslandDistance(); - } - - @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void onMove(PlayerMoveEvent e) { - if (e.getTo().getBlockX() != e.getFrom().getBlockX() || e.getTo().getBlockZ() != e.getFrom().getBlockZ()) { - int chunkX = e.getTo().getChunk().getX(); - int chunkZ = e.getTo().getChunk().getZ(); - int xx = Math.floorMod(chunkX, size); - int zz = Math.floorMod(chunkZ, size); - BentoBox.getInstance().logDebug("x = " + e.getTo().getBlockX() + " z = " + e.getTo().getBlockZ()); - BentoBox.getInstance().logDebug("ChunkX = " + chunkX + " ChunkZ = " + chunkZ); - BentoBox.getInstance().logDebug("CalcChunk X = " + xx + " Calc ChunkZ = " + zz + " should loop"); - - } - } -} diff --git a/src/main/java/world/bentobox/boxed/generators/BoxedBiomeProvider.java b/src/main/java/world/bentobox/boxed/generators/BoxedBiomeProvider.java deleted file mode 100644 index c4d6d92..0000000 --- a/src/main/java/world/bentobox/boxed/generators/BoxedBiomeProvider.java +++ /dev/null @@ -1,66 +0,0 @@ -package world.bentobox.boxed.generators; - -import java.util.Arrays; -import java.util.List; - -import org.bukkit.ChunkSnapshot; -import org.bukkit.block.Biome; -import org.bukkit.generator.BiomeProvider; -import org.bukkit.generator.WorldInfo; - -import world.bentobox.bentobox.BentoBox; -import world.bentobox.boxed.Boxed; - -/** - * @author tastybento - * - */ -public class BoxedBiomeProvider extends BiomeProvider { - - private final Boxed addon; - - public BoxedBiomeProvider(Boxed boxed) { - addon = boxed; - } - - @Override - public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) { - if (!worldInfo.getName().equals(addon.getSettings().getWorldName())) { - BentoBox.getInstance().logDebug("Wrong world biome ask."); - return Biome.OLD_GROWTH_SPRUCE_TAIGA; - } - int chunkX = (int)((double)x/16); - int chunkZ = (int)((double)z/16); - ChunkSnapshot c = addon.getChunkGenerator().getChunk(chunkX, chunkZ); - if (c == null) { - //BentoBox.getInstance().logDebug("No chunk snapshot for " + (int)((double)x/16) + "," + (int)((double)z/16)); - return Biome.OLD_GROWTH_SPRUCE_TAIGA; - } - int xx = Math.floorMod(x, 16); - int zz = Math.floorMod(z, 16); - int yy = Math.max(Math.min(y * 4, worldInfo.getMaxHeight()), worldInfo.getMinHeight()); // To handle bug in Spigot - Biome b = c.getBiome(xx, yy, zz); - if (b != Biome.CUSTOM) { - /* - if (chunkX == 0 && chunkZ == 0) { - BentoBox.getInstance().logDebug("Chunk thinks its coords are x=" + c.getX() + " z=" + c.getZ()); - BentoBox.getInstance().logDebug("World min = " + worldInfo.getMinHeight() + " world max = " + worldInfo.getMaxHeight()); - BentoBox.getInstance().logDebug("Biome found and coord = " + b + " " + x + "," + y + "," + z); - BentoBox.getInstance().logDebug("Chunk = " + chunkX + "," + chunkZ); - BentoBox.getInstance().logDebug("Pos in chunk " + xx + "," + yy + "," + zz); - } - */ - return b; - } else { - return Biome.OLD_GROWTH_BIRCH_FOREST; - } - } - - @Override - public List getBiomes(WorldInfo worldInfo) { - // Return all of them for now! - return Arrays.stream(Biome.values()).filter(b -> !b.equals(Biome.CUSTOM)).toList(); - //return overWorld.getBiomeProvider().getBiomes(overWorld); - } - -} diff --git a/src/main/java/world/bentobox/boxed/generators/SimpleBiomeProvider.java b/src/main/java/world/bentobox/boxed/generators/SimpleBiomeProvider.java deleted file mode 100644 index 432962f..0000000 --- a/src/main/java/world/bentobox/boxed/generators/SimpleBiomeProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package world.bentobox.boxed.generators; - -import java.util.List; -import java.util.Random; - -import org.bukkit.block.Biome; -import org.bukkit.generator.BiomeProvider; -import org.bukkit.generator.WorldInfo; -import org.bukkit.util.noise.SimplexOctaveGenerator; -import org.eclipse.jdt.annotation.NonNull; - -import com.google.common.collect.Lists; - -public class SimpleBiomeProvider extends BiomeProvider { - - @NonNull - @Override - public Biome getBiome(@NonNull WorldInfo worldInfo, int x, int y, int z) { - SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(worldInfo.getSeed()), 6); - generator.setScale(0.01); - - - if (generator.noise(x, z, 1, 1, true) < 0) { - return Biome.OCEAN; - } else { - return Biome.DESERT; - } - } - - @NonNull - @Override - public List getBiomes(@NonNull WorldInfo worldInfo) { - return Lists.newArrayList(Biome.OCEAN, Biome.DESERT); - } -} \ No newline at end of file