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)
In version 1.12.2 plugin does not work(((
Please update Mob Apocalypse to 1.10.2 :D
I get an error when loading your plugin:
org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.questcraftserver.itemapi.ItemAPI'
I'd really like to be able to use this plugin. Server running spigot 1.10.
@BlueSoapTurtle
I will look into this as I have begun updating plugins to 1.9
Awesome api! Though I noticed when adding an enchant, it's always level 1? even when calling the function with a higher number. Any way to fix this?
ItemStack item = new ItemStack(Material.DIAMOND_SWORD); ItemAPI.addEnchantment(item, CTypes.ABSORB, 5); player.getInventory().addItem(item);
Still only gives absorb 1
Bruh you are amazon
@Zombiesking4260
Sure, I can try to make some time to do that. However, this is intended to be added into an existing project you are making. Alone it will not really do anything except add and handle the custom enchants packaged with ItemAPI.
can you make a video about how to make a custom enchantment?
@Paul3820999
Not sure what you mean exactly. This simply gives your the framework to add new enchantments and other Item modifying methods for your own plugins.
You would need to build in whatever limits you wanted in your plugin. This is just a tool
@budopey
Sure, you can add anything to anything! :)
I have a question about weapon enchants. I have caster classes that only use tools/items as weapons. Would weapon enchants apply to them?Like Hoe, Stick, Blaze rod etc.
@budopey
I still need to update Upgradable to include any available custom added enchantments found in ItemAPI. As of now, Upgradable will include the default ItemAPI enchants but not ones you might add. So the current answer is no. The answer will be yes at next Upgradable update. Once that new update comes out then Upgradable will see any enchantment ItemAPI has loaded, which will include any a user would add.
I should have that all sorted over the weekend actually so early next week I should have a new release there with some new features too. :)
First download <3
@nj2miami
Very excited, the addGlow will be very useful!
@ShaneHD
Its awaiting approval.
Please make downloadable! (: