diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index 381e670bc..b8dc36068 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -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(); diff --git a/src/main/java/net/minestom/server/event/entity/EntityAttackEvent.java b/src/main/java/net/minestom/server/event/entity/EntityAttackEvent.java index 2c20758e0..f23f527f1 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityAttackEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityAttackEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityDamageEvent.java b/src/main/java/net/minestom/server/event/entity/EntityDamageEvent.java index 54e9bc324..256632fd4 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityDamageEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityDamageEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityDeathEvent.java b/src/main/java/net/minestom/server/event/entity/EntityDeathEvent.java index 8ea84ef4b..cb18c8981 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityDeathEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityDeathEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityFireEvent.java b/src/main/java/net/minestom/server/event/entity/EntityFireEvent.java index 40a0def37..17b760710 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityFireEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityFireEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityItemMergeEvent.java b/src/main/java/net/minestom/server/event/entity/EntityItemMergeEvent.java index cffc66a4c..cb234c3cc 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityItemMergeEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityItemMergeEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/entity/EntitySpawnEvent.java b/src/main/java/net/minestom/server/event/entity/EntitySpawnEvent.java index 8051f6da3..fc2c69836 100644 --- a/src/main/java/net/minestom/server/event/entity/EntitySpawnEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntitySpawnEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityTickEvent.java b/src/main/java/net/minestom/server/event/entity/EntityTickEvent.java index cdb69b3cd..5abc288fe 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityTickEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityTickEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/entity/EntityVelocityEvent.java b/src/main/java/net/minestom/server/event/entity/EntityVelocityEvent.java index 4961ab180..fa09f1176 100644 --- a/src/main/java/net/minestom/server/event/entity/EntityVelocityEvent.java +++ b/src/main/java/net/minestom/server/event/entity/EntityVelocityEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/instance/AddEntityToInstanceEvent.java b/src/main/java/net/minestom/server/event/instance/AddEntityToInstanceEvent.java index 31a798776..21da230b0 100644 --- a/src/main/java/net/minestom/server/event/instance/AddEntityToInstanceEvent.java +++ b/src/main/java/net/minestom/server/event/instance/AddEntityToInstanceEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/instance/InstanceChunkLoadEvent.java b/src/main/java/net/minestom/server/event/instance/InstanceChunkLoadEvent.java index cc55a4456..3fe385778 100644 --- a/src/main/java/net/minestom/server/event/instance/InstanceChunkLoadEvent.java +++ b/src/main/java/net/minestom/server/event/instance/InstanceChunkLoadEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/instance/InstanceChunkUnloadEvent.java b/src/main/java/net/minestom/server/event/instance/InstanceChunkUnloadEvent.java index ee10adf35..f354d67ee 100644 --- a/src/main/java/net/minestom/server/event/instance/InstanceChunkUnloadEvent.java +++ b/src/main/java/net/minestom/server/event/instance/InstanceChunkUnloadEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/instance/RemoveEntityFromInstanceEvent.java b/src/main/java/net/minestom/server/event/instance/RemoveEntityFromInstanceEvent.java index 5a28b8786..55f83bc4f 100644 --- a/src/main/java/net/minestom/server/event/instance/RemoveEntityFromInstanceEvent.java +++ b/src/main/java/net/minestom/server/event/instance/RemoveEntityFromInstanceEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/inventory/InventoryClickEvent.java b/src/main/java/net/minestom/server/event/inventory/InventoryClickEvent.java index 5169c456d..f3c3ce4a6 100644 --- a/src/main/java/net/minestom/server/event/inventory/InventoryClickEvent.java +++ b/src/main/java/net/minestom/server/event/inventory/InventoryClickEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/inventory/InventoryCloseEvent.java b/src/main/java/net/minestom/server/event/inventory/InventoryCloseEvent.java index e5739dcc6..81b94df32 100644 --- a/src/main/java/net/minestom/server/event/inventory/InventoryCloseEvent.java +++ b/src/main/java/net/minestom/server/event/inventory/InventoryCloseEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/inventory/InventoryOpenEvent.java b/src/main/java/net/minestom/server/event/inventory/InventoryOpenEvent.java index 27d1b3068..574aa4a1f 100644 --- a/src/main/java/net/minestom/server/event/inventory/InventoryOpenEvent.java +++ b/src/main/java/net/minestom/server/event/inventory/InventoryOpenEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/item/ItemDropEvent.java b/src/main/java/net/minestom/server/event/item/ItemDropEvent.java index ed3988b51..32ff8d743 100644 --- a/src/main/java/net/minestom/server/event/item/ItemDropEvent.java +++ b/src/main/java/net/minestom/server/event/item/ItemDropEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/item/ItemUpdateStateEvent.java b/src/main/java/net/minestom/server/event/item/ItemUpdateStateEvent.java index 52bfa3389..201602499 100644 --- a/src/main/java/net/minestom/server/event/item/ItemUpdateStateEvent.java +++ b/src/main/java/net/minestom/server/event/item/ItemUpdateStateEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java b/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java index 615192c93..9bb212a02 100644 --- a/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java +++ b/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/item/PickupItemEvent.java b/src/main/java/net/minestom/server/event/item/PickupItemEvent.java index 4cdfd05c6..a914a681e 100644 --- a/src/main/java/net/minestom/server/event/item/PickupItemEvent.java +++ b/src/main/java/net/minestom/server/event/item/PickupItemEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/AdvancementTabEvent.java b/src/main/java/net/minestom/server/event/player/AdvancementTabEvent.java index baad3067c..ea725ac49 100644 --- a/src/main/java/net/minestom/server/event/player/AdvancementTabEvent.java +++ b/src/main/java/net/minestom/server/event/player/AdvancementTabEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerBlockBreakEvent.java b/src/main/java/net/minestom/server/event/player/PlayerBlockBreakEvent.java index 187ce3a0a..f4918f2d2 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerBlockBreakEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerBlockBreakEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java index 7837108eb..233a03901 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerBlockPlaceEvent.java b/src/main/java/net/minestom/server/event/player/PlayerBlockPlaceEvent.java index f57e37ebe..5db541ece 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerBlockPlaceEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerBlockPlaceEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerChangeHeldSlotEvent.java b/src/main/java/net/minestom/server/event/player/PlayerChangeHeldSlotEvent.java index 85fe14b67..4ef36cfec 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerChangeHeldSlotEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerChangeHeldSlotEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerChatEvent.java b/src/main/java/net/minestom/server/event/player/PlayerChatEvent.java index e7bd89194..744f04767 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerChatEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerChatEvent.java @@ -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 chatFormat; - public PlayerChatEvent(Player sender, Collection recipients, String message) { + public PlayerChatEvent(@NotNull Player sender, @NotNull Collection 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 chatFormat) { + public void setChatFormat(@NotNull Function 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 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 getChatFormatFunction() { return chatFormat; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerChunkLoadEvent.java b/src/main/java/net/minestom/server/event/player/PlayerChunkLoadEvent.java index 586015e1a..bb66cfb14 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerChunkLoadEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerChunkLoadEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerChunkUnloadEvent.java b/src/main/java/net/minestom/server/event/player/PlayerChunkUnloadEvent.java index c7b047b45..137fb7f99 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerChunkUnloadEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerChunkUnloadEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerCommandEvent.java b/src/main/java/net/minestom/server/event/player/PlayerCommandEvent.java index eff53528e..0309c67ea 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerCommandEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerCommandEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerDisconnectEvent.java b/src/main/java/net/minestom/server/event/player/PlayerDisconnectEvent.java index e12df6004..5f8778c04 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerDisconnectEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerDisconnectEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerEatEvent.java b/src/main/java/net/minestom/server/event/player/PlayerEatEvent.java index 909524bea..516017f53 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerEatEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerEatEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerEntityInteractEvent.java b/src/main/java/net/minestom/server/event/player/PlayerEntityInteractEvent.java index fb5b39efb..385e7c6a0 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerEntityInteractEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerEntityInteractEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerHandAnimationEvent.java b/src/main/java/net/minestom/server/event/player/PlayerHandAnimationEvent.java index 0a80ad4e3..67ee657af 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerHandAnimationEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerHandAnimationEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerItemAnimationEvent.java b/src/main/java/net/minestom/server/event/player/PlayerItemAnimationEvent.java index 859069d60..cf4f9792b 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerItemAnimationEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerItemAnimationEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerLoginEvent.java b/src/main/java/net/minestom/server/event/player/PlayerLoginEvent.java index 61424e1ad..c4faa5e63 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerLoginEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerLoginEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerMoveEvent.java b/src/main/java/net/minestom/server/event/player/PlayerMoveEvent.java index 5a80d3f30..1ec41a584 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerMoveEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerMoveEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerPluginMessageEvent.java b/src/main/java/net/minestom/server/event/player/PlayerPluginMessageEvent.java index 91d712cc5..3f7a74e68 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerPluginMessageEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerPluginMessageEvent.java @@ -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); } diff --git a/src/main/java/net/minestom/server/event/player/PlayerPreEatEvent.java b/src/main/java/net/minestom/server/event/player/PlayerPreEatEvent.java index 9e3bc2c4b..a2c06c4bb 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerPreEatEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerPreEatEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerPreLoginEvent.java b/src/main/java/net/minestom/server/event/player/PlayerPreLoginEvent.java index 7c1eb3072..1db457ab3 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerPreLoginEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerPreLoginEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/net/minestom/server/event/player/PlayerResourcePackStatusEvent.java index 57b7ff4d2..2ad6e5068 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerResourcePackStatusEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerResourcePackStatusEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerRespawnEvent.java b/src/main/java/net/minestom/server/event/player/PlayerRespawnEvent.java index cc5aac898..00039316c 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerRespawnEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerRespawnEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerSkinInitEvent.java b/src/main/java/net/minestom/server/event/player/PlayerSkinInitEvent.java index 767e0f896..7afbd2371 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerSkinInitEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerSkinInitEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerSpawnEvent.java b/src/main/java/net/minestom/server/event/player/PlayerSpawnEvent.java index d434dee5c..e3dba08de 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerSpawnEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerSpawnEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerStartDiggingEvent.java b/src/main/java/net/minestom/server/event/player/PlayerStartDiggingEvent.java index 305ec80a0..87cd8ede2 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerStartDiggingEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerStartDiggingEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerStartFlyingEvent.java b/src/main/java/net/minestom/server/event/player/PlayerStartFlyingEvent.java index c75ae99c1..074de112f 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerStartFlyingEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerStartFlyingEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerStopFlyingEvent.java b/src/main/java/net/minestom/server/event/player/PlayerStopFlyingEvent.java index 936058889..84d2b3f9d 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerStopFlyingEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerStopFlyingEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerSwapItemEvent.java b/src/main/java/net/minestom/server/event/player/PlayerSwapItemEvent.java index 2184d3f46..3785874ec 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerSwapItemEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerSwapItemEvent.java @@ -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; } } diff --git a/src/main/java/net/minestom/server/event/player/PlayerTickEvent.java b/src/main/java/net/minestom/server/event/player/PlayerTickEvent.java index 7f654dada..88c5f5d63 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerTickEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerTickEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerUseItemEvent.java b/src/main/java/net/minestom/server/event/player/PlayerUseItemEvent.java index 923caee76..07389079a 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerUseItemEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerUseItemEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/PlayerUseItemOnBlockEvent.java b/src/main/java/net/minestom/server/event/player/PlayerUseItemOnBlockEvent.java index 3a0391b81..6bec50bf5 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerUseItemOnBlockEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerUseItemOnBlockEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/event/player/UpdateTagListEvent.java b/src/main/java/net/minestom/server/event/player/UpdateTagListEvent.java index ce375f039..a68777609 100644 --- a/src/main/java/net/minestom/server/event/player/UpdateTagListEvent.java +++ b/src/main/java/net/minestom/server/event/player/UpdateTagListEvent.java @@ -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; } diff --git a/src/main/java/net/minestom/server/instance/WorldBorder.java b/src/main/java/net/minestom/server/instance/WorldBorder.java index 4cb0c2b36..74d64d310 100644 --- a/src/main/java/net/minestom/server/instance/WorldBorder.java +++ b/src/main/java/net/minestom/server/instance/WorldBorder.java @@ -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; } diff --git a/src/main/java/net/minestom/server/utils/ArrayUtils.java b/src/main/java/net/minestom/server/utils/ArrayUtils.java index 54a53d9cb..72ef4c4b8 100644 --- a/src/main/java/net/minestom/server/utils/ArrayUtils.java +++ b/src/main/java/net/minestom/server/utils/ArrayUtils.java @@ -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 the array type */ - public static void fill(T[] array, Supplier supplier) { + @NotNull + public static void fill(@NotNull T[] array, @NotNull Supplier supplier) { for (int i = 0; i < array.length; i++) { array[i] = supplier.get(); } diff --git a/src/main/java/net/minestom/server/utils/BlockPosition.java b/src/main/java/net/minestom/server/utils/BlockPosition.java index 9c7c4d983..f6aa5708b 100644 --- a/src/main/java/net/minestom/server/utils/BlockPosition.java +++ b/src/main/java/net/minestom/server/utils/BlockPosition.java @@ -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); }