From 0432f28d6fd8acaf175ed04a558fc1d953b402ce Mon Sep 17 00:00:00 2001
From: moo <48740106+moom0o@users.noreply.github.com>
Date: Tue, 29 Mar 2022 16:54:57 -0400
Subject: [PATCH] 1.25.0 - Fix enchanted gapples reverting
---
README.md | 4 ++-
pom.xml | 2 +-
.../me/moomoo/anarchyexploitfixes/Main.java | 32 +++++++++++--------
src/main/resources/config.yml | 4 ++-
4 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 171ebae1d..f9a87d21e 100644
--- a/README.md
+++ b/README.md
@@ -143,8 +143,10 @@ RevertStackedItems: true
RevertEnchantments: true
RevertUnEnchantable: true # Removes enchantments that normally can't be applied to that item.
RevertSpecificEnchantments: false # Only revert specific enchantments
-SpecificEnchantments:
+SpecificEnchantments: # If RevertSpecificEnchantments is enabled, only these specific enchantments will be reverted.
- "DIG_SPEED" # The name of the enchantment in the spigot api
+ItemsSkipped: # Items that won't be reverted from illegal enchants or unbreakablity.
+ - "GOLDEN_APPLE" # Make sure to keep this line here or else enchanted golden apples will be reverted to normal ones.
RevertUnbreakables:
Enabled: true # Revert unbreakable items, items with less than 0 durability will be automatically removed or set to 0 durability, which will break on the next use. Items with higher than max durability will be set to legal maximum durability.
# Only removes player heads, not mob heads
diff --git a/pom.xml b/pom.xml
index a88e48fe0..ceeab5072 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.moomoo
anarchyexploitfixes
- 1.24.0
+ 1.25.0
jar
AnarchyExploitFixes
diff --git a/src/main/java/me/moomoo/anarchyexploitfixes/Main.java b/src/main/java/me/moomoo/anarchyexploitfixes/Main.java
index f2942cbd0..9a96b0157 100644
--- a/src/main/java/me/moomoo/anarchyexploitfixes/Main.java
+++ b/src/main/java/me/moomoo/anarchyexploitfixes/Main.java
@@ -240,11 +240,13 @@ public void revert(ItemStack item) {
}
if (getConfig().getBoolean("RevertUnbreakables.Enabled")) {
- if (item.getDurability() > item.getType().getMaxDurability()) {
- item.setDurability(item.getType().getMaxDurability());
- }
- if (item.getDurability() < 0) {
- item.subtract(item.getAmount());
+ if (!getConfig().getStringList("ItemsSkipped").contains(item.getType().name())) {
+ if (item.getDurability() > item.getType().getMaxDurability()) {
+ item.setDurability(item.getType().getMaxDurability());
+ }
+ if (item.getDurability() < 0) {
+ item.subtract(item.getAmount());
+ }
}
}
@@ -268,18 +270,20 @@ public void revert(ItemStack item) {
}
private void revertEnchantments(ItemStack item) {
- for (Map.Entry entry : item.getEnchantments().entrySet()) {
- if (entry.getValue() != null && entry.getKey() != null) {
- if (getConfig().getBoolean("RevertSpecificEnchantments")) {
- for (String s : getConfig().getStringList("SpecificEnchantments")) {
- if (entry.getValue() > entry.getKey().getMaxLevel() && entry.getKey().getName().contains(s)) {
+ if (!getConfig().getStringList("ItemsSkipped").contains(item.getType().name())) {
+ for (Map.Entry entry : item.getEnchantments().entrySet()) {
+ if (entry.getValue() != null && entry.getKey() != null) {
+ if (getConfig().getBoolean("RevertSpecificEnchantments")) {
+ for (String s : getConfig().getStringList("SpecificEnchantments")) {
+ if (entry.getValue() > entry.getKey().getMaxLevel() && entry.getKey().getName().contains(s)) {
+ replaceEnchantment(item, entry.getKey(), entry.getKey().getMaxLevel());
+ }
+ }
+ } else {
+ if (entry.getValue() > entry.getKey().getMaxLevel()) {
replaceEnchantment(item, entry.getKey(), entry.getKey().getMaxLevel());
}
}
- } else {
- if (entry.getValue() > entry.getKey().getMaxLevel()) {
- replaceEnchantment(item, entry.getKey(), entry.getKey().getMaxLevel());
- }
}
}
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 8659b0854..bd3db944b 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -16,8 +16,10 @@ RevertStackedItems: true
RevertEnchantments: true
RevertUnEnchantable: true # Removes enchantments that normally can't be applied to that item.
RevertSpecificEnchantments: false # Only revert specific enchantments
-SpecificEnchantments:
+SpecificEnchantments: # If RevertSpecificEnchantments is enabled, only these specific enchantments will be reverted.
- "DIG_SPEED" # The name of the enchantment in the spigot api
+ItemsSkipped: # Items that won't be reverted from illegal enchants or unbreakablity.
+ - "GOLDEN_APPLE" # Make sure to keep this line here or else enchanted golden apples will be reverted to normal ones.
RevertUnbreakables:
Enabled: true # Revert unbreakable items, items with less than 0 durability will be automatically removed or set to 0 durability, which will break on the next use. Items with higher than max durability will be set to legal maximum durability.
# Only removes player heads, not mob heads