diff --git a/Changelog.txt b/Changelog.txt
index 961605906..a3c96c60d 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,15 @@
+Version 2.2.006
+ Added new config custom_item_support.yml
+ Added setting to disable repair on items with custom models, this is not on by default
+ Added new locale entry 'Anvil.Repair.Reject.CustomModelData'
+ Added new locale entry 'Anvil.Salvage.Reject.CustomModelData'
+
+ NOTES:
+ Let me know in detail what kind of support you'd like to see in mcMMO regarding custom items, I'm open to suggestions.
+ This update adds a new config file to allow server owners to disable repair or salvage on items with custom models,
+ This prevention mechanism is not enabled by default, change the settings in custom_item_support.yml if you want to enable it.
+ This feature is off by default for now to keep compatibility with existing servers, but it may be enabled by default in the future if feedback suggests it should be.
+
Version 2.2.005
Fixed a bug where certain skills such as Dodge/Arrow Deflect had no skill cap and would continue improving forever
Reduced messages on startup for SQL DB
diff --git a/pom.xml b/pom.xml
index fbc6aae9a..e780ca2f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.2.005
+ 2.2.006-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/config/CustomItemSupportConfig.java b/src/main/java/com/gmail/nossr50/config/CustomItemSupportConfig.java
new file mode 100644
index 000000000..51731d367
--- /dev/null
+++ b/src/main/java/com/gmail/nossr50/config/CustomItemSupportConfig.java
@@ -0,0 +1,23 @@
+package com.gmail.nossr50.config;
+
+import java.io.File;
+
+public class CustomItemSupportConfig extends BukkitConfig {
+ public CustomItemSupportConfig(File dataFolder) {
+ super("custom_item_support.yml", dataFolder);
+ validate();
+ }
+
+ @Override
+ protected void loadKeys() {
+
+ }
+
+ public boolean isCustomRepairAllowed() {
+ return config.getBoolean("Custom_Item_Support.Repair.Allow_Repair_On_Items_With_Custom_Model_Data", true);
+ }
+
+ public boolean isCustomSalvageAllowed() {
+ return config.getBoolean("Custom_Item_Support.Salvage.Allow_Salvage_On_Items_With_Custom_Model_Data", true);
+ }
+}
diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java
index d76efa993..a8c1c8601 100644
--- a/src/main/java/com/gmail/nossr50/mcMMO.java
+++ b/src/main/java/com/gmail/nossr50/mcMMO.java
@@ -140,6 +140,7 @@ public class mcMMO extends JavaPlugin {
private GeneralConfig generalConfig;
private AdvancedConfig advancedConfig;
private PartyConfig partyConfig;
+ private CustomItemSupportConfig customItemSupportConfig;
private FoliaLib foliaLib;
private PartyManager partyManager;
@@ -185,6 +186,7 @@ public class mcMMO extends JavaPlugin {
//Init configs
advancedConfig = new AdvancedConfig(getDataFolder());
partyConfig = new PartyConfig(getDataFolder());
+ customItemSupportConfig = new CustomItemSupportConfig(getDataFolder());
//Store this value so other plugins can check it
isRetroModeEnabled = generalConfig.getIsRetroMode();
@@ -806,6 +808,10 @@ public class mcMMO extends JavaPlugin {
return partyManager;
}
+ public CustomItemSupportConfig getCustomItemSupportConfig() {
+ return customItemSupportConfig;
+ }
+
public @NotNull FoliaLib getFoliaLib() {
return foliaLib;
}
diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java
index fb9d6ceb3..08a6ce8e8 100644
--- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java
@@ -65,10 +65,19 @@ public class RepairManager extends SkillManager {
public void handleRepair(ItemStack item) {
Player player = getPlayer();
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
+ if (item.getItemMeta() != null) {
+ if(item.getItemMeta().hasCustomModelData()) {
+ if(!mcMMO.p.getCustomItemSupportConfig().isCustomRepairAllowed()) {
+ NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED,
+ "Anvil.Repair.Reject.CustomModelData");
+ return;
+ }
+ }
- if (item.getItemMeta().isUnbreakable()) {
- NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
- return;
+ if (item.getItemMeta().isUnbreakable()) {
+ NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
+ return;
+ }
}
// Permissions checks on material and item types
diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java
index 7546b1c99..cffd2bf37 100644
--- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java
+++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java
@@ -62,14 +62,19 @@ public class SalvageManager extends SkillManager {
}
public void handleSalvage(Location location, ItemStack item) {
- Player player = getPlayer();
+ final Player player = getPlayer();
- Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
- ItemMeta meta = item.getItemMeta();
-
- if (meta != null && meta.isUnbreakable()) {
- NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
- return;
+ final Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
+ final ItemMeta meta = item.getItemMeta();
+ if (meta != null) {
+ if (meta.hasCustomModelData() && !mcMMO.p.getCustomItemSupportConfig().isCustomSalvageAllowed()) {
+ NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Salvage.Reject.CustomModelData");
+ return;
+ }
+ if (meta.isUnbreakable()) {
+ NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Anvil.Unbreakable");
+ return;
+ }
}
// Permissions checks on material and item types
@@ -190,30 +195,6 @@ public class SalvageManager extends SkillManager {
return RankUtils.getRank(getPlayer(), SubSkillType.SALVAGE_ARCANE_SALVAGE);
}
- /*public double getExtractFullEnchantChance() {
- int skillLevel = getSkillLevel();
-
- for (Tier tier : Tier.values()) {
- if (skillLevel >= tier.getLevel()) {
- return tier.getExtractFullEnchantChance();
- }
- }
-
- return 0;
- }
-
- public double getExtractPartialEnchantChance() {
- int skillLevel = getSkillLevel();
-
- for (Tier tier : Tier.values()) {
- if (skillLevel >= tier.getLevel()) {
- return tier.getExtractPartialEnchantChance();
- }
- }
-
- return 0;
- }*/
-
public double getExtractFullEnchantChance() {
if(Permissions.hasSalvageEnchantBypassPerk(getPlayer()))
return 100.0D;
diff --git a/src/main/resources/custom_item_support.yml b/src/main/resources/custom_item_support.yml
new file mode 100644
index 000000000..76285867e
--- /dev/null
+++ b/src/main/resources/custom_item_support.yml
@@ -0,0 +1,11 @@
+# This is meant to be a general config for allowing mcMMO to allow interaction with custom items.
+# In the future, I would like to add configs to be specific about certain custom items.
+# For now, support is generalized to whether the custom item has a custom model.
+# This is an easy solution to implement for now, but not the most ideal.
+Custom_Item_Support:
+ Repair:
+ # Turn this off to disable repair on any items with custom model data
+ Allow_Repair_On_Items_With_Custom_Model_Data: true
+ Salvage:
+ # Turn this off to disable salvage on any items with custom model data
+ Allow_Salvage_On_Items_With_Custom_Model_Data: true
diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties
index 84316e4c5..7da72244d 100644
--- a/src/main/resources/locale/locale_en_US.properties
+++ b/src/main/resources/locale/locale_en_US.properties
@@ -423,6 +423,8 @@ Salvage.Skills.Lottery.Perfect=&a&lPerfect!&r&6 You salvaged &3{1}&6 effortlessl
Salvage.Skills.Lottery.Untrained=&7You aren't properly trained in salvaging. You were only able to recover &c{0}&7 materials from &a{1}&7.
#Anvil (Shared between SALVAGE and REPAIR)
Anvil.Unbreakable=This item is unbreakable!
+Anvil.Repair.Reject.CustomModelData=A mysterious force prevents you from repairing this item...
+Anvil.Salvage.Reject.CustomModelData=A mysterious force prevents you from salvaging this item...
#CROSSBOWS
Crossbows.SkillName=CROSSBOWS
Crossbows.Ability.Lower=&7You lower your crossbow.