mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 05:05:18 +01:00
Collect water wasn't overriding bucket usage for visitors
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1545
This commit is contained in:
parent
f09ea1ffef
commit
4a24364f81
@ -39,17 +39,20 @@ public class BucketListener extends FlagListener {
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBucketFill(final PlayerBucketFillEvent e) {
|
public void onBucketFill(final PlayerBucketFillEvent e) {
|
||||||
// Check filling of various liquids
|
// Check filling of various liquids
|
||||||
if (e.getItemStack().getType().equals(Material.LAVA_BUCKET) && (!checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA))) {
|
switch (e.getItemStack().getType()) {
|
||||||
|
case LAVA_BUCKET:
|
||||||
|
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA);
|
||||||
return;
|
return;
|
||||||
}
|
case WATER_BUCKET:
|
||||||
if (e.getItemStack().getType().equals(Material.WATER_BUCKET) && (!checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_WATER))) {
|
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.COLLECT_WATER);
|
||||||
return;
|
return;
|
||||||
}
|
case MILK_BUCKET:
|
||||||
if (e.getItemStack().getType().equals(Material.MILK_BUCKET) && (!checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.MILKING))) {
|
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.MILKING);
|
||||||
return;
|
return;
|
||||||
|
default:
|
||||||
|
// Check general bucket use
|
||||||
|
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.BUCKET);
|
||||||
}
|
}
|
||||||
// Check general bucket use
|
|
||||||
checkIsland(e, e.getPlayer(), e.getBlockClicked().getLocation(), Flags.BUCKET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
@ -283,6 +283,42 @@ public class BucketListenerTest {
|
|||||||
|
|
||||||
verify(notifier, times(4)).notify(any(), eq("protection.protected"));
|
verify(notifier, times(4)).notify(any(), eq("protection.protected"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method for {@link world.bentobox.bentobox.listeners.flags.protection.BucketListener#onBucketFill(org.bukkit.event.player.PlayerBucketFillEvent)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testOnBucketFillMixedAllowed() {
|
||||||
|
when(island.isAllowed(any(), eq(Flags.BUCKET))).thenReturn(false);
|
||||||
|
when(island.isAllowed(any(), eq(Flags.COLLECT_WATER))).thenReturn(true);
|
||||||
|
when(island.isAllowed(any(), eq(Flags.COLLECT_LAVA))).thenReturn(true);
|
||||||
|
when(island.isAllowed(any(), eq(Flags.MILKING))).thenReturn(true);
|
||||||
|
Block block = mock(Block.class);
|
||||||
|
when(block.getLocation()).thenReturn(location);
|
||||||
|
when(block.getRelative(any())).thenReturn(block);
|
||||||
|
ItemStack item = mock(ItemStack.class);
|
||||||
|
when(item.getType()).thenReturn(Material.WATER_BUCKET);
|
||||||
|
PlayerBucketFillEvent e = new PlayerBucketFillEvent(player, block, block, BlockFace.UP, Material.WATER_BUCKET, item);
|
||||||
|
l.onBucketFill(e);
|
||||||
|
assertFalse(e.isCancelled());
|
||||||
|
|
||||||
|
when(item.getType()).thenReturn(Material.BUCKET);
|
||||||
|
e = new PlayerBucketFillEvent(player, block, block, BlockFace.UP, Material.WATER_BUCKET, item);
|
||||||
|
l.onBucketFill(e);
|
||||||
|
assertTrue(e.isCancelled());
|
||||||
|
|
||||||
|
when(item.getType()).thenReturn(Material.LAVA_BUCKET);
|
||||||
|
e = new PlayerBucketFillEvent(player, block, block, BlockFace.UP, Material.WATER_BUCKET, item);
|
||||||
|
l.onBucketFill(e);
|
||||||
|
assertFalse(e.isCancelled());
|
||||||
|
|
||||||
|
when(item.getType()).thenReturn(Material.MILK_BUCKET);
|
||||||
|
e = new PlayerBucketFillEvent(player, block, block, BlockFace.UP, Material.WATER_BUCKET, item);
|
||||||
|
l.onBucketFill(e);
|
||||||
|
assertFalse(e.isCancelled());
|
||||||
|
|
||||||
|
verify(notifier).notify(any(), eq("protection.protected"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method for {@link world.bentobox.bentobox.listeners.flags.protection.BucketListener#onTropicalFishScooping(org.bukkit.event.player.PlayerInteractEntityEvent)}.
|
* Test method for {@link world.bentobox.bentobox.listeners.flags.protection.BucketListener#onTropicalFishScooping(org.bukkit.event.player.PlayerInteractEntityEvent)}.
|
||||||
|
Loading…
Reference in New Issue
Block a user