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.
Added
- Config options for messages:
noPermissionMessage, itemAlreadyRepaired, itemDoesNotHaveMending, mendingNotAllowed, insufficientXP, durabilityLeftMessage, repairsNeededMessage
. /bm reload
command to allow users with thebettermending.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 theMap
class to check if anItemStack
has the MENDING enchantment, and thecontains
method of theList
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 theonEnable
method.