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

View File

@ -236,15 +236,6 @@ public class Inventory implements InventoryModifier, InventoryClickHandler, View
playerConnection.sendPacket(createNewWindowItemsPacket()); 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 @NotNull
@Override @Override
public Set<Player> getViewers() { public Set<Player> getViewers() {

View File

@ -41,8 +41,7 @@ public interface InventoryModifier {
* @param slot the slot to check * @param slot the slot to check
* @return the item in the slot {@code slot} * @return the item in the slot {@code slot}
*/ */
@NotNull @NotNull ItemStack getItemStack(int slot);
ItemStack getItemStack(int slot);
/** /**
* Gets all the {@link ItemStack} in the inventory. * Gets all the {@link ItemStack} in the inventory.
@ -52,8 +51,7 @@ public interface InventoryModifier {
* *
* @return an array containing all the inventory's items * @return an array containing all the inventory's items
*/ */
@NotNull @NotNull ItemStack[] getItemStacks();
ItemStack[] getItemStacks();
/** /**
* Gets the size of the inventory. * Gets the size of the inventory.
@ -67,8 +65,7 @@ public interface InventoryModifier {
* *
* @return a modifiable {@link List} containing all the inventory conditions * @return a modifiable {@link List} containing all the inventory conditions
*/ */
@NotNull @NotNull List<InventoryCondition> getInventoryConditions();
List<InventoryCondition> getInventoryConditions();
/** /**
* Adds a new {@link InventoryCondition} to this inventory. * 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); Arrays.fill(items, ItemStack.AIR);
} }
@NotNull
@Override @Override
public ItemStack getItemStack(int slot) { public @NotNull ItemStack getItemStack(int slot) {
return this.items[slot]; return this.items[slot];
} }
@NotNull
@Override @Override
public ItemStack[] getItemStacks() { public @NotNull ItemStack[] getItemStacks() {
return items.clone(); return items.clone();
} }
@NotNull
@Override @Override
public List<InventoryCondition> getInventoryConditions() { public @NotNull List<InventoryCondition> getInventoryConditions() {
return inventoryConditions; return inventoryConditions;
} }
@ -215,16 +212,6 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
player.getPlayerConnection().sendPacket(createWindowItemsPacket()); 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. * Gets the item in player cursor.
* *
@ -305,7 +292,7 @@ public class PlayerInventory implements InventoryModifier, InventoryClickHandler
//refreshSlot((short) slot); //refreshSlot((short) slot);
} }
protected void setItemStackInternal(int slot, ItemStack itemStack) { protected void setItemStackInternal(int slot, @NotNull ItemStack itemStack) {
items[slot] = 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 offset offset (generally 9 to ignore armor and craft slots)
* @param itemStack the item stack to set * @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); final int convertedSlot = convertPlayerInventorySlot(slot, offset);
setItemStack(convertedSlot, itemStack); setItemStack(convertedSlot, itemStack);
} }