mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-15 03:54:43 +02:00
Hire an Excavation manager.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user