This is a plugin that serves as an API for easy creation of custom enchantments in plugins. Plugins usually need to have an enchantment wrapper to provide the methods needed for a custom enchantment, as well as a way to register these custom enchantments into the Enchantment class, so that the spigot API thinks that it is a Minecraft enchantment like all the vanilla ones. Well, using this library, creating enchantments is as easy as pie! This is the main class of an example plugin that utilizes this API:
See? Adding custom enchantments now only requires declaring a custom enchant as an instance of EnchantmentWrapper and calling a register() method for it in onEnable().
AN IMPORTANT NOTE: Any enchantment added using this plugin has no way of knowing how to display itself in the tooltip of an item. Any item with a custom enchantment given through your plugin should also have a lore that shows that the item has a custom enchantment.
Adding custom enchantments through plugins
There are a few different ways to construct an enchantment which you should be made aware of:
1) Constructing an enchantment with a key in the "minecraft:" namespace, a name and a maximum level.
2) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level and a starting level.
3) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level, a starting level and an EnchantmentTarget, which is basically what type of items this enchantment can be applied to.
4) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level, a starting level, an EnchantmentTarget and whether the enchantment is treasure.
5) Constructing an enchantment with a namespaced key, a name and a maximum level.
6) Constructing an enchantment with a namespaced key, a name, a maximum level and a starting level.
7) Constructing an enchantment with a namespaced key, a name, a maximum level, a starting level and an EnchantmentTarget.
8) Constructing an enchantment with a namespaced key, a name, a maximum level, a starting level, an EnchantmentTarget and whether the enchantment is treasure.
After constructing the enchantments (yes you can add more than one in the same plugin), calling them when the plugin is enabled is necessary for them to work.
All of the above is shown here:
Useful links
An example plugin that adds a custom enchantment and a /givemetool command to give the player a sword with that enchantment: https://www.mediafire.com/file/nl5oiyorl4ow84p/customenchtest.jar/file
The same plugin's decompiled source code: https://www.mediafire.com/file/wbkbuxnq8671ym8/customenchtest_source.zip/file
WrappersAPI's javadocs (if for some reason you want to see them): https://manossef.github.io/WrappersAPI-javadocs/
Code (Java):
package
whatevertheheck.customenchtest
;
import org.bukkit.enchantments.Enchantment ;
import org.bukkit.enchantments.EnchantmentTarget ;
import org.bukkit.plugin.java.JavaPlugin ;
import me.manossef.api.wrappers.CustomEnchantment ;
import me.manossef.api.wrappers.EnchantmentWrapper ;
public class Main extends JavaPlugin {
public static final Enchantment CUSTOM_ENCH_TEST = new EnchantmentWrapper ( "custom_ench_test", "Custom Ench Test", 1, 1, EnchantmentTarget. BREAKABLE, true, false ) ;
@Override
public void onEnable ( ) {
CustomEnchantment. register (CUSTOM_ENCH_TEST ) ;
}
@Override
public void onDisable ( ) {
}
}
import org.bukkit.enchantments.Enchantment ;
import org.bukkit.enchantments.EnchantmentTarget ;
import org.bukkit.plugin.java.JavaPlugin ;
import me.manossef.api.wrappers.CustomEnchantment ;
import me.manossef.api.wrappers.EnchantmentWrapper ;
public class Main extends JavaPlugin {
public static final Enchantment CUSTOM_ENCH_TEST = new EnchantmentWrapper ( "custom_ench_test", "Custom Ench Test", 1, 1, EnchantmentTarget. BREAKABLE, true, false ) ;
@Override
public void onEnable ( ) {
CustomEnchantment. register (CUSTOM_ENCH_TEST ) ;
}
@Override
public void onDisable ( ) {
}
}
AN IMPORTANT NOTE: Any enchantment added using this plugin has no way of knowing how to display itself in the tooltip of an item. Any item with a custom enchantment given through your plugin should also have a lore that shows that the item has a custom enchantment.
Adding custom enchantments through plugins
There are a few different ways to construct an enchantment which you should be made aware of:
1) Constructing an enchantment with a key in the "minecraft:" namespace, a name and a maximum level.
2) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level and a starting level.
3) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level, a starting level and an EnchantmentTarget, which is basically what type of items this enchantment can be applied to.
4) Constructing an enchantment with a key in the "minecraft:" namespace, a name, a maximum level, a starting level, an EnchantmentTarget and whether the enchantment is treasure.
5) Constructing an enchantment with a namespaced key, a name and a maximum level.
6) Constructing an enchantment with a namespaced key, a name, a maximum level and a starting level.
7) Constructing an enchantment with a namespaced key, a name, a maximum level, a starting level and an EnchantmentTarget.
8) Constructing an enchantment with a namespaced key, a name, a maximum level, a starting level, an EnchantmentTarget and whether the enchantment is treasure.
After constructing the enchantments (yes you can add more than one in the same plugin), calling them when the plugin is enabled is necessary for them to work.
All of the above is shown here:
Code (Java):
package
whatevertheheck.moreench
;
import org.bukkit.NamespacedKey ;
import org.bukkit.enchantments.Enchantment ;
import org.bukkit.enchantments.EnchantmentTarget ;
import org.bukkit.plugin.java.JavaPlugin ;
import me.manossef.api.wrappers.CustomEnchantment ;
import me.manossef.api.wrappers.EnchantmentWrapper ;
public class MoreEnch extends JavaPlugin {
public static final Enchantment TEST1 = new EnchantmentWrapper ( "test1", "Test 1", 1 ) ;
public static final Enchantment TEST2 = new EnchantmentWrapper ( "test2", "Test 2", 1, 1 ) ;
public static final Enchantment TEST3 = new EnchantmentWrapper ( "test3", "Test 3", 1, 1, EnchantmentTarget. BREAKABLE ) ;
public static final Enchantment TEST4 = new EnchantmentWrapper ( "test4", "Test 4", 1, 1, EnchantmentTarget. BREAKABLE, true ) ;
public static Enchantment TEST5 ;
public static Enchantment TEST6 ;
public static Enchantment TEST7 ;
public static Enchantment TEST8 ;
@Override
public void onEnable ( ) {
CustomEnchantment. register (TEST1 ) ;
CustomEnchantment. register (TEST2 ) ;
CustomEnchantment. register (TEST3 ) ;
CustomEnchantment. register (TEST4 ) ;
TEST5 = new EnchantmentWrapper ( new NamespacedKey ( this, "test5" ), "Test 5", 1 ) ;
CustomEnchantment. register (TEST5 ) ;
TEST6 = new EnchantmentWrapper ( new NamespacedKey ( this, "test6" ), "Test 6", 1, 1 ) ;
CustomEnchantment. register (TEST6 ) ;
TEST7 = new EnchantmentWrapper ( new NamespacedKey ( this, "test7" ), "Test 7", 1, 1, EnchantmentTarget. BREAKABLE ) ;
CustomEnchantment. register (TEST7 ) ;
TEST8 = new EnchantmentWrapper ( new NamespacedKey ( this, "test8" ), "Test 8", 1, 1, EnchantmentTarget. BREAKABLE, true ) ;
CustomEnchantment. register (TEST8 ) ;
}
@Override
public void onDisable ( ) {
}
}
import org.bukkit.NamespacedKey ;
import org.bukkit.enchantments.Enchantment ;
import org.bukkit.enchantments.EnchantmentTarget ;
import org.bukkit.plugin.java.JavaPlugin ;
import me.manossef.api.wrappers.CustomEnchantment ;
import me.manossef.api.wrappers.EnchantmentWrapper ;
public class MoreEnch extends JavaPlugin {
public static final Enchantment TEST1 = new EnchantmentWrapper ( "test1", "Test 1", 1 ) ;
public static final Enchantment TEST2 = new EnchantmentWrapper ( "test2", "Test 2", 1, 1 ) ;
public static final Enchantment TEST3 = new EnchantmentWrapper ( "test3", "Test 3", 1, 1, EnchantmentTarget. BREAKABLE ) ;
public static final Enchantment TEST4 = new EnchantmentWrapper ( "test4", "Test 4", 1, 1, EnchantmentTarget. BREAKABLE, true ) ;
public static Enchantment TEST5 ;
public static Enchantment TEST6 ;
public static Enchantment TEST7 ;
public static Enchantment TEST8 ;
@Override
public void onEnable ( ) {
CustomEnchantment. register (TEST1 ) ;
CustomEnchantment. register (TEST2 ) ;
CustomEnchantment. register (TEST3 ) ;
CustomEnchantment. register (TEST4 ) ;
TEST5 = new EnchantmentWrapper ( new NamespacedKey ( this, "test5" ), "Test 5", 1 ) ;
CustomEnchantment. register (TEST5 ) ;
TEST6 = new EnchantmentWrapper ( new NamespacedKey ( this, "test6" ), "Test 6", 1, 1 ) ;
CustomEnchantment. register (TEST6 ) ;
TEST7 = new EnchantmentWrapper ( new NamespacedKey ( this, "test7" ), "Test 7", 1, 1, EnchantmentTarget. BREAKABLE ) ;
CustomEnchantment. register (TEST7 ) ;
TEST8 = new EnchantmentWrapper ( new NamespacedKey ( this, "test8" ), "Test 8", 1, 1, EnchantmentTarget. BREAKABLE, true ) ;
CustomEnchantment. register (TEST8 ) ;
}
@Override
public void onDisable ( ) {
}
}
An example plugin that adds a custom enchantment and a /givemetool command to give the player a sword with that enchantment: https://www.mediafire.com/file/nl5oiyorl4ow84p/customenchtest.jar/file
The same plugin's decompiled source code: https://www.mediafire.com/file/wbkbuxnq8671ym8/customenchtest_source.zip/file
WrappersAPI's javadocs (if for some reason you want to see them): https://manossef.github.io/WrappersAPI-javadocs/
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.13, 1.14, 1.15
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
WrappersAPI - A library for easy addition of custom enchantments is a free Minecraft Java mod. Compatible with Minecraft 1.13, 1.14, 1.15, 1.16 and newer. Downloaded 194 times (via Spigot). Download it and open it directly in the game.