2013-01-07 18:51:39 +01:00
|
|
|
package com.gmail.nossr50.skills.mining;
|
|
|
|
|
2013-01-08 15:35:41 +01:00
|
|
|
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;
|
2013-01-08 18:52:16 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2013-01-07 18:51:39 +01:00
|
|
|
|
|
|
|
import com.gmail.nossr50.util.Misc;
|
|
|
|
|
2013-01-08 15:35:41 +01:00
|
|
|
public class MiningBlockEventHandler {
|
2013-01-07 18:51:39 +01:00
|
|
|
private MiningManager manager;
|
2013-01-08 18:52:16 +01:00
|
|
|
private Player player;
|
2013-01-08 15:35:41 +01:00
|
|
|
|
2013-01-07 18:51:39 +01:00
|
|
|
private Block block;
|
2013-01-08 15:35:41 +01:00
|
|
|
private Location blockLocation;
|
|
|
|
private Material blockType;
|
2013-01-07 18:51:39 +01:00
|
|
|
|
|
|
|
protected int skillModifier;
|
|
|
|
|
2013-01-08 15:35:41 +01:00
|
|
|
protected MiningBlockEventHandler(MiningManager manager, Block block) {
|
2013-01-07 18:51:39 +01:00
|
|
|
this.manager = manager;
|
2013-01-08 18:52:16 +01:00
|
|
|
this.player = manager.getPlayer();
|
2013-01-08 15:35:41 +01:00
|
|
|
|
2013-01-07 18:51:39 +01:00
|
|
|
this.block = block;
|
2013-01-08 15:35:41 +01:00
|
|
|
this.blockLocation = block.getLocation();
|
|
|
|
this.blockType = block.getType();
|
2013-01-07 18:51:39 +01:00
|
|
|
|
|
|
|
calculateSkillModifier();
|
|
|
|
}
|
|
|
|
|
2013-01-10 01:45:34 +01:00
|
|
|
private void calculateSkillModifier() {
|
2013-01-22 08:20:05 +01:00
|
|
|
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Mining.doubleDropsMaxLevel);
|
2013-01-07 18:51:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process Mining block drops.
|
|
|
|
*/
|
|
|
|
protected void processDrops() {
|
2013-01-08 18:52:16 +01:00
|
|
|
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
2013-01-08 15:35:41 +01:00
|
|
|
Mining.silkTouchDrops(block, blockLocation, blockType);
|
2013-01-07 18:51:39 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-01-08 15:35:41 +01:00
|
|
|
Mining.miningDrops(block, blockLocation, blockType);
|
2013-01-07 18:51:39 +01:00
|
|
|
}
|
|
|
|
}
|
2013-01-08 15:42:37 +01:00
|
|
|
|
2013-01-10 01:45:34 +01:00
|
|
|
protected void processXPGain() {
|
2013-01-08 18:52:16 +01:00
|
|
|
Mining.miningXP(player, manager.getProfile(), block, blockType);
|
2013-01-08 15:42:37 +01:00
|
|
|
}
|
2013-01-07 18:51:39 +01:00
|
|
|
}
|