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]
@Meowt
Sorry, for which lines/keywords did translations did not work? Maybe you can place your response on theTranslations page and I can fix the issue.
Would be very grateful - if you can do usual support for other languages. For use another plugin (LanguageAPI) for 1 pair of rows translation somehow do not want to.
Thanks!
@filbert66
That would be amazing. It would also mean I could stop relying on EnchantHandicap, which when combined with your plugin introduces a dupe/enchant limit bypass exploit that sounds rather similar to the one you fixed. (albeit logged by your plugin, so thankfully I can take action against anyone stupid enough to do it).
As for repairing, it'd be nice if there was a flag (or even a permission) to repair illegal enchants (i.e. the item in slot 1 is the same enchant as the resultant item), repair them but have the resulting enchant bumped down to legal limits, or to prohibit it entirely if the resultant item isn't legal. I'd imagine a flag for the second scenario would be the most useful, though, that way any books you find with illegal enchants aren't completely useless.
@PatchyKnowly
I think I could work that into the implementation for the other feature request from @Pepper82, to have different groups of disallowed/permitted enchants, by permissions. I could create a subtree under Disallowed enchants of "Anvil" and another of "Table", where what is under there only impacts those methods.
For anvil repairs, if you configure a new flag Allow repairs to permit repairs of otherwise illegal items, keeping their enchant levels, would that be good enough? Or do you wish to make them even rarer by permitting them to exist but get used up or reduced in level when you repair them? (FYI, I have another plugin that makes items not wear out, Unbreakable Items, which you can use to make those rare items even better.)
@filbert66
Right now I'm running second enchant plugin (enchant handicap) to restrict only infinity from being enchanted at a table, and allowing infinity in enchlimiter. The result is people can do stuff with it at anvils, but can't enchant it directly.
If there were a separate table for anvils, you could restrict what people get out of an enchantment table but not necessarily restrict anvil use. An option to make anvils downgrade resultant enchants to allowed levels instead of refusing the repair entirely would be nice.
It'd definitely be neat if you could have a table for each source of enchants this plugin affects, though. (I'm actually intending for people to be able to fish infinity books or get them from mobs, but not from a table to create some scarcity)
Just my two cents.
@PatchyKnowly
Thanks for the bug report. Working on it right now.
As to separating anvil from table, right now you can repair a item in an anvil (with an unenchanted base item on right), but you can't add any more enchants to it by using an enchanted item on the right. Is there something else you'd like to be able to do?
Update: You can't repair an item with a disallowed enchant. That's because of the fail-safe feature I added which prevents illegal results from being taken. I could modify that to permit the action if it's only a repair (item on right has no enchants and is same as item on left). Another feature request...
Update2: spawned items by mobs or fishing will be corrected currently. I could make that configurable. Feature request...
Really nice plugin. Does the job a lot better than previous ones I've used.
My only gripe is that I can't seem to get it to work for books. I made a ticket over at: http://dev.bukkit.org/bukkit-plugins/ench-limiter/tickets/2-error-when-enchanting-books/
Also, it'd be super neato if you could separate anvil and table enchants eventually, so that some things can be impossible to get from a table, but still be anvil-able if you get an item with the enchant through other means (villagers, chests, mob drops, fishing, etc.).
Keep up the good work!
@filbert66
Thanks! This work!
@Done84
Just posted version 1.1 which includes new admin command. Only one currently is reload, but more are coming. So you'd type this into chat after editing your config.yml:
Also includes fix for bug reported by @Meowt.
@Meowt
Created a ticket and fixed it. Currently pending release, but see bug comments if you want more.
Hello! I found a bug in your plugin.
When i press the Shift and click right or left button of mouse on any item in anvil - plugin has ignore all restrictions. As well all item, which i try enchant has duplicated.
I hope You fix this critical bug. Thanks.
And I advise to use ProtocolLib.
P.S. Sorry for my bad english.
@Done84
Disable all levels by listing level 1. That and above will be disallowed. Example:
@filbert66
Realoads are known to be very bad for servers especially big one with a lot of plugins. I would try to add a reload command and commands to configure all options of the plugin in-game. This would make the plug in more professional.
@Done84
Put them anywhere in your config.yml. Reload command is good idea. Have no commands as of yet. What other commands are needed?
Please add a Reload command. Also where do i put the Disallowed enchants ?? in the config after whats already there?
@pepper82
Hmm, can't do that yet. enchlimiter.disallowed is all or none right now. I'll consider that a feature request.
I could create multiple versions of Disallowed enchants, but I'd rather come up with groups that you can name. Will have to put some thought to it.
How can I add permissions for specific groups to be able to use certain enchants on their weapon? I want only some people to be able to use "THORNS" enchantment for example.
@WoodysGamertag
Just posted version 0.9 to address your noted missing features. DM me if you want an early copy.
@WoodysGamertag
Combining two items on an anvil to get a higher level forbidden enchant is something that needs to be added. Thanks for pointing it out. Right now it only works if you are using a book in right slot of anvil.
It is supposed to prevent sharp4 books if sharp3 is forbidden. I know it works in enchantment table. You can outright prevent book+book enchants with Limit Multiples, but it may be that using a book in an anvil to increment the enchant level of an already enchanted item may not be caught either.
Send me your config if you still can't get sharp4 books to not happen and I can take a look.