mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Make some events implement ItemEvent
This commit is contained in:
parent
f1ddedfb44
commit
5d3bae3d7f
@ -2,11 +2,11 @@ package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ItemDropEvent implements CancellableEvent {
|
||||
public class ItemDropEvent implements ItemEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ItemStack itemStack;
|
||||
|
@ -1,11 +1,12 @@
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ItemUpdateStateEvent implements Event {
|
||||
public class ItemUpdateStateEvent implements PlayerEvent, ItemEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
@ -18,21 +19,11 @@ public class ItemUpdateStateEvent implements Event {
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player.Hand getHand() {
|
||||
return hand;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public void setHandAnimation(boolean handAnimation) {
|
||||
this.handAnimation = handAnimation;
|
||||
}
|
||||
@ -40,4 +31,14 @@ public class ItemUpdateStateEvent implements Event {
|
||||
public boolean hasHandAnimation() {
|
||||
return handAnimation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.ItemEntity;
|
||||
import net.minestom.server.entity.LivingEntity;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PickupItemEvent implements CancellableEvent {
|
||||
public class PickupItemEvent implements EntityEvent, ItemEvent, CancellableEvent {
|
||||
|
||||
private final LivingEntity livingEntity;
|
||||
private final ItemEntity itemEntity;
|
||||
@ -29,10 +31,6 @@ public class PickupItemEvent implements CancellableEvent {
|
||||
return itemEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getItemEntity()} and {@link ItemEntity#getItemStack()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
public ItemStack getItemStack() {
|
||||
return getItemEntity().getItemStack();
|
||||
@ -47,4 +45,9 @@ public class PickupItemEvent implements CancellableEvent {
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Entity getEntity() {
|
||||
return livingEntity;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Event when an item is used without clicking on a block.
|
||||
*/
|
||||
public class PlayerUseItemEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerUseItemEvent implements PlayerEvent, ItemEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
@ -11,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Used when a player is clicking on a block with an item (but is not a block in item form).
|
||||
*/
|
||||
public class PlayerUseItemOnBlockEvent implements PlayerEvent {
|
||||
public class PlayerUseItemOnBlockEvent implements PlayerEvent, ItemEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
Loading…
Reference in New Issue
Block a user