Hire an Excavation manager.

This commit is contained in:
GJ
2013-02-26 18:06:30 -05:00
parent 4392e6b9ab
commit f388948f04
5 changed files with 86 additions and 62 deletions

View File

@ -0,0 +1,59 @@
package com.gmail.nossr50.skills.excavation;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class ExcavationManager extends SkillManager {
public ExcavationManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.EXCAVATION);
}
/**
* Process treasure drops & XP gain for Excavation.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param player The {@link Player} using this ability
*/
public void excavationBlockCheck(BlockState blockState) {
int xp = Excavation.getBlockXP(blockState);
if (Permissions.excavationTreasureHunter(getPlayer())) {
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
if (!treasures.isEmpty()) {
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
xp += treasure.getXp();
Misc.dropItem(location, treasure.getDrop());
}
}
}
}
applyXpGain(xp);
}
/**
* Process the Giga Drill Breaker ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param player The {@link Player} using this ability
*/
public void gigaDrillBreaker(BlockState blockState) {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
}
}