mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-06 23:41:28 +01:00
Fixed ender dragon issue in 1.14+ (#769)
* Fix ender dragon issue in 1.14+ Mojang changed spawn chunk loading again, so they are all time loaded again. That mean, previous hack, that puts a portal on chunk load will not work anymore, as chunks are loaded before the event even is registered. I fixed it by moving from ChunkLoadEvent to PlayerChangeWorldEvent as it will kick always when player joins the end. * improved javadoc
This commit is contained in:
parent
2927aca98c
commit
12db414ea1
@ -1,5 +1,6 @@
|
||||
package world.bentobox.bentobox.listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -7,7 +8,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
@ -22,26 +24,41 @@ public class BlockEndDragon implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* This listener moves the end exit island high up in the sky
|
||||
* @param e - event
|
||||
* Adds a portal frame at the top of the world, when a player joins an island End world.
|
||||
* This prevents the Ender Dragon from spawning: if any portal frame exists, then the dragon is considered killed already.
|
||||
* @param event PlayerChangedWorldEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onEnd(ChunkLoadEvent e) {
|
||||
if (!e.getWorld().getEnvironment().equals(Environment.THE_END)
|
||||
|| e.getChunk().getX() != 0
|
||||
|| e.getChunk().getZ() != 0
|
||||
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(e.getWorld())
|
||||
|| !plugin.getIWM().inWorld(e.getWorld())
|
||||
|| !plugin.getIWM().isEndGenerate(e.getWorld())
|
||||
|| !plugin.getIWM().isEndIslands(e.getWorld())
|
||||
|| e.getChunk().getBlock(0, 255, 0).getType().equals(Material.END_PORTAL))
|
||||
{
|
||||
// No need to process.
|
||||
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
|
||||
Location location = event.getPlayer().getLocation();
|
||||
|
||||
if (!plugin.getIWM().isIslandEnd(location.getWorld())
|
||||
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(location.getWorld())
|
||||
|| location.getWorld().getBlockAt(0, 255, 0).getType().equals(Material.END_PORTAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting a End Portal at the top will trick dragon legacy check.
|
||||
e.getChunk().getBlock(0, 255, 0).setType(Material.END_PORTAL, false);
|
||||
location.getWorld().getBlockAt(0, 255, 0).setType(Material.END_PORTAL, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a portal frame at the top of the world, when a player joins an island End world.
|
||||
* This prevents the Ender Dragon from spawning: if any portal frame exists, then the dragon is considered killed already.
|
||||
* @param event PlayerJoinEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerJoinWorld(PlayerJoinEvent event) {
|
||||
Location location = event.getPlayer().getLocation();
|
||||
|
||||
if (!plugin.getIWM().isIslandEnd(location.getWorld())
|
||||
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(location.getWorld())
|
||||
|| location.getWorld().getBlockAt(0, 255, 0).getType().equals(Material.END_PORTAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setting a End Portal at the top will trick dragon legacy check.
|
||||
location.getWorld().getBlockAt(0, 255, 0).setType(Material.END_PORTAL, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user