2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.skills.mining;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
2014-03-03 18:27:45 +01:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-08-23 10:16:22 +02:00
|
|
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
|
|
|
|
|
public class Mining {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculate XP gain for Mining.
|
|
|
|
*
|
|
|
|
* @param blockState The {@link BlockState} to check ability activation for
|
|
|
|
*/
|
2014-12-22 17:25:55 +01:00
|
|
|
public static int getBlockXp(BlockState blockState) {
|
2013-03-01 06:52:01 +01:00
|
|
|
Material blockType = blockState.getType();
|
2013-10-31 18:25:06 +01:00
|
|
|
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
|
|
|
|
2014-02-03 20:48:43 +01:00
|
|
|
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
|
|
|
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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:
|
2013-12-02 18:08:12 +01:00
|
|
|
case HARD_CLAY:
|
2013-03-01 06:52:01 +01:00
|
|
|
case IRON_ORE:
|
|
|
|
case MOSSY_COBBLESTONE:
|
|
|
|
case NETHERRACK:
|
|
|
|
case OBSIDIAN:
|
|
|
|
case SANDSTONE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case STAINED_CLAY:
|
2013-03-01 06:52:01 +01:00
|
|
|
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:
|
2013-12-02 18:08:12 +01:00
|
|
|
case EMERALD_ORE:
|
2013-03-01 06:52:01 +01:00
|
|
|
case GLOWSTONE:
|
|
|
|
case LAPIS_ORE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case PACKED_ICE:
|
2013-03-22 00:05:34 +01:00
|
|
|
case QUARTZ_ORE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case REDSTONE_ORE:
|
|
|
|
case STONE:
|
2013-03-01 06:52:01 +01:00
|
|
|
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
2013-03-08 13:40:25 +01:00
|
|
|
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle double drops from Mining & Blast Mining.
|
|
|
|
*
|
|
|
|
* @param blockState The {@link BlockState} to check ability activation for
|
|
|
|
*/
|
|
|
|
protected static void handleMiningDrops(BlockState blockState) {
|
2013-10-09 17:44:45 +02:00
|
|
|
switch (blockState.getType()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case COAL_ORE:
|
|
|
|
case DIAMOND_ORE:
|
|
|
|
case EMERALD_ORE:
|
|
|
|
case ENDER_STONE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case GLOWSTONE:
|
2013-03-01 06:52:01 +01:00
|
|
|
case GOLD_ORE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case HARD_CLAY:
|
2013-03-01 06:52:01 +01:00
|
|
|
case IRON_ORE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case LAPIS_ORE:
|
2013-03-01 06:52:01 +01:00
|
|
|
case MOSSY_COBBLESTONE:
|
|
|
|
case NETHERRACK:
|
|
|
|
case OBSIDIAN:
|
2013-12-02 18:08:12 +01:00
|
|
|
case PACKED_ICE:
|
2013-10-09 17:44:45 +02:00
|
|
|
case REDSTONE_ORE:
|
2013-03-01 06:52:01 +01:00
|
|
|
case SANDSTONE:
|
2013-12-02 18:08:12 +01:00
|
|
|
case STAINED_CLAY:
|
|
|
|
case STONE:
|
2013-03-22 00:05:34 +01:00
|
|
|
case QUARTZ_ORE:
|
2013-10-09 17:44:45 +02:00
|
|
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
2013-03-01 06:52:01 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
case GLOWING_REDSTONE_ORE:
|
|
|
|
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
|
2013-10-09 17:44:45 +02:00
|
|
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
return;
|
2013-10-09 17:44:45 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
default:
|
2014-02-03 20:48:43 +01:00
|
|
|
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
|
2013-10-09 17:44:45 +02:00
|
|
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|