mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Add EntityInstanceEvent (#480)
This commit is contained in:
parent
2f1e4101d1
commit
45071cebd8
@ -1,14 +1,14 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player does a left click on an entity or with
|
||||
* {@link net.minestom.server.entity.EntityCreature#attack(Entity)}.
|
||||
*/
|
||||
public class EntityAttackEvent implements EntityEvent {
|
||||
public class EntityAttackEvent implements EntityInstanceEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final Entity target;
|
||||
|
@ -4,13 +4,13 @@ import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.LivingEntity;
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called with {@link LivingEntity#damage(DamageType, float)}.
|
||||
*/
|
||||
public class EntityDamageEvent implements EntityEvent, CancellableEvent {
|
||||
public class EntityDamageEvent implements EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final DamageType damageType;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityDeathEvent implements EntityEvent {
|
||||
public class EntityDeathEvent implements EntityInstanceEvent {
|
||||
|
||||
// TODO cause
|
||||
private final Entity entity;
|
||||
|
@ -2,13 +2,13 @@ package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
|
||||
public class EntityFireEvent implements EntityEvent, CancellableEvent {
|
||||
public class EntityFireEvent implements EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private Duration duration;
|
||||
|
@ -3,14 +3,14 @@ package net.minestom.server.event.entity;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.ItemEntity;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when two {@link ItemEntity} are merging their {@link ItemStack} together to form a sole entity.
|
||||
*/
|
||||
public class EntityItemMergeEvent implements EntityEvent, CancellableEvent {
|
||||
public class EntityItemMergeEvent implements EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final ItemEntity merged;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.potion.Potion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPotionAddEvent implements EntityEvent {
|
||||
public class EntityPotionAddEvent implements EntityInstanceEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final Potion potion;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.potion.Potion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityPotionRemoveEvent implements EntityEvent {
|
||||
public class EntityPotionRemoveEvent implements EntityInstanceEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final Potion potion;
|
||||
|
@ -4,13 +4,13 @@ import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityProjectile;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called with {@link EntityProjectile#shoot(Point, double, double)}
|
||||
*/
|
||||
public class EntityShootEvent implements EntityEvent, CancellableEvent {
|
||||
public class EntityShootEvent implements EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final Entity projectile;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a new instance is set for an entity.
|
||||
*/
|
||||
public class EntitySpawnEvent implements EntityEvent {
|
||||
public class EntitySpawnEvent implements EntityInstanceEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private final Instance spawnInstance;
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when an entity ticks itself.
|
||||
* Same event instance used for all tick events for the same entity.
|
||||
*/
|
||||
public class EntityTickEvent implements EntityEvent {
|
||||
public class EntityTickEvent implements EntityInstanceEvent {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a velocity is applied to an entity using {@link Entity#setVelocity(Vec)}.
|
||||
*/
|
||||
public class EntityVelocityEvent implements EntityEvent, CancellableEvent {
|
||||
public class EntityVelocityEvent implements EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private Vec velocity;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.InventoryEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Called after {@link InventoryPreClickEvent}, this event cannot be cancelled and items related to the click
|
||||
* are already moved.
|
||||
*/
|
||||
public class InventoryClickEvent implements InventoryEvent, PlayerEvent {
|
||||
public class InventoryClickEvent implements InventoryEvent, PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Inventory inventory;
|
||||
private final Player player;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.InventoryEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
@ -10,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Called when an {@link Inventory} is closed by a player.
|
||||
*/
|
||||
public class InventoryCloseEvent implements InventoryEvent, PlayerEvent {
|
||||
public class InventoryCloseEvent implements InventoryEvent, PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Inventory inventory;
|
||||
private final Player player;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.InventoryEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
* <p>
|
||||
* Executed by {@link Player#openInventory(Inventory)}.
|
||||
*/
|
||||
public class InventoryOpenEvent implements InventoryEvent, PlayerEvent, CancellableEvent {
|
||||
public class InventoryOpenEvent implements InventoryEvent, PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private Inventory inventory;
|
||||
private final Player player;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.InventoryEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
@ -13,7 +14,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Called before {@link InventoryClickEvent}, used to potentially cancel the click.
|
||||
*/
|
||||
public class InventoryPreClickEvent implements InventoryEvent, PlayerEvent, CancellableEvent {
|
||||
public class InventoryPreClickEvent implements InventoryEvent, PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Inventory inventory;
|
||||
private final Player player;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.inventory.AbstractInventory;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
@ -10,12 +11,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Called when {@link AbstractInventory#safeItemInsert(int, ItemStack)} is being invoked on a {@link PlayerInventory}.
|
||||
* This event cannot be cancelled and items related to the change are already moved.
|
||||
*
|
||||
* <p>
|
||||
* When this event is being called, {@link InventoryItemChangeEvent} listeners will also be triggered, so you can
|
||||
* listen only for an ancestor event and check whether it is an instance of that class.
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
public class PlayerInventoryItemChangeEvent extends InventoryItemChangeEvent implements PlayerEvent {
|
||||
public class PlayerInventoryItemChangeEvent extends InventoryItemChangeEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -3,11 +3,12 @@ package net.minestom.server.event.item;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EquipmentSlot;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityEquipEvent implements EntityEvent, ItemEvent {
|
||||
public class EntityEquipEvent implements EntityEvent, EntityInstanceEvent, ItemEvent {
|
||||
|
||||
private final Entity entity;
|
||||
private ItemStack equippedItem;
|
||||
|
@ -2,12 +2,13 @@ package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
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 ItemDropEvent implements PlayerEvent, ItemEvent, CancellableEvent {
|
||||
public class ItemDropEvent implements PlayerEvent, EntityInstanceEvent, ItemEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ItemStack itemStack;
|
||||
|
@ -1,12 +1,13 @@
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
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 PlayerEvent, ItemEvent {
|
||||
public class ItemUpdateStateEvent implements PlayerEvent, EntityInstanceEvent, ItemEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -3,10 +3,11 @@ package net.minestom.server.event.item;
|
||||
import net.minestom.server.entity.ExperienceOrb;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PickupExperienceEvent implements CancellableEvent, PlayerEvent {
|
||||
public class PickupExperienceEvent implements CancellableEvent, PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ExperienceOrb experienceOrb;
|
||||
|
@ -5,11 +5,12 @@ import net.minestom.server.entity.ItemEntity;
|
||||
import net.minestom.server.entity.LivingEntity;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PickupItemEvent implements EntityEvent, ItemEvent, CancellableEvent {
|
||||
public class PickupItemEvent implements EntityEvent, EntityInstanceEvent, ItemEvent, CancellableEvent {
|
||||
|
||||
private final LivingEntity livingEntity;
|
||||
private final ItemEntity itemEntity;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.advancements.AdvancementAction;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -9,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* Called when a {@link Player} opens the advancement screens or switch the tab
|
||||
* and when he closes the screen.
|
||||
*/
|
||||
public class AdvancementTabEvent implements PlayerEvent {
|
||||
public class AdvancementTabEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final AdvancementAction action;
|
||||
|
@ -1,14 +1,15 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.BlockEvent;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerBlockBreakEvent implements PlayerEvent, BlockEvent, CancellableEvent {
|
||||
public class PlayerBlockBreakEvent implements PlayerEvent, EntityInstanceEvent, BlockEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Block block;
|
||||
|
@ -1,19 +1,20 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.BlockEvent;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player interacts with a block (right-click).
|
||||
* This is also called when a block is placed.
|
||||
*/
|
||||
public class PlayerBlockInteractEvent implements PlayerEvent, BlockEvent, CancellableEvent {
|
||||
public class PlayerBlockInteractEvent implements PlayerEvent, EntityInstanceEvent, BlockEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -4,6 +4,7 @@ import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.BlockEvent;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
@ -12,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Called when a player tries placing a block.
|
||||
*/
|
||||
public class PlayerBlockPlaceEvent implements PlayerEvent, BlockEvent, CancellableEvent {
|
||||
public class PlayerBlockPlaceEvent implements PlayerEvent, EntityInstanceEvent, BlockEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private Block block;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Called when a player change his held slot (by pressing 1-9 keys).
|
||||
*/
|
||||
public class PlayerChangeHeldSlotEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerChangeHeldSlotEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private byte slot;
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.event.player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -16,7 +17,7 @@ import java.util.function.Supplier;
|
||||
* Called every time a {@link Player} write and send something in the chat.
|
||||
* The event can be cancelled to do not send anything, and the format can be changed.
|
||||
*/
|
||||
public class PlayerChatEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerChatEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Collection<Player> recipients;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player receive a new chunk data.
|
||||
*/
|
||||
public class PlayerChunkLoadEvent implements PlayerEvent {
|
||||
public class PlayerChunkLoadEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final int chunkX, chunkZ;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -9,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* <p>
|
||||
* Could be used to unload the chunk internally in order to save memory.
|
||||
*/
|
||||
public class PlayerChunkUnloadEvent implements PlayerEvent {
|
||||
public class PlayerChunkUnloadEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final int chunkX, chunkZ;
|
||||
|
@ -2,13 +2,14 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called every time a player send a message starting by '/'.
|
||||
*/
|
||||
public class PlayerCommandEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerCommandEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private String command;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -9,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Called when a player die in {@link Player#kill()}.
|
||||
*/
|
||||
public class PlayerDeathEvent implements PlayerEvent {
|
||||
public class PlayerDeathEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private Component deathText;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player disconnect.
|
||||
*/
|
||||
public class PlayerDisconnectEvent implements PlayerEvent {
|
||||
public class PlayerDisconnectEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -8,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Called when a player is finished eating.
|
||||
*/
|
||||
public class PlayerEatEvent implements PlayerEvent {
|
||||
public class PlayerEatEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ItemStack foodItem;
|
||||
|
@ -2,13 +2,14 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a {@link Player} interacts (right-click) with an {@link Entity}.
|
||||
*/
|
||||
public class PlayerEntityInteractEvent implements PlayerEvent {
|
||||
public class PlayerEntityInteractEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Entity entityTarget;
|
||||
|
@ -2,13 +2,14 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when the player swings his hand.
|
||||
*/
|
||||
public class PlayerHandAnimationEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerHandAnimationEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
* @see ItemAnimationType
|
||||
*/
|
||||
public class PlayerItemAnimationEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerItemAnimationEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ItemAnimationType armAnimationType;
|
||||
|
@ -1,15 +1,16 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player is modifying his position.
|
||||
*/
|
||||
public class PlayerMoveEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerMoveEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private Pos newPosition;
|
||||
|
@ -2,11 +2,12 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.network.packet.client.ClientPacket;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerPacketEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerPacketEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ClientPacket packet;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player send {@link net.minestom.server.network.packet.client.play.ClientPluginMessagePacket}.
|
||||
*/
|
||||
public class PlayerPluginMessageEvent implements PlayerEvent {
|
||||
public class PlayerPluginMessageEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
private final String identifier;
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -11,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* or to cancel its processing, cancelling the event means that the player will
|
||||
* continue the animation indefinitely.
|
||||
*/
|
||||
public class PlayerPreEatEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerPreEatEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final ItemStack foodItem;
|
||||
|
@ -1,11 +1,12 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.BlockEvent;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -16,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* (could be because of high latency or a modified client) so cancelling {@link PlayerBlockBreakEvent} is also necessary.
|
||||
* Could be fixed in future Minestom version.
|
||||
*/
|
||||
public class PlayerStartDiggingEvent implements PlayerEvent, BlockEvent, CancellableEvent {
|
||||
public class PlayerStartDiggingEvent implements PlayerEvent, EntityInstanceEvent, BlockEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Block block;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player start flying.
|
||||
*/
|
||||
public class PlayerStartFlyingEvent implements PlayerEvent {
|
||||
public class PlayerStartFlyingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerStartFlyingWithElytraEvent implements PlayerEvent {
|
||||
public class PlayerStartFlyingWithElytraEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player starts sneaking.
|
||||
*/
|
||||
public class PlayerStartSneakingEvent implements PlayerEvent {
|
||||
public class PlayerStartSneakingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player starts sprinting.
|
||||
*/
|
||||
public class PlayerStartSprintingEvent implements PlayerEvent {
|
||||
public class PlayerStartSprintingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player stop flying.
|
||||
*/
|
||||
public class PlayerStopFlyingEvent implements PlayerEvent {
|
||||
public class PlayerStopFlyingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlayerStopFlyingWithElytraEvent implements PlayerEvent {
|
||||
public class PlayerStopFlyingWithElytraEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player stops sneaking.
|
||||
*/
|
||||
public class PlayerStopSneakingEvent implements PlayerEvent {
|
||||
public class PlayerStopSneakingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called when a player stops sprinting.
|
||||
*/
|
||||
public class PlayerStopSprintingEvent implements PlayerEvent {
|
||||
public class PlayerStopSprintingEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -9,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Called when a player is trying to swap his main and off hand item.
|
||||
*/
|
||||
public class PlayerSwapItemEvent implements PlayerEvent, CancellableEvent {
|
||||
public class PlayerSwapItemEvent implements PlayerEvent, EntityInstanceEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private ItemStack mainHandItem;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Called at each player tick.
|
||||
*/
|
||||
public class PlayerTickEvent implements PlayerEvent {
|
||||
public class PlayerTickEvent implements PlayerEvent, EntityInstanceEvent {
|
||||
|
||||
private final Player player;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.CancellableEvent;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
import net.minestom.server.event.trait.ItemEvent;
|
||||
import net.minestom.server.event.trait.PlayerEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Event when an item is used without clicking on a block.
|
||||
*/
|
||||
public class PlayerUseItemEvent implements PlayerEvent, ItemEvent, CancellableEvent {
|
||||
public class PlayerUseItemEvent implements PlayerEvent, EntityInstanceEvent, ItemEvent, CancellableEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -1,17 +1,18 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.trait.EntityInstanceEvent;
|
||||
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.Direction;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
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, ItemEvent {
|
||||
public class PlayerUseItemOnBlockEvent implements PlayerEvent, EntityInstanceEvent, ItemEvent {
|
||||
|
||||
private final Player player;
|
||||
private final Player.Hand hand;
|
||||
|
@ -0,0 +1,23 @@
|
||||
package net.minestom.server.event.trait;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents an {@link EntityEvent} which happen in {@link Entity#getInstance()}.
|
||||
* Useful if you need to listen to entity events happening in its instance.
|
||||
* <p>
|
||||
* Be aware that the entity's instance must be non-null.
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
@ApiStatus.Experimental
|
||||
public interface EntityInstanceEvent extends EntityEvent, InstanceEvent {
|
||||
@Override
|
||||
default @NotNull Instance getInstance() {
|
||||
final Instance instance = getEntity().getInstance();
|
||||
assert instance != null : "EntityInstanceEvent is only supported on events where the entity's instance is non-null!";
|
||||
return instance;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user