This commit is contained in:
themode 2021-04-02 22:50:20 +02:00
parent 4a075da3e0
commit 56bba41f68
4 changed files with 17 additions and 51 deletions

View File

@ -20,8 +20,7 @@ public interface EquipmentHandler {
*
* @return the {@link ItemStack} in main hand
*/
@NotNull
ItemStack getItemInMainHand();
@NotNull ItemStack getItemInMainHand();
/**
* Changes the main hand {@link ItemStack}.
@ -35,8 +34,7 @@ public interface EquipmentHandler {
*
* @return the item in off hand
*/
@NotNull
ItemStack getItemInOffHand();
@NotNull ItemStack getItemInOffHand();
/**
* Changes the off hand {@link ItemStack}.
@ -51,8 +49,7 @@ public interface EquipmentHandler {
* @param hand the Hand to get the {@link ItemStack} from
* @return the {@link ItemStack} in {@code hand}
*/
@NotNull
default ItemStack getItemInHand(@NotNull Player.Hand hand) {
default @NotNull ItemStack getItemInHand(@NotNull Player.Hand hand) {
switch (hand) {
case MAIN:
return getItemInMainHand();
@ -85,8 +82,7 @@ public interface EquipmentHandler {
*
* @return the helmet
*/
@NotNull
ItemStack getHelmet();
@NotNull ItemStack getHelmet();
/**
* Changes the helmet.
@ -100,8 +96,7 @@ public interface EquipmentHandler {
*
* @return the chestplate
*/
@NotNull
ItemStack getChestplate();
@NotNull ItemStack getChestplate();
/**
* Changes the chestplate.
@ -115,8 +110,7 @@ public interface EquipmentHandler {
*
* @return the leggings
*/
@NotNull
ItemStack getLeggings();
@NotNull ItemStack getLeggings();
/**
* Changes the leggings.
@ -130,8 +124,7 @@ public interface EquipmentHandler {
*
* @return the boots
*/
@NotNull
ItemStack getBoots();
@NotNull ItemStack getBoots();
/**
* Changes the boots.
@ -146,8 +139,7 @@ public interface EquipmentHandler {
* @param slot the equipment to get the item from
* @return the equipment {@link ItemStack}
*/
@NotNull
default ItemStack getEquipment(@NotNull EntityEquipmentPacket.Slot slot) {
default @NotNull ItemStack getEquipment(@NotNull EntityEquipmentPacket.Slot slot) {
switch (slot) {
case MAIN_HAND:
return getItemInMainHand();
@ -191,8 +183,7 @@ public interface EquipmentHandler {
* @return the packet with the equipments
* @throws IllegalStateException if 'this' is not an {@link Entity}
*/
@NotNull
default EntityEquipmentPacket getEquipmentsPacket() {
default @NotNull EntityEquipmentPacket getEquipmentsPacket() {
Check.stateCondition(!(this instanceof Entity), "Only accessible for Entity");
final Entity entity = (Entity) this;

View File

@ -236,15 +236,6 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
playerConnection.sendPacket(createNewWindowItemsPacket());
}
/**
* Refreshes only a specific slot with the updated item stack data.
*
* @param slot the slot to refresh
*/
public void refreshSlot(short slot) {
sendSlotRefresh(slot, getItemStack(slot));
}
@NotNull
@Override
public Set<Player> getViewers() {

View File

@ -41,8 +41,7 @@ public interface InventoryModifier {
* @param slot the slot to check
* @return the item in the slot {@code slot}
*/
@NotNull
ItemStack getItemStack(int slot);
@NotNull ItemStack getItemStack(int slot);
/**
* Gets all the {@link ItemStack} in the inventory.
@ -52,8 +51,7 @@ public interface InventoryModifier {
*
* @return an array containing all the inventory's items
*/
@NotNull
ItemStack[] getItemStacks();
@NotNull ItemStack[] getItemStacks();
/**
* Gets the size of the inventory.
@ -67,8 +65,7 @@ public interface InventoryModifier {
*
* @return a modifiable {@link List} containing all the inventory conditions
*/
@NotNull
List<InventoryCondition> getInventoryConditions();
@NotNull List<InventoryCondition> getInventoryConditions();
/**
* Adds a new {@link InventoryCondition} to this inventory.

View File

@ -48,21 +48,18 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
Arrays.fill(items, ItemStack.AIR);
}
@NotNull
@Override
public ItemStack getItemStack(int slot) {
public @NotNull ItemStack getItemStack(int slot) {
return this.items[slot];
}
@NotNull
@Override
public ItemStack[] getItemStacks() {
public @NotNull ItemStack[] getItemStacks() {
return items.clone();
}
@NotNull
@Override
public List<InventoryCondition> getInventoryConditions() {
public @NotNull List<InventoryCondition> getInventoryConditions() {
return inventoryConditions;
}
@ -215,16 +212,6 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
player.getPlayerConnection().sendPacket(createWindowItemsPacket());
}
/**
* Refreshes only a specific slot with the updated item stack data.
*
* @param slot the slot to refresh
*/
public void refreshSlot(short slot) {
final int packetSlot = convertToPacketSlot(slot);
sendSlotRefresh((short) packetSlot, getItemStack(slot));
}
/**
* Gets the item in player cursor.
*
@ -305,7 +292,7 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
//refreshSlot((short) slot);
}
protected void setItemStackInternal(int slot, ItemStack itemStack) {
protected void setItemStackInternal(int slot, @NotNull ItemStack itemStack) {
items[slot] = itemStack;
}
@ -316,7 +303,7 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
* @param offset offset (generally 9 to ignore armor and craft slots)
* @param itemStack the item stack to set
*/
protected void setItemStack(int slot, int offset, ItemStack itemStack) {
protected void setItemStack(int slot, int offset, @NotNull ItemStack itemStack) {
final int convertedSlot = convertPlayerInventorySlot(slot, offset);
setItemStack(convertedSlot, itemStack);
}