Skip to content

Commit

Permalink
Make BlockEndDragon support custom max world height (#1888)
Browse files Browse the repository at this point in the history
Use max world height instead of magic 255 value.
  • Loading branch information
BONNe authored Dec 6, 2021
1 parent 59de6a8 commit 3b64973
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ private void testLocation(Location location) {
World w = location.getWorld();
if (w == null || !plugin.getIWM().isIslandEnd(w)
|| !Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(w)
|| w.getBlockAt(0, 255, 0).getType().equals(Material.END_PORTAL)) {
|| w.getBlockAt(0, w.getMaxHeight() - 1, 0).getType().equals(Material.END_PORTAL)) {
return;
}

// Setting a End Portal at the top will trick dragon legacy check.
w.getBlockAt(0, 255, 0).setType(Material.END_PORTAL, false);
w.getBlockAt(0, w.getMaxHeight() - 1, 0).setType(Material.END_PORTAL, false);
}

/**
Expand All @@ -68,9 +68,9 @@ public void onEndBlockPlace(BlockPlaceEvent e) {
}

private boolean testBlock(Block block) {
return block.getY() == 255
&& block.getX() == 0
return block.getX() == 0
&& block.getZ() == 0
&& block.getY() == block.getWorld().getMaxHeight() - 1
&& block.getWorld().getEnvironment().equals(Environment.THE_END)
&& Flags.REMOVE_END_EXIT_ISLAND.isSetForWorld(block.getWorld())
&& plugin.getIWM().inWorld(block.getWorld())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void setUp() throws Exception {
when(block.getZ()).thenReturn(0);
when(block.getWorld()).thenReturn(world);
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(block);
when(world.getMaxHeight()).thenReturn(256);
when(world.getEnvironment()).thenReturn(Environment.THE_END);
// Player
UUID uuid = UUID.randomUUID();
Expand Down

0 comments on commit 3b64973

Please sign in to comment.