Item Frames could be placed on any island.

https://github.com/BentoBoxWorld/BentoBox/issues/610
This commit is contained in:
tastybento 2019-03-17 15:18:19 -07:00
parent 47900fd183
commit 39c3861391
2 changed files with 17 additions and 11 deletions

View File

@ -44,7 +44,7 @@ public class PlaceBlocksListener extends FlagListener {
}
/**
* Handle placing of fireworks, mine carts, end crystals, doors, chests and boats on land
* Handle placing of fireworks, item frames, mine carts, end crystals, chests and boats on land
* The doors and chests are related to an exploit.
* @param e - event
*/
@ -73,8 +73,10 @@ public class PlaceBlocksListener extends FlagListener {
if (e.getMaterial().equals(Material.FIREWORK_ROCKET)
|| e.getMaterial().equals(Material.ARMOR_STAND)
|| e.getMaterial().equals(Material.END_CRYSTAL)
|| e.getMaterial().equals(Material.ITEM_FRAME)
//|| Tag.DOORS.isTagged(e.getMaterial())
|| e.getMaterial().equals(Material.CHEST) || e.getMaterial().equals(Material.TRAPPED_CHEST)) {
|| e.getMaterial().equals(Material.CHEST)
|| e.getMaterial().equals(Material.TRAPPED_CHEST)) {
checkIsland(e, e.getPlayer(), e.getPlayer().getLocation(), Flags.PLACE_BLOCKS);
}
else if (e.getMaterial().name().contains("BOAT")) {

View File

@ -280,13 +280,15 @@ public class PlaceBlocksListenerTest {
@Test
public void testOnPlayerInteract() {
ItemStack item = mock(ItemStack.class);
when(item.getType()).thenReturn(Material.ARMOR_STAND);
when(item.getType()).thenReturn(Material.ARMOR_STAND, Material.FIREWORK_ROCKET, Material.ITEM_FRAME, Material.END_CRYSTAL, Material.CHEST, Material.TRAPPED_CHEST, Material.JUNGLE_BOAT);
Block clickedBlock = mock(Block.class);
when(clickedBlock.getLocation()).thenReturn(location);
when(clickedBlock.getType()).thenReturn(Material.GRASS_BLOCK);
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item, clickedBlock, BlockFace.UP, EquipmentSlot.HAND);
pbl.onPlayerInteract(e);
assertFalse(e.isCancelled());
for (int i = 0; i < 7; i++) {
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item, clickedBlock, BlockFace.UP, EquipmentSlot.HAND);
pbl.onPlayerInteract(e);
assertFalse("Failed on " + item.getType().toString(), e.isCancelled());
}
}
/**
@ -296,14 +298,16 @@ public class PlaceBlocksListenerTest {
public void testOnPlayerInteractNotAllowed() {
when(island.isAllowed(Mockito.any(), Mockito.any())).thenReturn(false);
ItemStack item = mock(ItemStack.class);
when(item.getType()).thenReturn(Material.ARMOR_STAND);
when(item.getType()).thenReturn(Material.ARMOR_STAND, Material.FIREWORK_ROCKET, Material.ITEM_FRAME, Material.END_CRYSTAL, Material.CHEST, Material.TRAPPED_CHEST, Material.DARK_OAK_BOAT);
Block clickedBlock = mock(Block.class);
when(clickedBlock.getLocation()).thenReturn(location);
when(clickedBlock.getType()).thenReturn(Material.GRASS_BLOCK);
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item, clickedBlock, BlockFace.UP, EquipmentSlot.HAND);
pbl.onPlayerInteract(e);
assertTrue(e.isCancelled());
Mockito.verify(notifier).notify(Mockito.any(), Mockito.eq("protection.protected"));
for (int i = 0; i < 7; i++) {
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, item, clickedBlock, BlockFace.UP, EquipmentSlot.HAND);
pbl.onPlayerInteract(e);
assertTrue("Failed on " + item.getType().toString(), e.isCancelled());
}
Mockito.verify(notifier, Mockito.times(7)).notify(Mockito.any(), Mockito.eq("protection.protected"));
}
/**