From b40afbe16781b0eaf61dd22b9ea8e5ead5e16467 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sun, 12 Jul 2020 17:17:25 +0200 Subject: [PATCH] Fix for biomes broken in 2.3.4 in Nether and End --- .../java/com/songoda/skyblock/SkyBlock.java | 1 + .../com/songoda/skyblock/listeners/World.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/main/java/com/songoda/skyblock/listeners/World.java diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index b64589fe..7f5e8e70 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -213,6 +213,7 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new Grow(this), this); pluginManager.registerEvents(new Piston(this), this); pluginManager.registerEvents(new FallBreak(this), this); + pluginManager.registerEvents(new World(this), this); if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); diff --git a/src/main/java/com/songoda/skyblock/listeners/World.java b/src/main/java/com/songoda/skyblock/listeners/World.java new file mode 100644 index 00000000..e082cb94 --- /dev/null +++ b/src/main/java/com/songoda/skyblock/listeners/World.java @@ -0,0 +1,48 @@ +package com.songoda.skyblock.listeners; + +import com.songoda.core.compatibility.CompatibleBiome; +import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.biome.BiomeManager; +import com.songoda.skyblock.island.Island; +import com.songoda.skyblock.island.IslandManager; +import com.songoda.skyblock.island.IslandWorld; +import org.bukkit.Location; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerChangedWorldEvent; + +public class World implements Listener { + + private final SkyBlock plugin; + + public World(SkyBlock plugin) { + this.plugin = plugin; + } + + // Hotfix for wrong biome in other worlds; + @EventHandler(ignoreCancelled = true) + public void onWorldChange(PlayerChangedWorldEvent event) { + IslandManager islandManager = plugin.getIslandManager(); + BiomeManager biomeManager = plugin.getBiomeManager(); + + Location to = event.getPlayer().getLocation(); + Island island = islandManager.getIslandAtLocation(to); + + if(island != null) { + switch (to.getWorld().getEnvironment()) { + case NORMAL: + break; + case NETHER: + if(!to.getBlock().getBiome().equals(CompatibleBiome.NETHER_WASTES.getBiome())) { + biomeManager.setBiome(island, IslandWorld.Nether, CompatibleBiome.NETHER_WASTES.getBiome(), null); + } + break; + case THE_END: + if(!to.getBlock().getBiome().equals(CompatibleBiome.THE_END.getBiome())) { + biomeManager.setBiome(island, IslandWorld.End, CompatibleBiome.THE_END.getBiome(), null); + } + break; + } + } + } +}