From 934c04388ddfade47ea0ce78335d98fc49fc457c Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 21 Nov 2022 16:54:32 -0500 Subject: [PATCH] 1.7.0 beta 8 --- .../net/tylermurphy/hideAndSeek/Main.java | 5 ++ .../hideAndSeek/command/world/Create.java | 2 + .../hideAndSeek/util/Location.java | 2 +- .../hideAndSeek/world/VoidGenerator.java | 50 +++++++------------ .../hideAndSeek/world/WorldLoader.java | 12 +++-- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/Main.java b/src/main/java/net/tylermurphy/hideAndSeek/Main.java index 656f60d..ad49273 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/Main.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/Main.java @@ -280,5 +280,10 @@ public class Main extends JavaPlugin implements Listener { public boolean isLoaded() { return loaded; } + + public void scheduleTask(Runnable task) { + if(!isEnabled()) return; + Bukkit.getServer().getScheduler().runTask(this, task); + } } \ No newline at end of file diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java index 5ab9039..20ffd5a 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java @@ -3,8 +3,10 @@ package net.tylermurphy.hideAndSeek.command.world; import net.tylermurphy.hideAndSeek.Main; import net.tylermurphy.hideAndSeek.command.util.ICommand; import net.tylermurphy.hideAndSeek.util.Location; +import org.bukkit.Bukkit; import org.bukkit.WorldType; import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; import java.util.Arrays; diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java b/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java index b75eb95..e769b05 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/Location.java @@ -84,7 +84,7 @@ public class Location { public void teleport(Player player) { if(!exists()) return; if(load() == null) return; - player.teleport(toBukkit()); + Main.getInstance().scheduleTask(() -> player.teleport(toBukkit())); } public Location changeWorld(String world) { diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java index b0ce824..15ff45f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/VoidGenerator.java @@ -19,7 +19,9 @@ package net.tylermurphy.hideAndSeek.world; +import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.jetbrains.annotations.NotNull; @@ -36,41 +38,27 @@ public class VoidGenerator extends ChunkGenerator { return Collections.emptyList(); } - public boolean shouldGenerateNoise() { - return false; - } - - public boolean shouldGenerateSurface() { - return false; - } - - public boolean shouldGenerateBedrock() { - return false; - } - - public boolean shouldGenerateCaves() { - return false; - } - - public boolean shouldGenerateDecorations() { - return false; - } - - public boolean shouldGenerateMobs() { - return false; - } - - public boolean shouldGenerateStructures() { - return false; - } - - public boolean canSpawn(@NotNull World world, int x, int z) { + @Override + public boolean canSpawn(World world, int x, int z) { return true; } + @Override + public Location getFixedSpawnLocation(World world, Random random) { + return new Location(world, 0, 100, 0); + } + // 1.13 And Prev - public @NotNull ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome) { - return createChunkData(world); + public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biome) { + ChunkData chunkData = super.createChunkData(world); + + for(int x = 0; x < 16; x++) { + for(int z = 0; z < 16; z++) { + biome.setBiome(x, z, Biome.PLAINS); + } + } + + return chunkData; } // 1.8 diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java index 6ea1773..864397e 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java @@ -50,11 +50,13 @@ public class WorldLoader { return; } world.getPlayers().forEach(player -> exitPosition.teleport(player)); - if (Bukkit.getServer().unloadWorld(world, false)) { - Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName()); - }else{ - Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + map.getGameSpawnName()); - } + Main.getInstance().scheduleTask(() -> { + if (Bukkit.getServer().unloadWorld(world, false)) { + Main.getInstance().getLogger().info("Successfully unloaded " + map.getGameSpawnName()); + } else { + Main.getInstance().getLogger().severe("COULD NOT UNLOAD " + map.getGameSpawnName()); + } + }); } public void loadMap() {