Adding buyable enchants - Loikas/MinecraftPlugins GitHub Wiki
Since update 1.5 it is possible to add enchantments which you can buy when integrating ExpandedEnchants with vault. You can find the example for this at the bottom of this page.
If you have Vault installed on your server you can make it possible for players to buy enchantments using money instead of enchanting items via an enchanting table. You can very easily create buyable enchantments in the config file. Here you can specify which enchantments you can buy and which max level they can become when buying them.
First create a new file in the ExpandedEnchants folder inside the plugins folder and call it buy.yml Making buyable enchantments is really easy. They need to consist of 3 things: An enchant, a price per level and optionally a max level. And they need to be defined within an item. For example you can specify which enchants can be bought for pickaxes. The item name is mandatory and can be any of the following: Sword, Pickaxe, Axe, Shovel, Hoe, Bow, Crossbow, Elytra, Helmet, Chestplate, Leggings, Boots These need to have the exact same capitalization as given here.
The name has to be the name of the enchantment which for vanilla enchants can be found by using '/enchant {yourname}' ingame, or a custom enchantment which is one of these names: minecraft:ee_assassin, minecraft:ee_unbreakable, minecraft:ee_direct, minecraft:ee_autosmelt, minecraft:ee_antigravity, minecraft:ee_beheading, minecraft:ee_expboost, minecraft:ee_lavawalker, minecraft:ee_traveler, minecraft:ee_healthboost, minecraft:ee_stonefists, minecraft:ee_leaping, minecraft:ee_owleyes, minecraft:ee_heavenslightness, minecraft:ee_thermalplating, minecraft:ee_lifesteal, minecraft:ee_icy, minecraft:ee_deflect, minecraft:ee_lumberjack, minecraft:ee_veinmine, minecraft:ee_wide, minecraft:ee_feedingmodule, minecraft:ee_stepping, minecraft:ee_gourmand, minecraft:ee_shadowstep, minecraft:ee_soulbound, minecraft:ee_splitting, minecraft:ee_replanting, minecraft:ee_elemental, minecraft:ee_disarming and minecraft:ee_disruption
The max level can be anything you'd like. If no max level is specified it will default to the vanilla max level. This can go as high as you want except for lure, depth strider and quick shot. Those are automatically capped.
The level definition is a list of levels with a price. If a level isn't specified the plugin will take the the next lower level it can find. For example if you specify level 1 and 2 and a player wants to buy level 3 the plugin will take the price you specified at level 2 because its the closests lower level. When defining a level you have to define 3 things. The level which is gonna be bought, de price this level will cost and the chance this is gonna be succesful. If you set it to 100 a player will always succeed in buying the enchant. If you set it to 50 its going to fail half of the time and they will lose their money.
At the top you can define incompatible enchants when buying enchants. In the example veinmine is made incompatible with efficiency. When using books these two enchants can still be combined but if you have a pickaxe with either veinmine or efficiency the other one can't be bought onto that specific item.
