From c6f242dbeeaf0aca3abe6ac4ca9b0da6e4b1855e Mon Sep 17 00:00:00 2001 From: Intybyte Date: Fri, 3 May 2024 18:09:52 +0200 Subject: [PATCH 1/2] Added McMMO anvil fix - Now you cannot repair or use sf materials to repair other items - Translation key mcmmo-repair should be added --- .../integrations/McMMOIntegration.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java index 6b9f2cf28e..8b42a081f8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java @@ -2,6 +2,7 @@ import javax.annotation.Nonnull; +import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -19,7 +20,7 @@ /** * This handles all integrations with {@link mcMMO}. - * + * * @author TheBusyBiscuit * */ @@ -54,6 +55,18 @@ public void onItemSalvage(McMMOPlayerSalvageCheckEvent e) { } } + @EventHandler(ignoreCancelled = true) + public void onItemRepair(McMMOPlayerRepairCheckEvent e) { + ItemStack repaired = e.getRepairedObject(); + ItemStack material = e.getRepairMaterial(); + + if (isSalvageable(repaired) && isSalvageable(material)) + return; + + e.setCancelled(true); + Slimefun.getLocalization().sendMessage(e.getPlayer(), "anvil.mcmmo-repair"); + } + @EventHandler(ignoreCancelled = true) public void onAutoDisenchant(AutoDisenchantEvent e) { try { @@ -67,10 +80,10 @@ public void onAutoDisenchant(AutoDisenchantEvent e) { * This method checks if an {@link ItemStack} can be salvaged or not. * We basically don't want players to salvage any {@link SlimefunItem} unless * it is a {@link VanillaItem}. - * + * * @param item * The {@link ItemStack} to check - * + * * @return Whether this item can be safely salvaged */ private boolean isSalvageable(@Nonnull ItemStack item) { From bd8dc27232c7a77cf6a045ab28b584470c878fd3 Mon Sep 17 00:00:00 2001 From: Vaan1310 <61906290+Intybyte@users.noreply.github.com> Date: Sat, 4 May 2024 13:46:44 +0200 Subject: [PATCH 2/2] Update src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java Co-authored-by: J3fftw <44972470+J3fftw1@users.noreply.github.com> --- .../slimefun4/integrations/McMMOIntegration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java index 8b42a081f8..2c6886d816 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/integrations/McMMOIntegration.java @@ -60,8 +60,9 @@ public void onItemRepair(McMMOPlayerRepairCheckEvent e) { ItemStack repaired = e.getRepairedObject(); ItemStack material = e.getRepairMaterial(); - if (isSalvageable(repaired) && isSalvageable(material)) + if (isSalvageable(repaired) && isSalvageable(material)) { return; + } e.setCancelled(true); Slimefun.getLocalization().sendMessage(e.getPlayer(), "anvil.mcmmo-repair");