package com.gmail.nossr50.skills.mining; import org.bukkit.Material; import org.bukkit.block.BlockState; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.ModUtils; public class Mining { public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel(); public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getMiningDoubleDropChance(); /** * Calculate XP gain for Mining. * * @param blockState The {@link BlockState} to check ability activation for */ protected static int getBlockXp(BlockState blockState) { Material blockType = blockState.getType(); int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType); if (xp == 0) { if (blockType == Material.GLOWING_REDSTONE_ORE) { xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE); } else if (ModUtils.isCustomMiningBlock(blockState)) { xp = ModUtils.getCustomBlock(blockState).getXpGain(); } } return xp; } /** * Handle double drops when using Silk Touch. * * @param blockState The {@link BlockState} to check ability activation for */ protected static void handleSilkTouchDrops(BlockState blockState) { Material blockType = blockState.getType(); switch (blockType) { case ENDER_STONE: case GOLD_ORE: case IRON_ORE: case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: case SANDSTONE: handleMiningDrops(blockState); return; case GLOWING_REDSTONE_ORE: if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE)); } return; case COAL_ORE: case DIAMOND_ORE: case REDSTONE_ORE: case GLOWSTONE: case LAPIS_ORE: case STONE: case EMERALD_ORE: case QUARTZ_ORE: Misc.dropItem(blockState.getLocation(), new ItemStack(blockType)); return; default: if (ModUtils.isCustomMiningBlock(blockState)) { Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); } return; } } /** * Handle double drops from Mining & Blast Mining. * * @param blockState The {@link BlockState} to check ability activation for */ protected static void handleMiningDrops(BlockState blockState) { switch (blockState.getType()) { case COAL_ORE: case DIAMOND_ORE: case EMERALD_ORE: case GLOWSTONE: case LAPIS_ORE: case STONE: case ENDER_STONE: case GOLD_ORE: case IRON_ORE: case MOSSY_COBBLESTONE: case NETHERRACK: case OBSIDIAN: case REDSTONE_ORE: case SANDSTONE: case QUARTZ_ORE: Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); return; case GLOWING_REDSTONE_ORE: if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) { Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); } return; default: if (ModUtils.isCustomMiningBlock(blockState)) { Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops()); } return; } } }