Better Mending

Better Mending

Plugin

A plugin that allows players to repair their items with experience points, with customizable repair amounts and costs.

Server EquipmentGame MechanicsMagicUtility

340 downloads
13 followers
Createda year ago
Updateda year ago

Follow Save
Better Mending has been archived. Better Mending will not receive any further updates unless the author decides to unarchive the project.
Host your Minecraft server on BisectHosting - get 25% off your first month with code MODRINTH.
Filter loader...
Filter versions...
Filter channels...
  • Fixed a syntax error in the code
    • Problem: There was no opening parenthesis after else if and the semicolon at the end of the line was terminating the if statement prematurely.
    • Solution: Added the missing parenthesis and removed the semicolon at the end of the line.

Changes

  • Replace the following block of code:
List<String> allowedEnchantments = getConfig().getStringList("allowedEnchantments");
for (Enchantment enchant : enchantments.keySet()) {
if (!allowedEnchantments.contains(enchant.getName())) {
// Enchantment is not allowed, cancel the event
interactEvent.setCancelled(true);
return;
}
}

with the following code:

if (enchantments.isEmpty()) {
// Item has no enchantments, cancel the event
interactEvent.setCancelled(true);
return;
}

List<String> allowedEnchantments = getConfig().getStringList("allowedEnchantments");
boolean hasAllowedEnchantment = false;
for (Enchantment enchant : enchantments.keySet()) {
if (allowedEnchantments.contains(enchant.getName())) {
hasAllowedEnchantment = true;
break;
}
}

if (!hasAllowedEnchantment) {
// Item does not have any allowed enchantments, cancel the event
interactEvent.setCancelled(true);
return;
}

This change modifies the onPlayerInteract method to check if the item being repaired has at least one allowed enchantment, rather than checking if all of its enchantments are allowed. If the item has at least one allowed enchantment, the player is allowed to use experience points to repair the item. If the item does not have any allowed enchantments, the event is cancelled and the player is not allowed to use experience points to repair the item.

  • Fix issue with enchantment in config not working

Changed

  • Forgot to include permission in plugin.yml
  • Optimize code

Added

  • Config options for messages: noPermissionMessage, itemAlreadyRepaired, itemDoesNotHaveMending, mendingNotAllowed, insufficientXP, durabilityLeftMessage, repairsNeededMessage.
  • /bm reload command to allow users with the bettermending.reload permission to reload the plugin's config.
  • /bm status command to allow users to check how many xp cost and durability repair.

Added

  • Configuration option allowedEnchantments to allow players to choose which enchantments they want to use with the repair feature. The plugin will only use enchantments from this list for repair.

Changed

  • Event handler to use the containsKey method of the Map class to check if an ItemStack has the MENDING enchantment, and the contains method of the List class to check if the MENDING enchantment is in the list of allowed enchantments.
  • Dependency on bStats library to the latest version to fix a compilation error.
  • Configuration option xpCost to 1. The amount of experience points required to repair 1 durability point is now 1.
  • Configuration option repairAmount to 2. The amount of durability points repaired per use is now 2.

Removed

  • Unused metrics variable from the onEnable method.

Added bstats to project for plugin analytics

Initial release of BetterMending Repair amounts and costs are configurable

External resources



Project members

laika

Owner

AkaSokuro

Member

Lumio

Member


Technical information

License
Project ID