Added annotations for all events

This commit is contained in:
themode 2020-10-24 16:33:13 +02:00
parent 2f21a7c233
commit 27e0b86cb5
54 changed files with 296 additions and 94 deletions

View File

@ -1624,6 +1624,11 @@ public class Player extends LivingEntity implements CommandSender {
Inventory newInventory = inventoryOpenEvent.getInventory();
if(newInventory == null){
// just close the inventory
return;
}
OpenWindowPacket openWindowPacket = new OpenWindowPacket();
openWindowPacket.windowId = newInventory.getWindowId();
openWindowPacket.windowType = newInventory.getInventoryType().getWindowType();

View File

@ -2,17 +2,18 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.Event;
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)}
* {@link net.minestom.server.entity.EntityCreature#attack(Entity)}.
*/
public class EntityAttackEvent extends Event {
private final Entity source;
private final Entity target;
public EntityAttackEvent(Entity source, Entity target) {
public EntityAttackEvent(@NotNull Entity source, @NotNull Entity target) {
this.source = source;
this.target = target;
}
@ -20,6 +21,7 @@ public class EntityAttackEvent extends Event {
/**
* @return the source of the attack
*/
@NotNull
public Entity getSource() {
return source;
}
@ -27,6 +29,7 @@ public class EntityAttackEvent extends Event {
/**
* @return the target of the attack
*/
@NotNull
public Entity getTarget() {
return target;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.LivingEntity;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called with {@link LivingEntity#damage(DamageType, float)}.
@ -13,7 +14,7 @@ public class EntityDamageEvent extends CancellableEvent {
private final DamageType damageType;
private float damage;
public EntityDamageEvent(LivingEntity entity, DamageType damageType, float damage) {
public EntityDamageEvent(@NotNull LivingEntity entity, @NotNull DamageType damageType, float damage) {
this.entity = entity;
this.damageType = damageType;
this.damage = damage;
@ -24,6 +25,7 @@ public class EntityDamageEvent extends CancellableEvent {
*
* @return the damaged entity
*/
@NotNull
public LivingEntity getEntity() {
return entity;
}
@ -33,6 +35,7 @@ public class EntityDamageEvent extends CancellableEvent {
*
* @return the damage type
*/
@NotNull
public DamageType getDamageType() {
return damageType;
}

View File

@ -2,13 +2,14 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
public class EntityDeathEvent extends Event {
private final Entity entity;
// TODO cause
public EntityDeathEvent(Entity entity) {
public EntityDeathEvent(@NotNull Entity entity) {
this.entity = entity;
}
@ -17,6 +18,7 @@ public class EntityDeathEvent extends Event {
*
* @return the entity that died
*/
@NotNull
public Entity getEntity() {
return entity;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.time.TimeUnit;
import org.jetbrains.annotations.NotNull;
public class EntityFireEvent extends CancellableEvent {
@ -15,6 +16,12 @@ public class EntityFireEvent extends CancellableEvent {
setFireTime(duration, timeUnit);
}
/**
* Gets the entity who got in fire.
*
* @return the entity
*/
@NotNull
public Entity getEntity() {
return entity;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.ItemEntity;
import net.minestom.server.event.CancellableEvent;
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.
@ -14,7 +15,7 @@ public class EntityItemMergeEvent extends CancellableEvent {
private ItemStack result;
public EntityItemMergeEvent(ItemEntity source, ItemEntity merged, ItemStack result) {
public EntityItemMergeEvent(@NotNull ItemEntity source, @NotNull ItemEntity merged, @NotNull ItemStack result) {
this.source = source;
this.merged = merged;
this.result = result;
@ -27,6 +28,7 @@ public class EntityItemMergeEvent extends CancellableEvent {
*
* @return the source ItemEntity
*/
@NotNull
public ItemEntity getSource() {
return source;
}
@ -38,6 +40,7 @@ public class EntityItemMergeEvent extends CancellableEvent {
*
* @return the merged ItemEntity
*/
@NotNull
public ItemEntity getMerged() {
return merged;
}
@ -47,6 +50,7 @@ public class EntityItemMergeEvent extends CancellableEvent {
*
* @return the item stack
*/
@NotNull
public ItemStack getResult() {
return result;
}
@ -56,7 +60,7 @@ public class EntityItemMergeEvent extends CancellableEvent {
*
* @param result the new item stack
*/
public void setResult(ItemStack result) {
public void setResult(@NotNull ItemStack result) {
this.result = result;
}
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.Event;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called when a new instance is set for an entity.
@ -12,7 +13,7 @@ public class EntitySpawnEvent extends Event {
private final Entity entity;
private final Instance spawnInstance;
public EntitySpawnEvent(Entity entity, Instance spawnInstance) {
public EntitySpawnEvent(@NotNull Entity entity, @NotNull Instance spawnInstance) {
this.entity = entity;
this.spawnInstance = spawnInstance;
}
@ -22,6 +23,7 @@ public class EntitySpawnEvent extends Event {
*
* @return the entity
*/
@NotNull
public Entity getEntity() {
return entity;
}
@ -31,6 +33,7 @@ public class EntitySpawnEvent extends Event {
*
* @return the instance
*/
@NotNull
public Instance getSpawnInstance() {
return spawnInstance;
}

View File

@ -2,19 +2,21 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when an entity ticks itself.
* Same instance used for all tick events for the same entity
* Same event instance used for all tick events for the same entity.
*/
public class EntityTickEvent extends Event {
private final Entity entity;
public EntityTickEvent(Entity entity) {
public EntityTickEvent(@NotNull Entity entity) {
this.entity = entity;
}
@NotNull
public Entity getEntity() {
return entity;
}

View File

@ -3,35 +3,47 @@ package net.minestom.server.event.entity;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.Vector;
import org.jetbrains.annotations.NotNull;
/**
* Called when a velocity is applied to an entity using {@link Entity#setVelocity(Vector)}.
*/
public class EntityVelocityEvent extends CancellableEvent {
private final Entity entity;
private Vector velocity;
public EntityVelocityEvent(Entity entity, Vector velocity) {
public EntityVelocityEvent(@NotNull Entity entity, @NotNull Vector velocity) {
this.entity = entity;
this.velocity = velocity;
}
/**
* @return the entity who the velocity is applied to
* Gets the enity who will be affected by {@link #getVelocity()}.
*
* @return the entity
*/
@NotNull
public Entity getEntity() {
return entity;
}
/**
* @return the velocity which will be applied
* Gets the velocity which will be applied.
*
* @return the velocity
*/
@NotNull
public Vector getVelocity() {
return velocity;
}
/**
* @param velocity the new velocity to applies
* Changes the applied velocity.
*
* @param velocity the new velocity
*/
public void setVelocity(Vector velocity) {
public void setVelocity(@NotNull Vector velocity) {
this.velocity = velocity;
}
}

View File

@ -3,33 +3,38 @@ package net.minestom.server.event.instance;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called by an Instance when an entity is added to it.
* Can be used attach data
* Can be used attach data.
*/
public class AddEntityToInstanceEvent extends CancellableEvent {
private final Instance instance;
private final Entity entity;
public AddEntityToInstanceEvent(Instance instance, Entity entity) {
public AddEntityToInstanceEvent(@NotNull Instance instance, @NotNull Entity entity) {
this.instance = instance;
this.entity = entity;
}
/**
* Entity being added
* @return entity being added
* Entity being added.
*
* @return the entity being added
*/
@NotNull
public Entity getEntity() {
return entity;
}
/**
* Instance in which the entity is being added
*
* @return instance in which the entity is being added
*/
@NotNull
public Instance getInstance() {
return instance;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.instance;
import net.minestom.server.event.Event;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called when a chunk in an instance is loaded.
@ -11,7 +12,7 @@ public class InstanceChunkLoadEvent extends Event {
private final Instance instance;
private final int chunkX, chunkZ;
public InstanceChunkLoadEvent(Instance instance, int chunkX, int chunkZ) {
public InstanceChunkLoadEvent(@NotNull Instance instance, int chunkX, int chunkZ) {
this.instance = instance;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
@ -22,6 +23,7 @@ public class InstanceChunkLoadEvent extends Event {
*
* @return the instance
*/
@NotNull
public Instance getInstance() {
return instance;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.instance;
import net.minestom.server.event.Event;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called when a chunk in an instance is unloaded.
@ -11,7 +12,7 @@ public class InstanceChunkUnloadEvent extends Event {
private final Instance instance;
private final int chunkX, chunkZ;
public InstanceChunkUnloadEvent(Instance instance, int chunkX, int chunkZ) {
public InstanceChunkUnloadEvent(@NotNull Instance instance, int chunkX, int chunkZ) {
this.instance = instance;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
@ -22,6 +23,7 @@ public class InstanceChunkUnloadEvent extends Event {
*
* @return the instance
*/
@NotNull
public Instance getInstance() {
return instance;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.instance;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called by an Instance when an entity is removed from it.
@ -12,23 +13,27 @@ public class RemoveEntityFromInstanceEvent extends CancellableEvent {
private final Instance instance;
private final Entity entity;
public RemoveEntityFromInstanceEvent(Instance instance, Entity entity) {
public RemoveEntityFromInstanceEvent(@NotNull Instance instance, @NotNull Entity entity) {
this.instance = instance;
this.entity = entity;
}
/**
* Entity being removed
* Gets the entity being removed.
*
* @return entity being removed
*/
@NotNull
public Entity getEntity() {
return entity;
}
/**
* Instance from which the entity is being removed
* Instance from which the entity is being removed.
*
* @return instance from which the entity is being removed
*/
@NotNull
public Instance getInstance() {
return instance;
}

View File

@ -5,6 +5,8 @@ import net.minestom.server.event.Event;
import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.click.ClickType;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called after {@link InventoryPreClickEvent}, this event cannot be cancelled and items related to the click
@ -19,7 +21,9 @@ public class InventoryClickEvent extends Event {
private final ItemStack clickedItem;
private final ItemStack cursorItem;
public InventoryClickEvent(Player player, Inventory inventory, int slot, ClickType clickType, ItemStack clicked, ItemStack cursor) {
public InventoryClickEvent(@NotNull Player player, Inventory inventory,
int slot, @NotNull ClickType clickType,
@NotNull ItemStack clicked, @NotNull ItemStack cursor) {
this.player = player;
this.inventory = inventory;
this.slot = slot;
@ -33,6 +37,7 @@ public class InventoryClickEvent extends Event {
*
* @return the player who clicked in the inventory
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -42,6 +47,7 @@ public class InventoryClickEvent extends Event {
*
* @return the inventory where the click happened, null if this is the player's inventory
*/
@Nullable
public Inventory getInventory() {
return inventory;
}
@ -60,6 +66,7 @@ public class InventoryClickEvent extends Event {
*
* @return the click type
*/
@NotNull
public ClickType getClickType() {
return clickType;
}
@ -69,6 +76,7 @@ public class InventoryClickEvent extends Event {
*
* @return the clicked item
*/
@NotNull
public ItemStack getClickedItem() {
return clickedItem;
}
@ -78,6 +86,7 @@ public class InventoryClickEvent extends Event {
*
* @return the cursor item
*/
@NotNull
public ItemStack getCursorItem() {
return cursorItem;
}

View File

@ -3,6 +3,8 @@ package net.minestom.server.event.inventory;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when an {@link Inventory} is closed by a player.
@ -13,7 +15,7 @@ public class InventoryCloseEvent extends Event {
private final Inventory inventory;
private Inventory newInventory;
public InventoryCloseEvent(Player player, Inventory inventory) {
public InventoryCloseEvent(@NotNull Player player, @Nullable Inventory inventory) {
this.player = player;
this.inventory = inventory;
}
@ -23,6 +25,7 @@ public class InventoryCloseEvent extends Event {
*
* @return the player who closed the inventory
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -32,6 +35,7 @@ public class InventoryCloseEvent extends Event {
*
* @return the closed inventory, null if this is the player inventory
*/
@Nullable
public Inventory getInventory() {
return inventory;
}
@ -41,6 +45,7 @@ public class InventoryCloseEvent extends Event {
*
* @return the new inventory to open, null if there isn't any
*/
@Nullable
public Inventory getNewInventory() {
return newInventory;
}
@ -50,7 +55,7 @@ public class InventoryCloseEvent extends Event {
*
* @param newInventory the inventory to open, null to do not open any
*/
public void setNewInventory(Inventory newInventory) {
public void setNewInventory(@Nullable Inventory newInventory) {
this.newInventory = newInventory;
}
}

View File

@ -3,6 +3,8 @@ package net.minestom.server.event.inventory;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called when a player open an {@link Inventory}.
@ -14,7 +16,7 @@ public class InventoryOpenEvent extends CancellableEvent {
private final Player player;
private Inventory inventory;
public InventoryOpenEvent(Player player, Inventory inventory) {
public InventoryOpenEvent(@NotNull Player player, @Nullable Inventory inventory) {
this.player = player;
this.inventory = inventory;
}
@ -24,6 +26,7 @@ public class InventoryOpenEvent extends CancellableEvent {
*
* @return the player who opens the inventory
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -31,8 +34,9 @@ public class InventoryOpenEvent extends CancellableEvent {
/**
* Gets the inventory to open, this could have been change by the {@link #setInventory(Inventory)}.
*
* @return the inventory to open
* @return the inventory to open, null to just close the current inventory if any
*/
@Nullable
public Inventory getInventory() {
return inventory;
}
@ -43,9 +47,8 @@ public class InventoryOpenEvent extends CancellableEvent {
* To do not open any inventory see {@link #setCancelled(boolean)}.
*
* @param inventory the inventory to open
* @throws NullPointerException if {@code inventory} is null
*/
public void setInventory(Inventory inventory) {
public void setInventory(@Nullable Inventory inventory) {
this.inventory = inventory;
}
}

View File

@ -2,15 +2,17 @@ package net.minestom.server.event.item;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class ItemDropEvent extends CancellableEvent {
private final ItemStack itemStack;
public ItemDropEvent(ItemStack itemStack) {
public ItemDropEvent(@NotNull ItemStack itemStack) {
this.itemStack = itemStack;
}
@NotNull
public ItemStack getItemStack() {
return itemStack;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.item;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class ItemUpdateStateEvent extends Event {
@ -11,20 +12,23 @@ public class ItemUpdateStateEvent extends Event {
private final ItemStack itemStack;
private boolean handAnimation;
public ItemUpdateStateEvent(Player player, Player.Hand hand, ItemStack itemStack) {
public ItemUpdateStateEvent(@NotNull Player player, @NotNull Player.Hand hand, @NotNull ItemStack itemStack) {
this.player = player;
this.hand = hand;
this.itemStack = itemStack;
}
@NotNull
public Player getPlayer() {
return player;
}
@NotNull
public Player.Hand getHand() {
return hand;
}
@NotNull
public ItemStack getItemStack() {
return itemStack;
}

View File

@ -2,17 +2,19 @@ package net.minestom.server.event.item;
import net.minestom.server.entity.ExperienceOrb;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
public class PickupExperienceEvent extends CancellableEvent {
private final ExperienceOrb experienceOrb;
private short experienceCount;
public PickupExperienceEvent(ExperienceOrb experienceOrb) {
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb) {
this.experienceOrb = experienceOrb;
this.experienceCount = experienceOrb.getExperienceCount();
}
@NotNull
public ExperienceOrb getExperienceOrb() {
return experienceOrb;
}

View File

@ -2,15 +2,17 @@ package net.minestom.server.event.item;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class PickupItemEvent extends CancellableEvent {
private final ItemStack itemStack;
public PickupItemEvent(ItemStack itemStack) {
public PickupItemEvent(@NotNull ItemStack itemStack) {
this.itemStack = itemStack;
}
@NotNull
public ItemStack getItemStack() {
return itemStack;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.advancements.AdvancementAction;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a {@link Player} opens the advancement screens or switch the tab
@ -14,7 +15,7 @@ public class AdvancementTabEvent extends Event {
private final AdvancementAction action;
private final String tabId;
public AdvancementTabEvent(Player player, AdvancementAction action, String tabId) {
public AdvancementTabEvent(@NotNull Player player, @NotNull AdvancementAction action, @NotNull String tabId) {
this.player = player;
this.action = action;
this.tabId = tabId;
@ -25,6 +26,7 @@ public class AdvancementTabEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -34,6 +36,7 @@ public class AdvancementTabEvent extends Event {
*
* @return the action
*/
@NotNull
public AdvancementAction getAction() {
return action;
}
@ -45,6 +48,7 @@ public class AdvancementTabEvent extends Event {
*
* @return the tab id
*/
@NotNull
public String getTabId() {
return tabId;
}

View File

@ -4,6 +4,8 @@ import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlayerBlockBreakEvent extends CancellableEvent {
@ -17,8 +19,8 @@ public class PlayerBlockBreakEvent extends CancellableEvent {
private short resultBlockStateId;
private short resultCustomBlockId;
public PlayerBlockBreakEvent(Player player, BlockPosition blockPosition,
short blockStateId, CustomBlock customBlock,
public PlayerBlockBreakEvent(@NotNull Player player, @NotNull BlockPosition blockPosition,
short blockStateId, @Nullable CustomBlock customBlock,
short resultBlockStateId, short resultCustomBlockId) {
this.player = player;
@ -36,6 +38,7 @@ public class PlayerBlockBreakEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -45,6 +48,7 @@ public class PlayerBlockBreakEvent extends CancellableEvent {
*
* @return the block position
*/
@NotNull
public BlockPosition getBlockPosition() {
return blockPosition;
}
@ -64,6 +68,7 @@ public class PlayerBlockBreakEvent extends CancellableEvent {
* @return the custom block,
* null if not any
*/
@Nullable
public CustomBlock getCustomBlock() {
return customBlock;
}

View File

@ -4,6 +4,7 @@ import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.block.BlockFace;
import net.minestom.server.utils.BlockPosition;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player interacts with a block (right-click).
@ -22,8 +23,8 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*/
private boolean blocksItemUse;
public PlayerBlockInteractEvent(Player player,
BlockPosition blockPosition, Player.Hand hand, BlockFace blockFace) {
public PlayerBlockInteractEvent(@NotNull Player player,
@NotNull BlockPosition blockPosition, @NotNull Player.Hand hand, @NotNull BlockFace blockFace) {
this.player = player;
this.blockPosition = blockPosition;
this.hand = hand;
@ -35,6 +36,7 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -57,6 +59,7 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*
* @return the block position
*/
@NotNull
public BlockPosition getBlockPosition() {
return blockPosition;
}
@ -66,6 +69,7 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*
* @return the hand used
*/
@NotNull
public Player.Hand getHand() {
return hand;
}
@ -75,6 +79,7 @@ public class PlayerBlockInteractEvent extends CancellableEvent {
*
* @return the block face
*/
@NotNull
public BlockFace getBlockFace() {
return blockFace;
}

View File

@ -6,6 +6,7 @@ import net.minestom.server.event.CancellableEvent;
import net.minestom.server.instance.block.BlockManager;
import net.minestom.server.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player tries placing a block.
@ -22,7 +23,8 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
private boolean consumeBlock;
public PlayerBlockPlaceEvent(Player player, short blockStateId, short customBlockId, BlockPosition blockPosition, Player.Hand hand) {
public PlayerBlockPlaceEvent(@NotNull Player player, short blockStateId, short customBlockId,
@NotNull BlockPosition blockPosition, @NotNull Player.Hand hand) {
this.player = player;
this.blockStateId = blockStateId;
this.customBlockId = customBlockId;
@ -36,7 +38,7 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
*
* @param customBlock the custom block to place
*/
public void setCustomBlock(CustomBlock customBlock) {
public void setCustomBlock(@NotNull CustomBlock customBlock) {
setBlockStateId(customBlock.getDefaultBlockStateId());
setCustomBlockId(customBlock.getCustomBlockId());
}
@ -56,7 +58,7 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
*
* @param customBlockId the custom block id to place
*/
public void setCustomBlock(String customBlockId) {
public void setCustomBlock(@NotNull String customBlockId) {
final CustomBlock customBlock = BLOCK_MANAGER.getCustomBlock(customBlockId);
setCustomBlock(customBlock);
}
@ -105,6 +107,7 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -114,6 +117,7 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
*
* @return the block position
*/
@NotNull
public BlockPosition getBlockPosition() {
return blockPosition;
}
@ -123,6 +127,7 @@ public class PlayerBlockPlaceEvent extends CancellableEvent {
*
* @return the hand used
*/
@NotNull
public Player.Hand getHand() {
return hand;
}

View File

@ -4,6 +4,7 @@ import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.MathUtils;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player change his held slot (by pressing 1-9 keys).
@ -13,7 +14,7 @@ public class PlayerChangeHeldSlotEvent extends CancellableEvent {
private final Player player;
private byte slot;
public PlayerChangeHeldSlotEvent(Player player, byte slot) {
public PlayerChangeHeldSlotEvent(@NotNull Player player, byte slot) {
this.player = player;
this.slot = slot;
}
@ -23,6 +24,7 @@ public class PlayerChangeHeldSlotEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.chat.RichMessage;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
@ -19,7 +20,7 @@ public class PlayerChatEvent extends CancellableEvent {
private String message;
private Function<PlayerChatEvent, RichMessage> chatFormat;
public PlayerChatEvent(Player sender, Collection<Player> recipients, String message) {
public PlayerChatEvent(@NotNull Player sender, @NotNull Collection<Player> recipients, @NotNull String message) {
this.sender = sender;
this.recipients = new ArrayList<>(recipients);
this.message = message;
@ -30,7 +31,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @param chatFormat the custom chat format
*/
public void setChatFormat(Function<PlayerChatEvent, RichMessage> chatFormat) {
public void setChatFormat(@NotNull Function<PlayerChatEvent, RichMessage> chatFormat) {
this.chatFormat = chatFormat;
}
@ -39,6 +40,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @return the sender
*/
@NotNull
public Player getSender() {
return sender;
}
@ -50,6 +52,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @return a modifiable list of message targets
*/
@NotNull
public Collection<Player> getRecipients() {
return recipients;
}
@ -59,6 +62,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @return the sender's message
*/
@NotNull
public String getMessage() {
return message;
}
@ -68,7 +72,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @param message the new message
*/
public void setMessage(String message) {
public void setMessage(@NotNull String message) {
this.message = message;
}
@ -79,6 +83,7 @@ public class PlayerChatEvent extends CancellableEvent {
*
* @return the chat format which will be used
*/
@NotNull
public Function<PlayerChatEvent, RichMessage> getChatFormatFunction() {
return chatFormat;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player receive a new chunk data.
@ -11,7 +12,7 @@ public class PlayerChunkLoadEvent extends Event {
private final Player player;
private final int chunkX, chunkZ;
public PlayerChunkLoadEvent(Player player, int chunkX, int chunkZ) {
public PlayerChunkLoadEvent(@NotNull Player player, int chunkX, int chunkZ) {
this.player = player;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
@ -22,6 +23,7 @@ public class PlayerChunkLoadEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called after a chunk being unload to a certain player.
@ -13,7 +14,7 @@ public class PlayerChunkUnloadEvent extends Event {
private final Player player;
private final int chunkX, chunkZ;
public PlayerChunkUnloadEvent(Player player, int chunkX, int chunkZ) {
public PlayerChunkUnloadEvent(@NotNull Player player, int chunkX, int chunkZ) {
this.player = player;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
@ -24,6 +25,7 @@ public class PlayerChunkUnloadEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called every time a player send a message starting by '/'.
@ -11,7 +12,7 @@ public class PlayerCommandEvent extends CancellableEvent {
private final Player player;
private String command;
public PlayerCommandEvent(Player player, String command) {
public PlayerCommandEvent(@NotNull Player player, @NotNull String command) {
this.player = player;
this.command = command;
}
@ -21,6 +22,7 @@ public class PlayerCommandEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -30,6 +32,7 @@ public class PlayerCommandEvent extends CancellableEvent {
*
* @return the command that the player wants to execute
*/
@NotNull
public String getCommand() {
return command;
}
@ -39,7 +42,7 @@ public class PlayerCommandEvent extends CancellableEvent {
*
* @param command the new command
*/
public void setCommand(String command) {
public void setCommand(@NotNull String command) {
this.command = command;
}
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player disconnect.
@ -10,7 +11,7 @@ public class PlayerDisconnectEvent extends Event {
private final Player player;
public PlayerDisconnectEvent(Player player) {
public PlayerDisconnectEvent(@NotNull Player player) {
this.player = player;
}
@ -19,6 +20,7 @@ public class PlayerDisconnectEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player is finished eating.
@ -12,7 +13,7 @@ public class PlayerEatEvent extends Event {
private final Player player;
private final ItemStack foodItem;
public PlayerEatEvent(Player player, ItemStack foodItem) {
public PlayerEatEvent(@NotNull Player player, @NotNull ItemStack foodItem) {
this.player = player;
this.foodItem = foodItem;
}
@ -22,6 +23,7 @@ public class PlayerEatEvent extends Event {
*
* @return the concerned player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -31,6 +33,7 @@ public class PlayerEatEvent extends Event {
*
* @return the food item
*/
@NotNull
public ItemStack getFoodItem() {
return foodItem;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a {@link Player} interacts (right-click) with an {@link Entity}.
@ -13,7 +14,7 @@ public class PlayerEntityInteractEvent extends Event {
private final Entity entityTarget;
private final Player.Hand hand;
public PlayerEntityInteractEvent(Player player, Entity entityTarget, Player.Hand hand) {
public PlayerEntityInteractEvent(@NotNull Player player, @NotNull Entity entityTarget, @NotNull Player.Hand hand) {
this.player = player;
this.entityTarget = entityTarget;
this.hand = hand;
@ -24,6 +25,7 @@ public class PlayerEntityInteractEvent extends Event {
*
* @return the {@link Player}
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -33,6 +35,7 @@ public class PlayerEntityInteractEvent extends Event {
*
* @return the {@link Entity}
*/
@NotNull
public Entity getTarget() {
return entityTarget;
}
@ -42,6 +45,7 @@ public class PlayerEntityInteractEvent extends Event {
*
* @return the hand
*/
@NotNull
public Player.Hand getHand() {
return hand;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called when the player swings his hand.
@ -11,7 +12,7 @@ public class PlayerHandAnimationEvent extends CancellableEvent {
private final Player player;
private final Player.Hand hand;
public PlayerHandAnimationEvent(Player player, Player.Hand hand) {
public PlayerHandAnimationEvent(@NotNull Player player, @NotNull Player.Hand hand) {
this.player = player;
this.hand = hand;
}
@ -21,6 +22,7 @@ public class PlayerHandAnimationEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -30,6 +32,7 @@ public class PlayerHandAnimationEvent extends CancellableEvent {
*
* @return the hand
*/
@NotNull
public Player.Hand getHand() {
return hand;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import org.jetbrains.annotations.NotNull;
/**
* Used when a {@link Player} finish the animation of an item.
@ -13,7 +14,7 @@ public class PlayerItemAnimationEvent extends CancellableEvent {
private final Player player;
private final ItemAnimationType armAnimationType;
public PlayerItemAnimationEvent(Player player, ItemAnimationType armAnimationType) {
public PlayerItemAnimationEvent(@NotNull Player player, @NotNull ItemAnimationType armAnimationType) {
this.player = player;
this.armAnimationType = armAnimationType;
}
@ -23,6 +24,7 @@ public class PlayerItemAnimationEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -32,6 +34,7 @@ public class PlayerItemAnimationEvent extends CancellableEvent {
*
* @return the animation
*/
@NotNull
public ItemAnimationType getArmAnimationType() {
return armAnimationType;
}

View File

@ -3,6 +3,8 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called at player login, used to define his spawn instance.
@ -14,7 +16,7 @@ public class PlayerLoginEvent extends Event {
private final Player player;
private Instance spawningInstance;
public PlayerLoginEvent(Player player) {
public PlayerLoginEvent(@NotNull Player player) {
this.player = player;
}
@ -23,6 +25,7 @@ public class PlayerLoginEvent extends Event {
*
* @return the player who is logging
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -34,6 +37,7 @@ public class PlayerLoginEvent extends Event {
*
* @return the spawning instance
*/
@Nullable
public Instance getSpawningInstance() {
return spawningInstance;
}
@ -43,7 +47,7 @@ public class PlayerLoginEvent extends Event {
*
* @param instance the new spawning instance
*/
public void setSpawningInstance(Instance instance) {
public void setSpawningInstance(@NotNull Instance instance) {
this.spawningInstance = instance;
}
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player is modifying his position.
@ -12,7 +13,7 @@ public class PlayerMoveEvent extends CancellableEvent {
private final Player player;
private Position newPosition;
public PlayerMoveEvent(Player player, Position newPosition) {
public PlayerMoveEvent(@NotNull Player player, @NotNull Position newPosition) {
this.player = player;
this.newPosition = newPosition;
}
@ -22,6 +23,7 @@ public class PlayerMoveEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -31,6 +33,7 @@ public class PlayerMoveEvent extends CancellableEvent {
*
* @return the new position
*/
@NotNull
public Position getNewPosition() {
return newPosition;
}
@ -40,7 +43,7 @@ public class PlayerMoveEvent extends CancellableEvent {
*
* @param newPosition the new target position
*/
public void setNewPosition(Position newPosition) {
public void setNewPosition(@NotNull Position newPosition) {
this.newPosition = newPosition;
}
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player send {@link net.minestom.server.network.packet.client.play.ClientPluginMessagePacket}.
@ -12,7 +13,7 @@ public class PlayerPluginMessageEvent extends Event {
private final String identifier;
private final byte[] message;
public PlayerPluginMessageEvent(Player player, String identifier, byte[] message) {
public PlayerPluginMessageEvent(@NotNull Player player, @NotNull String identifier, @NotNull byte[] message) {
this.player = player;
this.identifier = identifier;
this.message = message;
@ -23,6 +24,7 @@ public class PlayerPluginMessageEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -32,6 +34,7 @@ public class PlayerPluginMessageEvent extends Event {
*
* @return the identifier
*/
@NotNull
public String getIdentifier() {
return identifier;
}
@ -41,6 +44,7 @@ public class PlayerPluginMessageEvent extends Event {
*
* @return the message
*/
@NotNull
public byte[] getMessage() {
return message;
}
@ -50,6 +54,7 @@ public class PlayerPluginMessageEvent extends Event {
*
* @return the message
*/
@NotNull
public String getMessageString() {
return new String(message);
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called before the PlayerEatEvent and can be used to change the eating time
@ -15,7 +16,7 @@ public class PlayerPreEatEvent extends CancellableEvent {
private final ItemStack foodItem;
private long eatingTime;
public PlayerPreEatEvent(Player player, ItemStack foodItem, long eatingTime) {
public PlayerPreEatEvent(@NotNull Player player, @NotNull ItemStack foodItem, long eatingTime) {
this.player = player;
this.foodItem = foodItem;
this.eatingTime = eatingTime;
@ -26,6 +27,7 @@ public class PlayerPreEatEvent extends CancellableEvent {
*
* @return the concerned player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -35,6 +37,7 @@ public class PlayerPreEatEvent extends CancellableEvent {
*
* @return the food item
*/
@NotNull
public ItemStack getFoodItem() {
return foodItem;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.utils.validate.Check;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
@ -16,7 +17,7 @@ public class PlayerPreLoginEvent extends Event {
private String username;
private UUID playerUuid;
public PlayerPreLoginEvent(Player player, String username, UUID playerUuid) {
public PlayerPreLoginEvent(@NotNull Player player, @NotNull String username, @NotNull UUID playerUuid) {
this.player = player;
this.username = username;
this.playerUuid = playerUuid;
@ -27,6 +28,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -36,6 +38,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return the player username
*/
@NotNull
public String getUsername() {
return username;
}
@ -45,7 +48,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @param username the new player username
*/
public void setUsername(String username) {
public void setUsername(@NotNull String username) {
Check.notNull(username, "The player username cannot be null");
this.username = username;
}
@ -55,6 +58,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @return the player uuid
*/
@NotNull
public UUID getPlayerUuid() {
return playerUuid;
}
@ -64,7 +68,7 @@ public class PlayerPreLoginEvent extends Event {
*
* @param playerUuid the new player uuid
*/
public void setPlayerUuid(UUID playerUuid) {
public void setPlayerUuid(@NotNull UUID playerUuid) {
Check.notNull(playerUuid, "The player uuid cannot be null");
this.playerUuid = playerUuid;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.resourcepack.ResourcePackStatus;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player warns the server of a resource pack status.
@ -12,7 +13,7 @@ public class PlayerResourcePackStatusEvent extends Event {
private final Player player;
private final ResourcePackStatus status;
public PlayerResourcePackStatusEvent(Player player, ResourcePackStatus status) {
public PlayerResourcePackStatusEvent(@NotNull Player player, @NotNull ResourcePackStatus status) {
this.player = player;
this.status = status;
}
@ -22,6 +23,7 @@ public class PlayerResourcePackStatusEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -31,6 +33,7 @@ public class PlayerResourcePackStatusEvent extends Event {
*
* @return the resource pack status
*/
@NotNull
public ResourcePackStatus getStatus() {
return status;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull;
/**
* Called when {@link Player#respawn()} is executed (for custom respawn or as a result of
@ -13,7 +14,7 @@ public class PlayerRespawnEvent extends Event {
private final Player player;
private Position respawnPosition;
public PlayerRespawnEvent(Player player) {
public PlayerRespawnEvent(@NotNull Player player) {
this.player = player;
this.respawnPosition = player.getRespawnPoint();
}
@ -23,6 +24,7 @@ public class PlayerRespawnEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -34,6 +36,7 @@ public class PlayerRespawnEvent extends Event {
*
* @return the respawn position
*/
@NotNull
public Position getRespawnPosition() {
return respawnPosition;
}
@ -43,7 +46,7 @@ public class PlayerRespawnEvent extends Event {
*
* @param respawnPosition the new respawn position
*/
public void setRespawnPosition(Position respawnPosition) {
public void setRespawnPosition(@NotNull Position respawnPosition) {
this.respawnPosition = respawnPosition;
}
}

View File

@ -3,6 +3,8 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.entity.PlayerSkin;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Called at the player connection to initialize his skin.
@ -12,7 +14,7 @@ public class PlayerSkinInitEvent extends Event {
private final Player player;
private PlayerSkin skin;
public PlayerSkinInitEvent(Player player) {
public PlayerSkinInitEvent(@NotNull Player player) {
this.player = player;
}
@ -21,6 +23,7 @@ public class PlayerSkinInitEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -30,6 +33,7 @@ public class PlayerSkinInitEvent extends Event {
*
* @return the player skin, or null if not any
*/
@Nullable
public PlayerSkin getSkin() {
return skin;
}
@ -39,7 +43,7 @@ public class PlayerSkinInitEvent extends Event {
*
* @param skin the new player skin
*/
public void setSkin(PlayerSkin skin) {
public void setSkin(@Nullable PlayerSkin skin) {
this.skin = skin;
}
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Entity;
import net.minestom.server.event.entity.EntitySpawnEvent;
import net.minestom.server.instance.Instance;
import org.jetbrains.annotations.NotNull;
/**
* Called when a new instance is set for a player
@ -11,7 +12,7 @@ public class PlayerSpawnEvent extends EntitySpawnEvent {
private final boolean firstSpawn;
public PlayerSpawnEvent(Entity entity, Instance spawnInstance, boolean firstSpawn) {
public PlayerSpawnEvent(@NotNull Entity entity, @NotNull Instance spawnInstance, boolean firstSpawn) {
super(entity, spawnInstance);
this.firstSpawn = firstSpawn;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.BlockPosition;
import org.jetbrains.annotations.NotNull;
/**
* Called when a {@link Player} start digging a block,
@ -15,7 +16,7 @@ public class PlayerStartDiggingEvent extends CancellableEvent {
private final int blockStateId;
private final int customBlockId;
public PlayerStartDiggingEvent(Player player, BlockPosition blockPosition, int blockStateId, int customBlockId) {
public PlayerStartDiggingEvent(@NotNull Player player, @NotNull BlockPosition blockPosition, int blockStateId, int customBlockId) {
this.player = player;
this.blockPosition = blockPosition;
this.blockStateId = blockStateId;
@ -27,6 +28,7 @@ public class PlayerStartDiggingEvent extends CancellableEvent {
*
* @return the {@link Player}
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -36,6 +38,7 @@ public class PlayerStartDiggingEvent extends CancellableEvent {
*
* @return the {@link BlockPosition}
*/
@NotNull
public BlockPosition getBlockPosition() {
return blockPosition;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player start flying.
@ -10,7 +11,7 @@ public class PlayerStartFlyingEvent extends Event {
private final Player player;
public PlayerStartFlyingEvent(Player player) {
public PlayerStartFlyingEvent(@NotNull Player player) {
this.player = player;
}
@ -19,6 +20,7 @@ public class PlayerStartFlyingEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player stop flying.
@ -10,7 +11,7 @@ public class PlayerStopFlyingEvent extends Event {
private final Player player;
public PlayerStopFlyingEvent(Player player) {
public PlayerStopFlyingEvent(@NotNull Player player) {
this.player = player;
}
@ -19,6 +20,7 @@ public class PlayerStopFlyingEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player is trying to swap his main and off hand item.
@ -13,7 +14,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
private ItemStack mainHandItem;
private ItemStack offHandItem;
public PlayerSwapItemEvent(Player player, ItemStack mainHandItem, ItemStack offHandItem) {
public PlayerSwapItemEvent(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) {
this.player = player;
this.mainHandItem = mainHandItem;
this.offHandItem = offHandItem;
@ -24,6 +25,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -33,6 +35,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
*
* @return the item in main hand
*/
@NotNull
public ItemStack getMainHandItem() {
return mainHandItem;
}
@ -42,7 +45,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
*
* @param mainHandItem the main hand item
*/
public void setMainHandItem(ItemStack mainHandItem) {
public void setMainHandItem(@NotNull ItemStack mainHandItem) {
this.mainHandItem = mainHandItem;
}
@ -51,6 +54,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
*
* @return the item in off hand
*/
@NotNull
public ItemStack getOffHandItem() {
return offHandItem;
}
@ -60,7 +64,7 @@ public class PlayerSwapItemEvent extends CancellableEvent {
*
* @param offHandItem the off hand item
*/
public void setOffHandItem(ItemStack offHandItem) {
public void setOffHandItem(@NotNull ItemStack offHandItem) {
this.offHandItem = offHandItem;
}
}

View File

@ -2,6 +2,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
import org.jetbrains.annotations.NotNull;
/**
* Called at each player tick.
@ -10,7 +11,7 @@ public class PlayerTickEvent extends Event {
private final Player player;
public PlayerTickEvent(Player player) {
public PlayerTickEvent(@NotNull Player player) {
this.player = player;
}
@ -19,6 +20,7 @@ public class PlayerTickEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}

View File

@ -3,6 +3,7 @@ package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Event when an item is used without clicking on a block.
@ -13,7 +14,7 @@ public class PlayerUseItemEvent extends CancellableEvent {
private final Player.Hand hand;
private final ItemStack itemStack;
public PlayerUseItemEvent(Player player, Player.Hand hand, ItemStack itemStack) {
public PlayerUseItemEvent(@NotNull Player player, @NotNull Player.Hand hand, @NotNull ItemStack itemStack) {
this.player = player;
this.hand = hand;
this.itemStack = itemStack;
@ -24,6 +25,7 @@ public class PlayerUseItemEvent extends CancellableEvent {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -33,6 +35,7 @@ public class PlayerUseItemEvent extends CancellableEvent {
*
* @return the hand used
*/
@NotNull
public Player.Hand getHand() {
return hand;
}
@ -42,6 +45,7 @@ public class PlayerUseItemEvent extends CancellableEvent {
*
* @return the item
*/
@NotNull
public ItemStack getItemStack() {
return itemStack;
}

View File

@ -5,6 +5,7 @@ import net.minestom.server.event.Event;
import net.minestom.server.item.ItemStack;
import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.Direction;
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).
@ -17,7 +18,9 @@ public class PlayerUseItemOnBlockEvent extends Event {
private final BlockPosition position;
private final Direction blockFace;
public PlayerUseItemOnBlockEvent(Player player, Player.Hand hand, ItemStack itemStack, BlockPosition position, Direction blockFace) {
public PlayerUseItemOnBlockEvent(@NotNull Player player, @NotNull Player.Hand hand,
@NotNull ItemStack itemStack,
@NotNull BlockPosition position, @NotNull Direction blockFace) {
this.player = player;
this.hand = hand;
this.itemStack = itemStack;
@ -30,6 +33,7 @@ public class PlayerUseItemOnBlockEvent extends Event {
*
* @return the player
*/
@NotNull
public Player getPlayer() {
return player;
}
@ -39,6 +43,7 @@ public class PlayerUseItemOnBlockEvent extends Event {
*
* @return the block position
*/
@NotNull
public BlockPosition getPosition() {
return position;
}
@ -48,6 +53,7 @@ public class PlayerUseItemOnBlockEvent extends Event {
*
* @return the block face
*/
@NotNull
public Direction getBlockFace() {
return blockFace;
}
@ -57,6 +63,7 @@ public class PlayerUseItemOnBlockEvent extends Event {
*
* @return the hand
*/
@NotNull
public Player.Hand getHand() {
return hand;
}
@ -66,6 +73,7 @@ public class PlayerUseItemOnBlockEvent extends Event {
*
* @return the item
*/
@NotNull
public ItemStack getItemStack() {
return itemStack;
}

View File

@ -2,15 +2,17 @@ package net.minestom.server.event.player;
import net.minestom.server.event.Event;
import net.minestom.server.network.packet.server.play.TagsPacket;
import org.jetbrains.annotations.NotNull;
public class UpdateTagListEvent extends Event {
private TagsPacket packet;
public UpdateTagListEvent(TagsPacket packet) {
public UpdateTagListEvent(@NotNull TagsPacket packet) {
this.packet = packet;
}
@NotNull
public TagsPacket getTags() {
return packet;
}

View File

@ -5,6 +5,7 @@ import net.minestom.server.entity.Player;
import net.minestom.server.network.PacketWriterUtils;
import net.minestom.server.network.packet.server.play.WorldBorderPacket;
import net.minestom.server.utils.Position;
import org.jetbrains.annotations.NotNull;
/**
* Represents the world border of an {@link Instance},
@ -175,7 +176,8 @@ public class WorldBorder {
* @param position the position to check
* @return the axis where the position collides with the world border
*/
public CollisionAxis getCollisionAxis(Position position) {
@NotNull
public CollisionAxis getCollisionAxis(@NotNull Position position) {
final double radius = getDiameter() / 2d;
final boolean checkX = position.getX() <= getCenterX() + radius && position.getX() >= getCenterX() - radius;
final boolean checkZ = position.getZ() <= getCenterZ() + radius && position.getZ() >= getCenterZ() - radius;
@ -195,7 +197,7 @@ public class WorldBorder {
* @param position the position to check
* @return true if {@code position} is inside the world border, false otherwise
*/
public boolean isInside(Position position) {
public boolean isInside(@NotNull Position position) {
return getCollisionAxis(position) == CollisionAxis.NONE;
}
@ -205,7 +207,7 @@ public class WorldBorder {
* @param entity the entity to check
* @return true if {@code entity} is inside the world border, false otherwise
*/
public boolean isInside(Entity entity) {
public boolean isInside(@NotNull Entity entity) {
return isInside(entity.getPosition());
}
@ -237,7 +239,7 @@ public class WorldBorder {
*
* @param player the player to send the packet to
*/
protected void init(Player player) {
protected void init(@NotNull Player player) {
WorldBorderPacket worldBorderPacket = new WorldBorderPacket();
worldBorderPacket.action = WorldBorderPacket.Action.INITIALIZE;
worldBorderPacket.wbAction = new WorldBorderPacket.WBInitialize(centerX, centerZ, oldDiameter, newDiameter, speed,
@ -250,6 +252,7 @@ public class WorldBorder {
*
* @return the {@link Instance} of this world border
*/
@NotNull
public Instance getInstance() {
return instance;
}

View File

@ -1,6 +1,7 @@
package net.minestom.server.utils;
import it.unimi.dsi.fastutil.ints.IntList;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
@ -10,7 +11,7 @@ public final class ArrayUtils {
}
public static byte[] concenateByteArrays(byte[]... arrays) {
public static byte[] concatenateByteArrays(@NotNull byte[]... arrays) {
int totalLength = 0;
for (byte[] array : arrays) {
totalLength += array.length;
@ -25,7 +26,7 @@ public final class ArrayUtils {
return result;
}
public static void removeElement(Object[] arr, int index) {
public static void removeElement(@NotNull Object[] arr, int index) {
System.arraycopy(arr, index + 1, arr, index, arr.length - 1 - index);
}
@ -36,7 +37,8 @@ public final class ArrayUtils {
* @param b the second array
* @return an array containing a's indexes that aren't in b array
*/
public static int[] getDifferencesBetweenArray(long[] a, long[] b) {
@NotNull
public static int[] getDifferencesBetweenArray(@NotNull long[] a, @NotNull long[] b) {
int counter = 0;
int[] indexes = new int[Math.max(a.length, b.length)];
@ -60,7 +62,8 @@ public final class ArrayUtils {
return result;
}
public static int[] toArray(IntList list) {
@NotNull
public static int[] toArray(@NotNull IntList list) {
int[] array = new int[list.size()];
for (int i = 0; i < array.length; i++) {
array[i] = list.getInt(i);
@ -69,13 +72,14 @@ public final class ArrayUtils {
}
/**
* Fills an array by a supplier.
* Fills an array using a supplier.
*
* @param array the array to fill
* @param supplier the supplier to fill the array
* @param <T> the array type
*/
public static <T> void fill(T[] array, Supplier<T> supplier) {
@NotNull
public static <T> void fill(@NotNull T[] array, @NotNull Supplier<T> supplier) {
for (int i = 0; i < array.length; i++) {
array[i] = supplier.get();
}

View File

@ -1,5 +1,7 @@
package net.minestom.server.utils;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
// TODO: pool block positions?
@ -47,7 +49,7 @@ public class BlockPosition {
* @param position the position vector
* @see #BlockPosition(float, float, float)
*/
public BlockPosition(Vector position) {
public BlockPosition(@NotNull Vector position) {
this(position.getX(), position.getY(), position.getZ());
}
@ -59,6 +61,7 @@ public class BlockPosition {
* @param z the Z offset
* @return the instance of this block position
*/
@NotNull
public BlockPosition add(int x, int y, int z) {
this.x += x;
this.y += y;
@ -74,6 +77,7 @@ public class BlockPosition {
* @param z the Z offset
* @return the instance of this block position
*/
@NotNull
public BlockPosition subtract(int x, int y, int z) {
this.x -= x;
this.y -= y;
@ -87,7 +91,8 @@ public class BlockPosition {
* @param pos the pos to add
* @return the instance of this block position
*/
public BlockPosition add(BlockPosition pos) {
@NotNull
public BlockPosition add(@NotNull BlockPosition pos) {
this.x += pos.getX();
this.y += pos.getY();
this.z += pos.getZ();
@ -100,7 +105,8 @@ public class BlockPosition {
* @param pos the pos to subtract
* @return the instance of this block position
*/
public BlockPosition subtract(BlockPosition pos) {
@NotNull
public BlockPosition subtract(@NotNull BlockPosition pos) {
this.x -= pos.getX();
this.y -= pos.getY();
this.z -= pos.getZ();
@ -173,7 +179,7 @@ public class BlockPosition {
* @param blockPosition the block position to check the distance
* @return the distance between 'this' and {@code blockPosition}
*/
public int getDistance(BlockPosition blockPosition) {
public int getDistance(@NotNull BlockPosition blockPosition) {
return Math.abs(getX() - blockPosition.getX()) +
Math.abs(getY() - blockPosition.getY()) +
Math.abs(getZ() - blockPosition.getZ());
@ -184,6 +190,7 @@ public class BlockPosition {
*
* @return the cloned block position
*/
@NotNull
public BlockPosition clone() {
return new BlockPosition(x, y, z);
}
@ -193,6 +200,7 @@ public class BlockPosition {
*
* @return the converted {@link Position}
*/
@NotNull
public Position toPosition() {
return new Position(x, y, z);
}