- Fixed a syntax error in the code
- Problem: There was no opening parenthesis after
else ifand the semicolon at the end of the line was terminating theifstatement prematurely. - Solution: Added the missing parenthesis and removed the semicolon at the end of the line.
- Problem: There was no opening parenthesis after
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 reloadcommand to allow users with thebettermending.reloadpermission to reload the plugin's config./bm statuscommand to allow users to check how many xp cost and durability repair.
Added
- Configuration option
allowedEnchantmentsto 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
containsKeymethod of theMapclass to check if anItemStackhas the MENDING enchantment, and thecontainsmethod of theListclass 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
xpCostto 1. The amount of experience points required to repair 1 durability point is now 1. - Configuration option
repairAmountto 2. The amount of durability points repaired per use is now 2.
Removed
- Unused
metricsvariable from theonEnablemethod.
Added bstats to project for plugin analytics
Initial release of BetterMending Repair amounts and costs are configurable



