AutoRepair

56.6k Downloads

v2.16

Table of Contents

Credits

A lot of credit goes to lostaris; I heavily adapted his original plugin to make this compatible with Vault, support the latest versions, etc.

At a glace

  • Repairs your tools, weapons and armour
  • Repairs can either be free, cost items, cost via economy, cost xp, or any combination thereof; these can vary on a per-item basis, depending on configuration settings.
  • Repairs can be triggered manually or automatically
  • Allows for indestructible tools
  • Works on enchanted items too, with the ability to have different prices for enchanted and non-enchanted items!
  • Permissions support through PermissionsBukkit (may work, but not tested with, other Permissions systems)
  • Economy support through Vault
  • Repairs can be set to have varying cost depending on how damaged the item is
  • [NEW] Repair anvils can be constructed to force repairs to occur at a certain location.
  • [NEW] Per-player disabling via command is now supported.

Features

Allows a player can repair their tools, either manually or automatically just before they break. Automatic repairing will trigger on hitting a block with a tool when the tool is about to break. This repairing can be done at the cost of a given amount of one or more materials, a set amount of money if an economy system is in use, a set amount of experience points deducted from the player's total, or for free. Per-player disabling of autorepair is also supported.

New

Version 2.16

  • Removing items from the recipes list is now officially supported. The config.yml will automatically generate the first time the plugin is started, and contain all supported items. If an item is removed, repair of that item is effectively disabled.
  • Added 'enable' and 'disable' commands that allow players to disable autorepair on themselves, if they like (and if they're given permissions to do so).
  • Hoes now properly autorepair.

Version 2.12

  • Fishing poles now properly autorepair.

Version 2.10

  • Added new command alias: '/ar'
  • Added ability for items to be repaired in the recipe section to be specified as their item id, i.e. DIAMOND_SWORD could also be '276'. This should allow compatibility with weapon mods (however, this is untested! Looking for testing volunteers).

Version 2.00

  • Added new cost type: XP
  • Added ability to differentiate prices between enchanted and non-enchanted items
  • New, more user-friendly config format; if old config files are present, it will convert their contents to the new format
  • Config will now install itself when the plugin is run, instead of requiring manual installation
  • Anvil can now be made of configurable block type
  • Added ability to group items into up to 9 seperate groups that each have their own permission node

Version 1.84

  • Added ability to construct and repair at Anvils (1 iron block next to a sign that says "anvil")
  • Added ability in configuration to have enchanted items lose their enchantment upon being repaired
  • Added in repcommands permission node to restrict access only to the manual repair commands

Setup

As of version 2.00, there is only one config file for AutoRepair: it's the config.yml in your plugins/AutoRepair folder. This file has two sections, one dedicated to the repair "recipes", and the other dedicated to the configuration.

If you have the old 1.84 or before config files, then v2.00 will take those settings, and construct a new config.yml from them, and then begin using that file. Settings should not be lost in the transition from 1.84 to 2.00.

'recipes' section

The recipe section enumerates the specific cost for each item that it is possible to repair. Each of the fields under each item is optional; if no fields are present, it is assumed that there is no repair cost for the item and that repairs are free. The following is the largest possible format for one specific item:

  LEATHER_HELMET:
    permission-group: 1
    normal:
      LEATHER: 5
      item-cost-min: 1
      econ-cost: 5.5
      econ-cost-min: 1.0
      xp-cost: 6
      xp-cost-min: 1
    enchanted:
      LEATHER: 5
      GOLD_INGOT: 1
      item-cost-min: 1
      econ-cost: 7.5
      econ-cost-min: 2.0
      xp-cost: 20
      xp-cost-min: 5
  '276':
    normal:
      DIAMOND: 2
      STICK: 1

  • 'permission-group': Range is 1-9. Allows a specific item to be sorted into one of 9 groups that then require a specific permission to be set in order to allow repair on that group of items. If not specified, items default to 0, which is the same as "no group".
  • 'normal' vs 'enchanted': it is possible to specify seperate costs for normal and enchanted items.
  • ITEM_NAME: the item cost of repairing this specific item. There can be multiple item costs for each item, as seen in the example under 'enchanted'. Alternatively, this can be specified as '<item-data-id></item-data-id>'; this should allow for compatibility with weapon mods (untested!!).
  • 'XXX-cost': the specific cost of repairing the item. If the corresponding config option is turned off, this will be ignored. If this cost is missing, it is assumed that the cost is 0.
  • 'XXX-cost-min': if the specific cost is set to be "adjusted" in the config, then this is the minimum cost possible when conducting a repair. This prevents users from repairing after 3 uses of an item, causing the item cost to be 0 every time and thus getting away with free repairs.

'config' section

The config section now has a layout more consistant with other Bukkit plugins; a series of true/false variables that allow customization of the plugin. Please note, that nothing here is new to version 2.00, it's just presented in a slightly different format. All fields are true/false, except for anvilUse.anvilBlockType.

  • repairOfEnchantedItems.allow: allow repair of enchanted items.
  • repairOfEnchantedItems.lose-enchantment: if repairs of enchanted items are allowed, they will lose their enchantment upon being repaired
  • usePermissions: if a permissions system is installed, this will force permission checks on all operations. ONLY USE IF a permissions system is installed.
  • automaticRepair.allow: allow repairs to be done automatically before tools break, if cost requirements are met.
  • automaticRepair.no-warnings: This turns off warnings that would otherwise occur when tools are near breaking points; this is true whether automatic repairs are on or off.
  • automaticRepair.no-notifications: Disables repair notifications that occur when tools are repaired automatically.
  • anvilUse.allow: allow construction and use of anvils
  • anvilUse.anvilBlockType: specifies the specific block type that is required to make an anvil. Same format as items in the recipe section. Default is IRON_BLOCK.
  • econCost.use: use economy cost for an item, if economy linked, and econ cost specified for specific item in recipe section
  • econCost.adjust-for-damage: if econCost is enabled, this will adjust the economy cost of repairing based on the % of damage to the item.
  • xpCost.use: use experience point cost for an item, if xp cost specified for specific item in recipe section
  • xpCost.adjust-for-damage: if xpCost is enabled, this will adjust the xp cost of repairing based on the % of damage to the item.
  • itemCost.use: use item cost for an item, if item cost specified for specific item in recipe section
  • itemCost.adjust-for-damage: if itemCost is enabled, this will adjust the item cost of repairing based on the % of damage to the item.

Economy

Usage of an economy plugin via Vault is optional. You can configure this plugin to use an economy plugin's cash to charge for a repair. However, if you wish to use an economy plugin you MUST also run Vault.

If an economy plugin and/or Vault is not detected, and you have econCosts enabled in your configuration, these will be disabled until a valid economy is installed.

[NEW] Anvils

Anvils can now be constructed to force players to conduct their repair operation in one specific location.

An anvil is constructed by placing an iron block, and then placing a sign that says "anvil" in any neighboring space. Right-clicking the iron block will then initiate the repair, given that the proper configuration and permission options have been set.

Permission and configuration setup for a situation where an admin wishes to limit repairs to only occur at anvils are as follows: (unmentioned fields are assumed to be non-relevant or up to the admin)

  • anvilUse.allow: true
  • automaticRepair.allow: false
  • automaticRepair.no-warnings: true
  • usePermissions: true (you need to have a permissions plugin)
  • permission nodes AutoRepair.access, AutoRepair.repair, and AutoRepair.warn are enabled
  • permission node AutoRepair.repcommand is explicitly disabled

Permissions

The only new permissions in version 2.00 are the "itemgroup" permissions. It is necessary to specify each one of these that a user should belong to; if they should belong to all 9 possible itemgroups, then you will have to specify out each of those 9 permissions.

Bukkit permissions is optional and if permissions is either not installed or is disabled for this plugin, all features will be available for all users. Will be turned on if the line permissions=false in the default config.properties file is changed to true.

Available permission nodes are (case sensitive):

  • AutoRepair.access - allows the use of this plugin, without this a user cannot do anything
  • AutoRepair.info -- allows the use of the ? and dmg commands
  • AutoRepair.warn - allows warning when a tool is about to break
  • AutoRepair.repair -- allows items in a user's inventory to be repaired, whether automatic or manually
  • AutoRepair.repcommands -- allows manual commands to be used to repair items
  • AutoRepair.repair.enchanted - allows enchanted items to be repaired, if autorepair config is set accordingly
  • AutoRepair.auto -- enables AutoRepair of tools in a user's inventory
  • AutoRepair.auto.disable -- allows a player to disable autorepair via the '/rep disable' command.
  • AutoRepair.reload -- allows a user to reload the plugin
  • AutoRepair.itemgroup1 -- allows a user to repair items that have been set into item group 1 by the configuration
  • AutoRepair.itemgroup2 -- allows a user to repair items that have been set into item group 2 by the configuration
  • AutoRepair.itemgroup[3-9] -- follows the same format as itemgroup1 and 2, but for groups 3 through 9.

Commands Usage

There are three command aliases: '/repair', '/rep', and '/ar'. For convenience, we will use /rep to describe the commands.

  • '/rep [quickbar]' repairs the tool/armour in this slot and deducts cost from inventory
  • '/rep [quickbar] ?' tells you what item and how much of it is needed to repair this item
  • '/rep [quickbar] dmg' tells you how many uses are left before this tool breaks or '/rep', '/rep ?', '/rep dmg' for the item in your hand
  • '/rep all' to repair ALL repairable items in your inventory including worn armour
  • '/rep arm' repairs all of your currently equipped armour
  • '/rep arm ?' tells you what you need to repair your equipped armour
  • '/rep reload' reloads the config files
  • '/rep disable' Disable autorepair for yourself
  • '/rep enable' Re-enable autorepair for yourself (after disabling)