Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added McMMO anvil fix #4182

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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");
Intybyte marked this conversation as resolved.
Show resolved Hide resolved
}

@EventHandler(ignoreCancelled = true)
public void onAutoDisenchant(AutoDisenchantEvent e) {
try {
Expand All @@ -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) {
Expand Down
Loading