mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 23:17:59 +02:00
Prevent dropping air
This commit is contained in:
parent
1f2e4de0b3
commit
d0ad143c0f
@ -1290,11 +1290,17 @@ public class Player extends LivingEntity implements CommandSender {
|
||||
|
||||
/**
|
||||
* Calls an {@link ItemDropEvent} with a specified item.
|
||||
* <p>
|
||||
* Returns false if {@code item} is air.
|
||||
*
|
||||
* @param item the item to drop
|
||||
* @return true if player can drop the item (event not cancelled), false otherwise
|
||||
*/
|
||||
public boolean dropItem(@NotNull ItemStack item) {
|
||||
if (item.isAir()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemDropEvent itemDropEvent = new ItemDropEvent(item);
|
||||
callEvent(ItemDropEvent.class, itemDropEvent);
|
||||
return !itemDropEvent.isCancelled();
|
||||
|
Loading…
Reference in New Issue
Block a user