<commit_before>package com.gmail.nossr50.skills.mining;

import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;

public class SuperBreakerEventHandler {
    private MiningManager manager;
    private Block block;
    private Material blockType;
    private boolean customBlock;
    private ItemStack heldItem;
    private int tier;
    private int durabilityLoss;
    private FakePlayerAnimationEvent armswing;

    protected SuperBreakerEventHandler (MiningManager manager, Block block) {
        this.manager = manager;
        this.block = block;
        this.blockType = block.getType();
        this.customBlock = ModChecks.isCustomMiningBlock(block);
        Player player = manager.getMcMMOPlayer().getPlayer();
        this.heldItem = player.getItemInHand();
        this.tier = Misc.getTier(heldItem);
        this.armswing = new FakePlayerAnimationEvent(player);

        calculateDurabilityLoss();
    }

    protected void callFakeArmswing() {
        mcMMO.p.getServer().getPluginManager().callEvent(armswing);
    }

    protected void processDurabilityLoss() {
        SkillTools.abilityDurabilityLoss(heldItem, durabilityLoss);
    }

    protected void processDropsAndXP() {
        manager.miningBlockCheck(block);
    }

    protected void playSound() {
        manager.getMcMMOPlayer().getPlayer().playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
    }

    /**
     * Check for the proper tier of item for use with Super Breaker.
     *
     * @return True if the item is the required tier or higher, false otherwise
     */
    protected boolean tierCheck() {
        if (customBlock) {
            if (ModChecks.getCustomBlock(block).getTier() < tier) {
                return false;
            }

            return true;
        }

        switch (blockType) {
        case OBSIDIAN:
            if (tier < Mining.DIAMOND_TOOL_TIER) {
                return false;
            }
            /* FALL THROUGH */

        case DIAMOND_ORE:
        case GLOWING_REDSTONE_ORE:
        case GOLD_ORE:
        case LAPIS_ORE:
        case REDSTONE_ORE:
        case EMERALD_ORE:
            if (tier < Mining.IRON_TOOL_TIER) {
                return false;
            }
            /* FALL THROUGH */
<commit_msg>Fix Super Breaker not working right with custom blocks.<commit_after>package com.gmail.nossr50.skills.mining;

import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;

public class SuperBreakerEventHandler {
    private MiningManager manager;
    private Block block;
    private Material blockType;
    private boolean customBlock;
    private ItemStack heldItem;
    private int tier;
    private int durabilityLoss;
    private FakePlayerAnimationEvent armswing;
    private Player player;

    protected SuperBreakerEventHandler (MiningManager manager, Block block) {
        this.manager = manager;
        this.block = block;
        this.blockType = block.getType();
        this.customBlock = ModChecks.isCustomMiningBlock(block);
        this.player = manager.getMcMMOPlayer().getPlayer();
        this.heldItem = player.getItemInHand();
        this.tier = Misc.getTier(heldItem);
        this.armswing = new FakePlayerAnimationEvent(player);

        calculateDurabilityLoss();
    }

    protected void callFakeArmswing() {
        mcMMO.p.getServer().getPluginManager().callEvent(armswing);
    }

    protected void processDurabilityLoss() {
        SkillTools.abilityDurabilityLoss(heldItem, durabilityLoss);
    }

    protected void processDropsAndXP() {
        manager.miningBlockCheck(block);
    }

    protected void playSound() {
        player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
    }

    /**
     * Check for the proper tier of item for use with Super Breaker.
     *
     * @return True if the item is the required tier or higher, false otherwise
     */
    protected boolean tierCheck() {
        if (customBlock) {
            if (tier < ModChecks.getCustomBlock(block).getTier()) {
                return false;
            }

            return true;
        }

        switch (blockType) {
        case OBSIDIAN:
            if (tier < Mining.DIAMOND_TOOL_TIER) {
                return false;
            }
            /* FALL THROUGH */

        case DIAMOND_ORE:
        case GLOWING_REDSTONE_ORE:
        case GOLD_ORE:
        case LAPIS_ORE:
        case REDSTONE_ORE:
        case EMERALD_ORE:
            if (tier < Mining.IRON_TOOL_TIER) {
                return false;
            }
            /* FALL THROUGH */

{'fraction_non_alphanumeric': 0.08765989465763732, 'fraction_numerical': 0.004514672686230248, 'mean_word_length': 2.578061911170929, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2656024', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1564, 'n_words': 336}