Skip to content

Commit

Permalink
Added McMMO anvil fix
Browse files Browse the repository at this point in the history
- Now you cannot repair or use sf materials to repair other items
- Translation key mcmmo-repair should be added
  • Loading branch information
Intybyte committed May 3, 2024
1 parent b841828 commit c6f242d
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +20,7 @@

/**
* This handles all integrations with {@link mcMMO}.
*
*
* @author TheBusyBiscuit
*
*/
Expand Down Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down

0 comments on commit c6f242d

Please sign in to comment.