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..2c6886d816 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,19 @@ 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 +81,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) { diff --git a/src/main/resources/languages/en/messages.yml b/src/main/resources/languages/en/messages.yml index 81d5115c30..9bcd5d6524 100644 --- a/src/main/resources/languages/en/messages.yml +++ b/src/main/resources/languages/en/messages.yml @@ -339,6 +339,7 @@ machines: anvil: not-working: '&4You cannot use Slimefun items in an anvil!' mcmmo-salvaging: '&4You cannot salvage Slimefun items!' + mcmmo-repair: '&4You cannot repair using Slimefun items!' brewing_stand: not-working: '&4You cannot use Slimefun items in a brewing stand!'