Developer API

If you would like to hook into WeaponLevels, it's very simple!

All you have to do is add WeaponLevels to your build path, add 'WeaponLevels' to your softdepend: [] path in plugin.yml, and you're good to go!

Use the static class WeaponLevelsAPI to access various methods.

  • int WeaponLevelsAPI.getExperience(ItemStack item)
  • int WeaponLevelsAPI.getExperience(Block block)
  • int WeaponLevelsAPI.getLevel(ItemStack item)
  • int WeaponLevelsAPI.getLevel(Block block)
  • void WeaponLevelsAPI.addExperience(Player player, ItemStack item, int amount)
  • int WeaponLevelsAPI.getBonus(ItemStack item, String bonus)

Custom Bonuses

With the WeaponLevels API, you can create custom bonus values that correspond to the stage of the item! All you have to do is tell your downloaders to add "yourbonushere: yourvaluehere" to their weaponlevels stage bonuses.

Then, access the bonus value whenever you want to by using:

  • WeaponLevelsAPI.getBonus(ItemStack item, String bonus).

Example

For example, if you wanted to create a "heal" bonus for your healing plugin, you would add "heal: 0" to each stage in the weaponlevels stages.yml (replacing 0 with the desired bonus value).

Then, whenever you use the heal, add the bonus by using WeaponLevelsAPI.getBonus(item, "heal");