Prevents instant lava placing when scooping.

https://github.com/BentoBoxWorld/BentoBox/issues/1459
This commit is contained in:
tastybento 2020-07-22 22:29:37 -07:00
parent ab6799c159
commit 284b5865da
2 changed files with 4 additions and 0 deletions

View File

@ -50,6 +50,7 @@ public class ObsidianScoopingListener extends FlagListener {
}
user.sendMessage("protection.flags.OBSIDIAN_SCOOPING.scooping");
e.setCancelled(true);
if (e.getItem().getAmount() == 1) {
// Needs some special handling when there is only 1 bucket in the stack
e.getItem().setType(Material.LAVA_BUCKET);

View File

@ -1,5 +1,6 @@
package world.bentobox.bentobox.listeners.flags.worldsettings;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
@ -20,6 +21,7 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -278,6 +280,7 @@ public class ObsidianScoopingListenerTest {
// Test where the area is free of obby
when(world.getBlockAt(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt())).thenReturn(airBlock);
assertTrue(listener.onPlayerInteract(event));
assertEquals(Result.DENY, event.useInteractedBlock());
}
}
}