From 1489203acaabfd48efe4868a51f7b5d7f48722b6 Mon Sep 17 00:00:00 2001 From: snowleo Date: Fri, 2 Dec 2011 08:30:52 +0100 Subject: [PATCH] New config options repair-enchanted (default true) and permission essentials.repair.enchanted --- .../src/com/earth2me/essentials/ISettings.java | 2 ++ .../src/com/earth2me/essentials/Settings.java | 4 ++++ .../essentials/commands/Commandrepair.java | 14 ++++++++++++++ Essentials/src/config.yml | 5 +++++ 4 files changed, 25 insertions(+) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 9724d1a16..d7764ed16 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -138,4 +138,6 @@ public interface ISettings extends IConf Set getNoGodWorlds(); boolean getUpdateBedAtDaytime(); + + boolean getRepairEnchanted(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index ac74329ec..b65d53616 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -549,4 +549,8 @@ public class Settings implements ISettings { this.debug = debug; } + + public boolean getRepairEnchanted() { + return config.getBoolean("repair-enchanted", true); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index 50c6ac7af..cf9e43f9f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -32,6 +32,14 @@ public class Commandrepair extends EssentialsCommand { throw new Exception(_("repairInvalidType")); } + + if (!item.getEnchantments().isEmpty() + && !ess.getSettings().getRepairEnchanted() + && !user.isAuthorized("essentials.repair.enchanted")) + { + throw new Exception(_("repairEnchanted")); + } + final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH); final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess); @@ -104,6 +112,12 @@ public class Commandrepair extends EssentialsCommand user.sendMessage(ex.getMessage()); continue; } + if (!item.getEnchantments().isEmpty() + && !ess.getSettings().getRepairEnchanted() + && !user.isAuthorized("essentials.repair.enchanted")) + { + continue; + } try { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index e1a7e9d5a..f9eaa2ba4 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -227,6 +227,11 @@ no-god-in-worlds: # How many items should be in a oversized stack? oversized-stacksize: 64 +# Do you allow to repair enchanted weapons and armor? +# If you set this to false, you can still allow it for certain players using the permission +# essentials.repair.enchanted +repair-enchanted: true + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | #