ItemAPI

UPDATED FOR 1.9

ItemLib 2.0

This is strictly a developer's tool.

It will do no good installing on a server without anything hooked into it. It does nothing on its own! Since 1.9 is a major update, it is doubtful this version will work with pre-1.9 MC versions.

REQUIRES http://ci.dmulloy2.net/job/ProtocolLib/

Secondary dependancy (optional)

Integrates with my plugin EasyTitles for messages to be given to players in the ACTION bar rather than direct messages. (Cleaner display, less chat clutter.)

To Use ItemLib:

Once the JAR is added to your project, just use ItemAPI.<method_below>

Developers

Add the JAR to your project and simply call any of the following:

Remove all damage from an item

  • ItemStack removeDamageFromItem(ItemStack item)

Set a specific damage amount on a weapon (can send a Double or Integer)

  • ItemStack setDamageOnWeapon(ItemStack item, Integer damage)
  • ItemStack setDamageOnWeapon(ItemStack item, Double damage)

Modify (add/subtract) an amount on a weapon (can send +/- Double/Integer)

  • ItemStack modifyDamageOnWeapon(ItemStack item, Integer damage)
  • ItemStack modifyDamageOnWeapon(ItemStack item, Double damage)

Set specific amount of +Health on an item (can send Double or Integer)

  • ItemStack setHealthOnItem(ItemStack item, Integer health)
  • ItemStack setHealthOnItem(ItemStack item, Double health)

Get the current +Health of an item

  • Double getHealthOnItem(ItemStack item)

Add or remove the enchantment glow to an item

  • void addGlow(ItemStack item)
  • void removeGlow(ItemStack item)

Custom Enchantments

Armor Enchants

  • ABSORB - absorbs 1% per level
  • SHIELD - adds 1 gold heart per level

Weapon Enchants

  • DOUBLESTRIKE - chance to deal double damage
  • NIGHTBANE - +1 damage per level at night
  • LIGHTSEEKER - +1 damage per level during the day
  • SLOW - applies Slowness debuff
  • BLAZE - set target on fire, time increases with level
  • BLAZE_AOE - sets targets in an area on fire, time increases with level
  • SHOCK - strikes target with lightning, damage increases with level
  • SHOCK_AOE - strikes all targets in area with lightning, damage increases with level
  • STRENGTH - give player a strength buff, time increases with level
  • LIFESTEAL - steals % of damage dealth, increases with level
  • POISON - poisons target, time increases with level
  • POISON_AOE - poisons all in area, time increases with level
  • WITHER - withers target, time increases with level
  • WITHER_AOE - withers all in an area, time increases with level

Tool Enchants

  • BLOCKBOON - chance to receive extra drops (not implemented)
  • SUPER - not implemented

Now you can add your own custom enchants!

Simply edit the CONFIG.YML and follow what you see inside.

  • tigerblood: (use some name to identify your enchant here)
  • 'id' UNIQUE UD - continue sequence you see
  • 'display' What will display on the Item ie: 'Withering I'
  • 'enable' You can disable individual enchants
  • 'handle' Should be FALSE on all added enchants (ItemAPI handle built in customs)
  • 'maxlevel' Maximum level this enchant can be raised to
  • 'cooldown' Time in seconds this custom enchant can be used in succession

To see if an Item has an Enchant:

  • someItemStack.containsEnchantment(ItemAPI.getCustomEnch("whateverYouNamedIt"))

Add an enchant:

  • ItemAPI.addEnchantment(SomeItemStack, "nameOfCustomEnchant", levelOfEnchant)

Increment an enchant to the next level: (it will check if it is above the maxlevel)

  • ItemAPI.addEnchantment(SomeItemStack, "nameOfCustomEnchant")

Examples

To add a false glow to an item, simply send the ItemStack of the item to glow:

  • ItemAPI.addGlow(item)

Let's say you want to increase the currently held Diamond Sword's damage by 2.5

  • player.setItemInHand(ItemAPI.modifyDamageOnWeapon(player.getItemInHand(), 2.5)

Want to give a player a helmet with +2 health?

  • player.getInventory().addItem(ItemAPI.setHealthOnItem(helmet, 2)

Add a custom enchantment to an item?

  • itemAPI.addEnchantment(ItemStack itemToAddTo, CTypes.<enchant>, int levelOfEnchantment)

Comments

Posts Quoted:
Reply
Clear All Quotes

About This Project

Categories

Members

Recent Files

Bukkit