Enchantment Limiter
Need to make enchantments harder to get? Too many people with really high level and/or multiply-enchanted, overpowered items? Enchantment Limiter can do that for you. It does so by limiting the combination of books in anvil, and limits enchantment tables to yield only one power. When enchanting on a table, it returns a proportional number of XP levels when it removes an enchantment. Since 0.8, if it can reduce the enchantment level to one that is allowed, does that rather than removing it completely.
You can also specify enchantment combinations that are not allowed, like preventing any diamond swords from having sharpness. See configs below. Removes disallowed enchantments from spawned/dropped items, including from mobs or fishing. Or configurably disallow pickup of the item, leaving them alone for players with permissions. [New in 1.5.4] You can also restrict usage of illegal items, if player somehow gets them by other means. Set Fix held items to false.
Enforces the different ways to boost enchants with an anvil, including item+item and item with a permitted book. Also added a fail-safe to account for the Bukkit bug that sometimes permits illegal anvil enchants.
While I was at it repairing the anvil on rejected enchants, I added a new feature you can enable so anvils can never run out
Enchantment Limiter was inspired by inspired by Everyonc, and was based on code from my related plugin, Unbreakable Items.
Configuration
Default config is written to plugins/EnchLimiter/config.yml if it doesn't exist.
Message on cancel. Decides whether or not to message a player when he places a second book in an anvil and this plugin returns it to him. Default is true.
Message on limit. Decides whether or not to message a player when a second enchantment is removed from his enchantment table attempt. Informs them of returned amount of XP. Default is true.
Message on disallowed. Decides whether or not to message a player a disallowed enchantment is removed from his enchantment table attempt. Informs them of returned amount of XP. Default is true.
Message on cancel hold. Decides whether or not to message a player when denying his holding an illegally enchanted item. Default is true. [Added in 1.5.4]
Limit Multiples: If set, stops any enchantments at tables or anvils from having more than one enchantment type. Combining books not allowed. Defaults to true. [2.7]
Max Enchants Allowed: If Limit Multiples is true, allows you to change max # enchants on a single item from the default of 1.
Stop pickup: defaults false. If set, rather than removing enchants as items are picked up, players cannot pick them up. If you want to also check either anvil- and table-specific disallowed listings added in 1.4, see Apply_on_global_check below.
Restore levels: that restores XP on cancelled enchant, a feature added in 0.9. The default is different than 0.9 and is true, so the plugin normally behaves "nicely". if you want same behavior as 0.9 (to punish?) set to false. For explanation, see version history
Stop repairs: config item that allows repairing disallowed items in an anvil. Default = true 'Repairs' are defined as same items in each slot, rightmost item has no enchants, or rightmost item is raw material for left item [1.6.1]. Anything else might be an attempt to boost enchants. This does mean that some repairs won't work, such as two identically enchanted items except for wear. It's costly to repair this way; suggest repairing each tool individually.
Stop all repairs: defaults to false and if set does just that: you cannot repair anything in an anvil unless you have the new allrepairs permission.
Downgrade repairs:. Removed in 1.5.4 in favor of item below.
Downgrade in anvil: if true, downgrades result of anvil enchants rather than disallowing the action. Default is false. If attempt is caught when placing an item, chat messages are sent to the player. [new in 1.5.4]
Fix spawned items: if set to true will allow disallowed spawned items from having illegal enchants, fixing them at time of spawn. Fixing of necessity ignores any player permissions or groups. If you want to also check either anvil- and table-specific disallowed listings added in 1.4, see Apply_on_global_check below. Default false. Impacts any item "dropped" like mob drops, player drops, or fishing. This behavior used to be the case when Stop pickup was true; now you have individual control.
Infinite anvils: config item that, if true, repairs anvil whenever it is used, such that it never wears out. Default: false [In 1.3.2]
Fix held items: config item that, if true, "fixes" (removes disallowed enchants) from items placed in player's hand or [since 1.5.4] into armor slots. Default: changed to true in 1.5.4 in order to avoid Bukkit bug that sometimes misses "hold" event especially if player spams the button. This is a way of catching items that are not picked up (ex. taken from a loot chest), while still respecting player-specific permissions. It is a bit more server load since it is done every time a player changes held item. [New in 1.5.4] If false, player cannot put the illegal item in their hand (but see concern here on the default value). Also checks when equipping armor.If you want to also check either anvil- and table-specific disallowed listings added in 1.4, see Apply_on_global_check below.
Apply_on_global_check: new config node [added in 1.5.4] that allows referring to Disallowed anvil and/or table lists during item spawn, player pickup, or player hold events, respectively controlled by Fix spawned items, Stop pickup, Fix held items
- Apply_on_global_check.anvil: if true, then Disallowed anvil enchants will also be checked during those events. Default is false
- Apply_on_global_check.table: if true, then Disallowed table enchants will also be checked during those events. Default is false
- both of above can be true, if desired.
- Apply_on_global_check.restrictive: if true, the highest possible level will be used in case of conflict between Disalllowed enhants and the others. If false, the lowest enchant level will be used. Default is true.
Lore immutable string: configurable string that, if found in the lore of an item, ,causes the item to become immutable, as far as enchantments go. No more can be added [In 3.1]
Disallowed enchantments
Supports an optional configuration action to list disallowed enchantment combinations. They are of the form:
Disallowed enchants: <Item_Name>: <Enchantment_Name>: <Level> ....
Item names and enchantment names must be in ALL CAPS. Both support special "ALL" that matches every type. Item names support special "ALL_" subtypes as listed here plus standard Bukkit names. Enchantments must correspond to the standard Bukkit/Spigot names listed HERE. Note that the Bukkit enchantment names are different than the in-game names. Support a special enchantment name for new enchantments from other plugins, as long as you know the ID number, "UNKNOWN_ENCHANT_#", where the last is replaced by your ID number. I tested it against my Unbreakable Items plugin, so I know it works, but there are some caveats: [Added in 1.7]
- The plugin must add enchantments by extending org.bukkit.enchantments.Enchantment by calling registerEnchantment.
- The plugin must load before this one, so that retrieving the new enchant by ID works. You will see a warning on startup or on el reload if can't find the enchantment.
Levels are 1 or more. Blocking level n blocks n and higher, so specifying level 1 blocks all such enchants. DO NOT list all levels for the same enchant; the last one wins, so if you put level 4 last, you are only disallowing 4, not 1-3. [In 1.3.2] BOOK or ENCHANTED_BOOK are equivalent and apply to one another.
[New in 1.4] Support parallel configuration items specific to anvil or enchantment table usage, Disallowed anvil enchants and Disallowed table enchants, respectively. If an item/enchantment combination is found both in one of these and the global Disallowed enchants, the anvil/table specific settings overrides the global; this is easy to do if you use the "ALL" special names.
[New in 1.4] Furthermore support branches underneath any of the above, starting with keyword "Group_", which collect a set of disallowed enchants using that group name. Syntax under the Group_ branch is exactly as above.
- each group has an associated dynamic permission enchlimiter.Group_<name> which, if player has it, the group limits do not apply. Otherwise, the limits override the global settings (ex. so you restrict level 3 in global, but restrict to level 1 in group).
- can use same group name within each of Disallowed enchants, Disallowed anvil enchants, Disallowed table enchants
- this allows you to create special groups/classes of players that are the only ones who can perform their restricted enchants
Here is an example:
Disallowed enchants: DIAMOND_SWORD: SILK_TOUCH: 1 DAMAGE_ALL: 3 WOOD_AXE: FIRE_ASPECT: 1 ALL: DURABILITY: 2 BOW: ALL: 2 ALL_SWORDS: DAMAGE_ALL:2 UNKNOWN_ENCHANT_256: 1 ALL_ARMOR: THORNS:2 Disallowed anvil enchants: Group_smithy: ALL: ALL: 2 Disallowed table enchants: ALL_SWORDS: ALL: 3 ALL_AXES: ALL: 3 Group_weaponsmith: ALL_SWORDS: ALL: 2 ALL_AXES: ALL: 2
Permissions
Has a corresponding permission for each limitation. Use is optional: all defaults are OPerators only.
- enchlimiter.books: gives power to combine books
- enchlimiter.multiple: gives power to get multiple enchantments from one enchant in an enchantment table.
- enchlimiter.disallowed: gives power to override Disallowed enchants config.
- enchlimiter.repairs, allows repairs even if Stop repairs is true.
- enchlimiter.allrepairs, allows repairs even if Stop all repairs is true.
- enchlimiter.useillegal permits equipping/holding illegal items when Fix held items is false. [1.5.4]
- enchlimiter.el permits use of admin command. Default is Op.
- enchlimiter.elfix permits use of elfix command. Default is true. [New in 1.4]
Commands
See Command page for details.
Multiple Language Support
Supports multiple languages. See Languages and Translation page for details.
Future Ideas
- commands to modify settings [in progress],
save, and reload. - New permissions for each item/enchant combination.
- Add new Disallowed trading enchants to permit trading-specific blocking.
- World-specific configs.
Configurable # of max enchants (ex. 2 but not 3) [2.7]
Allow renaming of disallowed items. [2.7]
armor shortcuts like ALL_ARMOR_DIAMOND or ALL_ARMOR_CHAINMAIL [2.5]
ALL_BARDING doesn't work. Instead, list each of DIAMOND_BARDING, GOLD_BARDING, IRON_BARDING
New configuration that can block all repairs.
Block equipage of restricted items (ex. if config.yml recently changed and owned item now is restricted), or fix if Fix held items turned on.Turns out this is difficult because of so many ways to equip armor.[1.5.4]
Permit but downgrade/remove illegal enchants in an anvil.[1.5.4]
Allow Fix held items, Fix spawned items, Stop pickup to check more than only global Disallowed enchants listing.[1.5.4]
allow for different groups of disallowed and permitted enchants[v.1.4]
Does this plugin work for combining items on an anvil? In testing it works to stop players from picking up forbidden items (sharp3 axes) but it doesn't stop them from combining two sharp2 axes on an anvil.
Also, preventing sharp3 books works but it won't prevent sharp4 books. I don't see how to configure it to stop 3 and higher.
Am I doing something wrong?
@Glossinator
Yes, after looking at a description of the new enchanting system under pre-release 1.8, there will be an update required. I don't expect it to be backward-compatible, either. Big difference will b the amount of XP charged.
Will this be broken with the enchantment system in 1.8?
@MozaiX Fixed the link. Also full link here: http://bukkit-plugins/ench-limiter/pages/supported-materials
Hmm. Are you an Op? Default permissions is that an Operator can enchant anything.
Aha! Noticed a typo that you copied. Correct form is "Disallowed enchants", not 'enchantments'. Fixed my typo in config description (the example was correct) too.
The link to weapon names is broken. there is only the list to enchantment names.
also, the tutorial is not too specific. do i add the limited enchantments i want into the config.yml?
http://pastie.org/9201281
My config is not limiting any enchantments. i have protection_all: 2, but i restarted server with updated config and i can enchant a protection 3 and Power IV on a book. my log file gives no errors. i can post that if you want to be sure.
@doomlordking
That is now in version 0.8.
Got me thinking, if level >= N+1 enchantment is disallowed, we could could change enchantment to be only allowed level N. I have had this plugin on my server http://dev.bukkit.org/bukkit-plugins/enchantlimiter/ and it did what you came up with. :)
@doomlordking
Hmm, right. That would be a new feature. Currently the plugin only blocks adding enchantments on a table or anvil.
Could be added. What would you expect to be done: 1) don't allow player to pick up item; another player with permission could. Or (2) allow player to pick up item but remove the blocked enchantment(s). If blocking multiple, would have to pick one randomly to remove.
Got me thinking, if level >= N+1 enchantment is disallowed, we could could change enchantment to be only allowed level N.
Thank you so much, i have i have oxygen block on my server but people found if a mob drops the enchanted item or mcmmo fishing, it keeps and can use the enchant.
@doomlordking
Just posted version 0.7 with more generous XP return. Also has meta-items to make configuring easy.
@doomlordking
Currently it does give back, but the algorithm today gives back XP levels equal to the enchant level. So removing a lvl 1 enchant gets 1 XP level back. I know it's not always accurate but seemed the best at the time when removing a multiple enchant, since the remaining enchant may still be quite expensive.
I suppose I could try something like: compute XP cost per enchant lvls (by summing them all up) and then removing the fractional amount for the removed enchant. So if you are spending 30 for a level 1 + a level 2 enchant, removing the level 2 would return 20 XP levels. You could get a "cheap" enchantment this way, ex lvl 1 silk touch + lvl 2 fire, and removing the fire you get silk touch for only 10 XP levels.
Putting this in the next version
I have a idea, on my serve I want to limit peoples enchant but i don't want them to lose all the exp, so is there way to give them levels back. Ex: it on_remove: 5 (removed 1 enchant gets 5levels, 2 removed 10, 3 removed 15.