mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-03-30 16:26:24 +02:00
62 lines
2.2 KiB
Java
62 lines
2.2 KiB
Java
package com.gmail.nossr50.skills.excavation;
|
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.block.BlockState;
|
|
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbilityType;
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|
import com.gmail.nossr50.skills.SkillManager;
|
|
import com.gmail.nossr50.util.Misc;
|
|
import com.gmail.nossr50.util.Permissions;
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
|
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
|
|
*/
|
|
public void excavationBlockCheck(BlockState blockState) {
|
|
int xp = Excavation.getBlockXP(blockState);
|
|
|
|
if (Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbilityType.EXCAVATION_TREASURE_HUNTER)) {
|
|
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
|
|
|
|
if (!treasures.isEmpty()) {
|
|
int skillLevel = getSkillLevel();
|
|
Location location = blockState.getLocation();
|
|
|
|
for (ExcavationTreasure treasure : treasures) {
|
|
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
|
|
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
|
|
*/
|
|
public void gigaDrillBreaker(BlockState blockState) {
|
|
excavationBlockCheck(blockState);
|
|
excavationBlockCheck(blockState);
|
|
|
|
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
|
}
|
|
}
|