diff --git a/src/main/java/com/marcusslover/plus/lib/item/Item.java b/src/main/java/com/marcusslover/plus/lib/item/Item.java index 02f647d..9624a73 100644 --- a/src/main/java/com/marcusslover/plus/lib/item/Item.java +++ b/src/main/java/com/marcusslover/plus/lib/item/Item.java @@ -116,6 +116,13 @@ public int maxStack() { return this.itemStack.getType().getMaxStackSize(); } + /** + * @return the material type of this item + */ + public @NotNull Material material() { + return this.type(); + } + /** * @return the material type of this item */ @@ -123,6 +130,16 @@ public int maxStack() { return this.itemStack.getType(); } + /** + * Change the material type used in this item. + * + * @param material the material type of this item + * @return this item + */ + public @NotNull Item material(@NotNull Material material) { + return this.type(material); + } + /** * Change the material type used in this item. * @@ -134,6 +151,17 @@ public int maxStack() { return this; } + /** + * Change the material type used in this item. + * IMPORTANT: This method creates a new item with the specified material. + * + * @param material the material type of this item + * @return brand new item + */ + public @NotNull Item withType(@NotNull Material material) { + return Item.of(this.itemStack.withType(material)); + } + /** * @return the amount of items in the stack */ @@ -152,6 +180,74 @@ public int amount() { return this; } + /** + * Increment the amount of items in the stack by 1. + * @return the item + */ + public @NotNull Item increment() { + return this.increase(); + } + + /** + * Increment the amount of items in the stack by the specified amount. + * @param amount the amount to increment by + * @return the item + */ + public @NotNull Item increment(int amount) { + return this.increase(amount); + } + + /** + * Increment the amount of items in the stack by 1. + * @return the item + */ + public @NotNull Item increase() { + return this.increase(1); + } + + /** + * Increment the amount of items in the stack by the specified amount. + * @param amount the amount to increment by + * @return the item + */ + public @NotNull Item increase(int amount) { + return this.amount(this.amount() + amount); + } + + /** + * Decrement the amount of items in the stack by 1. + * @return the item + */ + public @NotNull Item decrement() { + return this.decrease(); + } + + /** + * Decrement the amount of items in the stack by the specified amount. + * @param amount the amount to decrement by + * @return the item + */ + public @NotNull Item decrement(int amount) { + return this.decrease(amount); + } + + /** + * Decrement the amount of items in the stack by 1. + * @return the item + */ + public @NotNull Item decrease() { + return this.decrease(1); + } + + /** + * Decrement the amount of items in the stack by the specified amount. + * @param amount the amount to decrement by + * @return the item + */ + public @NotNull Item decrease(int amount) { + return this.amount(this.amount() - amount); + } + /** * Changes the amount of damage this item has as a percentage. * @@ -246,12 +342,21 @@ public boolean hasEnchant(@NotNull Enchantment enchantment) { } public @NotNull Item glow() { - if (this.itemStack.getType().equals(Material.BOW)) { - enchant(Enchantment.DIG_SPEED, 1); + return this.glow(true); + } + + public @NotNull Item glow(boolean glow) { + if (glow) { + if (this.itemStack.getType().equals(Material.BOW)) { + enchant(Enchantment.DIG_SPEED, 1); + } else { + enchant(Enchantment.ARROW_INFINITE, 1); + } + return addItemFlag(ItemFlag.HIDE_ENCHANTS); } else { - enchant(Enchantment.ARROW_INFINITE, 1); + clearEnchants(); + return removeItemFlag(ItemFlag.HIDE_ENCHANTS); } - return addItemFlag(ItemFlag.HIDE_ENCHANTS); } /**