Enchantment Limiter

Bukkit Plugins
13,623 Downloads Last Updated: Nov 5, 2020 Game Version: 1.16   +3

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]

  1. The plugin must add enchantments by extending org.bukkit.enchantments.Enchantment by calling registerEnchantment.
  2. 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

  1. commands to modify settings [in progress], save, and reload.
  2. New permissions for each item/enchant combination.
  3. Add new Disallowed trading enchants to permit trading-specific blocking.
  4. 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]

 

Comments

  • To post a comment, please or register a new account.
Posts Quoted: