Fix bug where water couldn't be placed outside of greenhouse.

This commit is contained in:
tastybento 2021-01-31 18:58:06 -08:00
parent b0a0ae6e88
commit 39a88a4f84
2 changed files with 6 additions and 2 deletions

View File

@ -66,7 +66,7 @@ public class GreenhouseEvents implements Listener {
b.setType(Material.WATER);
} else if (!e.getPlayer().getWorld().getEnvironment().equals(World.Environment.NETHER)
&& addon.getManager().getMap().getGreenhouse(b.getLocation())
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(false)) {
// Not in Nether, in a nether greenhouse
e.setCancelled(true);
e.getPlayer().getInventory().getItemInMainHand().setType(Material.BUCKET);
@ -93,7 +93,7 @@ public class GreenhouseEvents implements Listener {
b.setType(Material.WATER);
} else if (!e.getPlayer().getWorld().getEnvironment().equals(World.Environment.NETHER)
&& addon.getManager().getMap().getGreenhouse(b.getLocation())
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(true)) {
.map(gh -> gh.getBiomeRecipe().getBiome()).map(NETHER_BIOMES::contains).orElse(false)) {
// Not in Nether, in a nether greenhouse
e.setCancelled(true);
b.setType(Material.AIR);

View File

@ -285,6 +285,8 @@ public class GreenhouseEventsTest {
Block block = mock(Block.class);
when(block.getType()).thenReturn(Material.ACACIA_BOAT);
when(block.getWorld()).thenReturn(world);
// Nether gh
when(block.getLocation()).thenReturn(location2);
BlockBreakEvent e = new BlockBreakEvent(block, player);
ghe.onIceBreak(e);
verify(block, never()).setType(Material.WATER);
@ -302,6 +304,8 @@ public class GreenhouseEventsTest {
Block block = mock(Block.class);
when(block.getType()).thenReturn(Material.ICE);
when(block.getWorld()).thenReturn(world);
// Nether gh
when(block.getLocation()).thenReturn(location2);
BlockBreakEvent e = new BlockBreakEvent(block, player);
ghe.onIceBreak(e);
verify(block).setType(Material.AIR);