mcMMO/src/main/java/com/gmail/nossr50/skills/mining/MiningBlockEventHandler.java

48 lines
1.3 KiB
Java
Raw Normal View History

2013-01-07 18:51:39 +01:00
package com.gmail.nossr50.skills.mining;
import org.bukkit.Location;
import org.bukkit.Material;
2013-01-07 18:51:39 +01:00
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.util.Misc;
public class MiningBlockEventHandler {
2013-01-07 18:51:39 +01:00
private MiningManager manager;
2013-01-07 18:51:39 +01:00
private Block block;
private Location blockLocation;
private Material blockType;
2013-01-07 18:51:39 +01:00
protected int skillModifier;
protected MiningBlockEventHandler(MiningManager manager, Block block) {
2013-01-07 18:51:39 +01:00
this.manager = manager;
2013-01-07 18:51:39 +01:00
this.block = block;
this.blockLocation = block.getLocation();
this.blockType = block.getType();
2013-01-07 18:51:39 +01:00
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Mining.DOUBLE_DROPS_MAX_BONUS_LEVEL);
}
/**
* Process Mining block drops.
*
* @param player The player mining the block
* @param block The block being broken
*/
protected void processDrops() {
if (manager.getPlayer().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
Mining.silkTouchDrops(block, blockLocation, blockType);
2013-01-07 18:51:39 +01:00
}
else {
Mining.miningDrops(block, blockLocation, blockType);
2013-01-07 18:51:39 +01:00
}
}
}