diff --git a/README.md b/README.md index f8f17d45..09bd0292 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@


- EcoEnchants logo + EcoEnchants logo

diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java deleted file mode 100644 index fc4e6868..00000000 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoenchants/proxy/v1_16_R3/RepairCost.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.willfp.ecoenchants.proxy.v1_16_R3; - -import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; -import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public final class RepairCost implements RepairCostProxy { - @Override - public ItemStack setRepairCost(@NotNull final ItemStack itemStack, - final int cost) { - net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - nmsStack.setRepairCost(cost); - return CraftItemStack.asBukkitCopy(nmsStack); - } - - @Override - public int getRepairCost(@NotNull final ItemStack itemStack) { - net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - return nmsStack.getRepairCost(); - } -} diff --git a/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_17_R1/RepairCost.java b/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_17_R1/RepairCost.java deleted file mode 100644 index ce98da51..00000000 --- a/eco-core/core-nms/v1_17_R1/src/main/java/com/willfp/ecoenchants/proxy/v1_17_R1/RepairCost.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.willfp.ecoenchants.proxy.v1_17_R1; - -import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; -import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public final class RepairCost implements RepairCostProxy { - @Override - public ItemStack setRepairCost(@NotNull final ItemStack itemStack, - final int cost) { - net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - nmsStack.setRepairCost(cost); - return CraftItemStack.asBukkitCopy(nmsStack); - } - - @Override - public int getRepairCost(@NotNull final ItemStack itemStack) { - net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(itemStack); - return nmsStack.getRepairCost(); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandLocaleDownload.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandLocaleDownload.java index 64f6a878..0413cc37 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandLocaleDownload.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/command/CommandLocaleDownload.java @@ -2,6 +2,8 @@ package com.willfp.ecoenchants.command; import com.willfp.eco.core.command.CommandHandler; import com.willfp.eco.core.command.impl.Subcommand; +import com.willfp.eco.core.config.interfaces.Config; +import com.willfp.eco.core.config.yaml.YamlTransientConfig; import com.willfp.eco.core.web.Paste; import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchant; @@ -31,7 +33,13 @@ public class CommandLocaleDownload extends Subcommand { } Paste paste = Paste.getFromHastebin(args.get(0)); - YamlConfiguration configuration = YamlConfiguration.loadConfiguration(new StringReader(paste.getContents())); + if (paste == null) { + sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-locale")); + return; + } + + String contents = paste.getContents(); + Config configuration = new YamlTransientConfig(contents); for (String key : configuration.getKeys(true)) { this.getPlugin().getLangYml().set(key, configuration.get(key)); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java index 91f78624..7bcf244a 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/display/EnchantDisplay.java @@ -190,8 +190,10 @@ public class EnchantDisplay extends DisplayModule { @Override public void revert(@NotNull final ItemStack itemStack) { - if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { - return; + if (options.isRequireTarget()) { + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return; + } } FastItemStack fast = FastItemStack.wrap(itemStack); @@ -217,6 +219,12 @@ public class EnchantDisplay extends DisplayModule { @Override public Object[] generateVarArgs(@NotNull final ItemStack itemStack) { + if (options.isRequireTarget()) { + if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) { + return new Object[]{false}; + } + } + ItemMeta meta = itemStack.getItemMeta(); if (meta == null) { return new Object[]{false}; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java index 11810094..c374aa21 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/support/merging/anvil/AnvilListeners.java @@ -6,7 +6,6 @@ import com.willfp.eco.core.fast.FastItemStack; import com.willfp.eco.core.proxy.ProxyConstants; import com.willfp.eco.util.NumberUtils; import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy; -import com.willfp.ecoenchants.proxy.proxies.RepairCostProxy; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -125,14 +124,16 @@ public class AnvilListeners extends PluginDependent implements Listen } if (this.getPlugin().getConfigYml().getBool("anvil.rework-cost")) { - int repairCost = this.getPlugin().getProxy(RepairCostProxy.class).getRepairCost(item); + int repairCost = FastItemStack.wrap(item).getRepairCost(); int reworkCount = NumberUtils.log2(repairCost + 1); if (repairCost == 0) { reworkCount = 0; } reworkCount++; repairCost = (int) Math.pow(2, reworkCount) - 1; - item = this.getPlugin().getProxy(RepairCostProxy.class).setRepairCost(item, repairCost); + FastItemStack fis = FastItemStack.wrap(item); + fis.setRepairCost(repairCost); + item = fis.unwrap(); } int cost; diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java deleted file mode 100644 index 98821b08..00000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/ecoenchants/proxy/proxies/RepairCostProxy.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.willfp.ecoenchants.proxy.proxies; - -import com.willfp.eco.core.proxy.AbstractProxy; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public interface RepairCostProxy extends AbstractProxy { - /** - * Set the rework penalty of an item. - * - * @param itemStack The item to query. - * @param cost The rework penalty to set. - * @return The item, with the rework penalty applied. - */ - ItemStack setRepairCost(@NotNull ItemStack itemStack, - int cost); - - /** - * Get the rework penalty of an item. - * - * @param itemStack The item to query. - * @return The rework penalty found on the item. - */ - int getRepairCost(@NotNull ItemStack itemStack); -} diff --git a/gradle.properties b/gradle.properties index fa5c1c0a..b4428374 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 8.13.5 +version = 8.13.9 plugin-name = EcoEnchants \ No newline at end of file