CustomEnchantment API

Summary

Want to create custom enchantments like those of minecraft vanilla? This plugin is for you.

 

EnchantmentAPI allows you to:

- Create custom enchantments

- Set enchantment's name, id, trigger ...

- Create custom enchantment effect

 

 

Installation

Put the file in your plugin folder.

 

To import the API, add it to your build path (like bukkit) and add this line in your plugin.yml:

depend: [EchantmentAPI]

 

Usage

To create custom enchantment, use CustomEnchantment class.

 

Constructors:

new CustomEnchantment(int id, String name, int lvl, EnchantmentTarget target)

 

new CustomEnchantment(int id, String name, int lvl, EnchantmentTarget target, int start, boolean cursed, boolean treasure, List<Enchantment> conf, EventTrigger eventtrigger, boolean visible)

Constructor args:

- Integer id: Enchantment ID in Minecraft (do not use a vanilla enchantment ID ex=1  ex=100

- String name: Enchantment display name

- EnchantmentTarget target: The enchantment type. Example: ALL, BREAKABLE, ARMOR, FEET, LEGS...

Integer start: The minimal enchantment level (default: 0)

- Boolean cursed: Is the enchantment a curse ?

- Boolean treasure: Is the enchantment a treasure enchatment ?  (as mending, frost walk ect...)

- List<Enchantment> conf: Enchantment in conflict with that one (Example: Mending cannot be used with Infinity

- EventTrigger trigger: The trigger event (Example: EntityDamageEvent, BlockBreakEvent...)

- Boolean visible: Is the enchantment is visible in the item lore ?

 

 

You can also create a file that extends the CustomEnchantment class:

public class MyEnchant extends CustomEnchantment{

 

public MyEnchant(int id, String name, int lvl, EnchantmentTarget target, int start, boolean cursed, boolean treasure, List<Enchantment> conf, EventTrigger eventtrigger, boolean visible) {

super(id, name, lvl, target, start, cursed, treasure, conf, damagetrigger, eventtrigger, visible); // TODO Auto-generated constructor stub }

 

@Override

public void enchantmentEffect(Event event, int lvl) {

// TODO Auto-generated method stub

          }

}

Supported events: 

Register custom enchantment: EntityDamageEvent, EntityDamageByEntityEvent, EntityDamageByBlockEvent, EntityAirChangeEvent, EntityCombustEventPlayerFishEvent, PlayerAnimationEvent, PlayerDeathEventBlockBreakEvent

 

Register custom enchantments:

EnchAPI.loadEnchantment(CustomEnchantment)

 

Set enchantment effect:

			public void enchantmentEffect(Event event, int lvl) {
//TODO Enchantment effect here
			}

 

Enchant an item:

YourEnchantment.enchant(ItemStack item, int level)

 

 Set Enchantment Effect, use abstract method enchantmentEffect(Event, int):

public void enchantmentEffect(Event event, int lvl){

//TODO Code here

}

 


Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes

About This Project

  • Project ID
    299560
  • Created
    Jul 31, 2018
  • Last Released File
    Aug 3, 2018
  • Total Downloads
    1,214
  • License

Categories

Members