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

152 lines
4.5 KiB
Java
Raw Normal View History

2013-01-07 18:51:39 +01:00
package com.gmail.nossr50.skills.mining;
2013-01-10 03:44:53 +01:00
import org.bukkit.Material;
2013-01-07 18:51:39 +01:00
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
2013-01-10 01:45:34 +01:00
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
2013-01-10 03:44:53 +01:00
import org.bukkit.event.player.PlayerInteractEvent;
2013-01-07 18:51:39 +01:00
import com.gmail.nossr50.mcMMO;
2013-01-10 15:26:01 +01:00
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.SkillType;
2013-01-08 18:52:16 +01:00
import com.gmail.nossr50.util.Misc;
2013-01-07 18:51:39 +01:00
import com.gmail.nossr50.util.Permissions;
2013-01-10 15:26:01 +01:00
public class MiningManager extends SkillManager{
2013-01-07 18:51:39 +01:00
public MiningManager (Player player) {
2013-01-10 15:26:01 +01:00
super(player, SkillType.MINING);
2013-01-07 18:51:39 +01:00
}
2013-01-10 03:44:53 +01:00
/**
* Detonate TNT for Blast Mining
*
* @param event The PlayerInteractEvent
* @param player Player detonating the TNT
* @param plugin mcMMO plugin instance
*/
public void detonate(PlayerInteractEvent event) {
if (skillLevel < BlastMining.rank1) {
2013-01-10 03:44:53 +01:00
return;
}
RemoteDetonationEventHandler eventHandler = new RemoteDetonationEventHandler(this, event);
eventHandler.targetTNT();
if (eventHandler.block.getType() != Material.TNT) {
return;
}
if (!Misc.blockBreakSimulate(eventHandler.block, player, true)) {
return;
}
if (!eventHandler.cooldownOver()) {
return;
}
eventHandler.sendMessages();
eventHandler.handleDetonation();
eventHandler.setProfileData();
}
2013-01-10 01:45:34 +01:00
/**
* Handler for explosion drops and XP gain.
*
* @param event Event whose explosion is being processed
*/
public void blastMiningDropProcessing(EntityExplodeEvent event) {
if (Misc.isNPCPlayer(player)) {
2013-01-10 01:45:34 +01:00
return;
}
if (skillLevel < BlastMining.rank1) {
2013-01-10 01:45:34 +01:00
return;
}
BlastMiningDropEventHandler eventHandler = new BlastMiningDropEventHandler(this, event);
eventHandler.sortExplosionBlocks();
eventHandler.modifyEventYield();
eventHandler.calcuateDropModifiers();
eventHandler.processDroppedBlocks();
eventHandler.processXPGain();
}
/**
* Decreases damage dealt by the explosion from TNT activated by Blast Mining.
*
* @param event Event whose explosion damage is being reduced
*/
public void demolitionsExpertise(EntityDamageEvent event) {
DemoltionsExpertiseEventHandler eventHandler = new DemoltionsExpertiseEventHandler(this, event);
eventHandler.calculateDamageModifier();
eventHandler.modifyEventDamage();
}
/**
* Increases the blast radius of the explosion.
*
* @param player Player triggering the explosion
* @param event Event whose explosion radius is being changed
*/
public void biggerBombs(ExplosionPrimeEvent event) {
if (Misc.isNPCPlayer(player)) {
2013-01-10 01:45:34 +01:00
return;
}
BiggerBombsEventHandler eventHandler = new BiggerBombsEventHandler(this, event);
eventHandler.calculateRadiusIncrease();
eventHandler.modifyBlastRadius();
}
2013-01-07 18:51:39 +01:00
/**
* Process Mining block drops.
*
* @param block The block being broken
*/
public void miningBlockCheck(Block block) {
2013-01-08 15:42:37 +01:00
MiningBlockEventHandler eventHandler = new MiningBlockEventHandler(this, block);
2013-01-10 01:45:34 +01:00
eventHandler.processXPGain();
2013-01-07 18:51:39 +01:00
if (!Permissions.miningDoubleDrops(player)) {
return;
}
float chance = ((float) Mining.doubleDropsMaxChance / Mining.doubleDropsMaxLevel) * eventHandler.skillModifier;
2013-01-07 18:51:39 +01:00
2013-01-22 02:01:33 +01:00
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.processDrops();
2013-01-07 18:51:39 +01:00
}
}
2013-01-08 18:52:16 +01:00
/**
* Handle the Super Breaker ability.
*
* @param player The player using the ability
* @param block The block being affected
*/
public void superBreakerBlockCheck(Block block) {
if (mcMMO.placeStore.isTrue(block) || !Misc.blockBreakSimulate(block, player, true)) {
2013-01-08 18:52:16 +01:00
return;
}
SuperBreakerEventHandler eventHandler = new SuperBreakerEventHandler(this, block);
2013-01-08 18:52:16 +01:00
if (!eventHandler.tierCheck()) {
2013-01-08 18:52:16 +01:00
return;
}
eventHandler.callFakeArmswing();
eventHandler.processDurabilityLoss();
eventHandler.processDropsAndXP();
eventHandler.playSpoutSound();
}
2013-01-07 18:51:39 +01:00
}