mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
GIANT Blast Mining update. Lots of new config options in advanced.yml
This commit is contained in:
@ -1,42 +0,0 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
public class BiggerBombsEventHandler {
|
||||
private int skillLevel;
|
||||
|
||||
private ExplosionPrimeEvent event;
|
||||
private float radius;
|
||||
private float radiusModifier;
|
||||
|
||||
protected BiggerBombsEventHandler(MiningManager manager, ExplosionPrimeEvent event) {
|
||||
this.skillLevel = manager.getSkillLevel();
|
||||
|
||||
this.event = event;
|
||||
this.radius = event.getRadius();
|
||||
}
|
||||
|
||||
protected void calculateRadiusIncrease() {
|
||||
if (skillLevel < BlastMining.rank2) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= BlastMining.rank8) {
|
||||
radiusModifier = 4.0f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank6) {
|
||||
radiusModifier = 3.0f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank4) {
|
||||
radiusModifier = 2.0f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank2) {
|
||||
radiusModifier = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyBlastRadius() {
|
||||
radius = radius + radiusModifier;
|
||||
event.setRadius(radius);
|
||||
}
|
||||
}
|
@ -1,46 +1,103 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class BlastMining {
|
||||
public static int rank1 = AdvancedConfig.getInstance().getBlastMiningRank1();
|
||||
public static int rank2 = AdvancedConfig.getInstance().getBlastMiningRank2();
|
||||
public static int rank3 = AdvancedConfig.getInstance().getBlastMiningRank3();
|
||||
public static int rank4 = AdvancedConfig.getInstance().getBlastMiningRank4();
|
||||
public static int rank5 = AdvancedConfig.getInstance().getBlastMiningRank5();
|
||||
public static int rank6 = AdvancedConfig.getInstance().getBlastMiningRank6();
|
||||
public static int rank7 = AdvancedConfig.getInstance().getBlastMiningRank7();
|
||||
public static int rank8 = AdvancedConfig.getInstance().getBlastMiningRank8();
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
protected enum Tier {
|
||||
EIGHT(8) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank8();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank8();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank8();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank8();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank8();}},
|
||||
SEVEN(7) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank7();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank7();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank7();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank7();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank7();}},
|
||||
SIX(6) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank6();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank6();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank6();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank6();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank6();}},
|
||||
FIVE(5) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank5();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank5();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank5();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank5();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank5();}},
|
||||
FOUR(4) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank4();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank4();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank4();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank4();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank4();}},
|
||||
THREE(3) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank3();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank3();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank3();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank3();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank3();}},
|
||||
TWO(2) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank2();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank2();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank2();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank2();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank2();}},
|
||||
ONE(1) {
|
||||
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank1();}
|
||||
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank1();}
|
||||
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank1();}
|
||||
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank1();}
|
||||
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1();}
|
||||
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank1();}};
|
||||
|
||||
int numerical;
|
||||
|
||||
private Tier(int numerical) {
|
||||
this.numerical = numerical;
|
||||
}
|
||||
|
||||
public int toNumerical() {
|
||||
return numerical;
|
||||
}
|
||||
|
||||
abstract protected int getLevel();
|
||||
abstract protected double getBlastRadiusModifier();
|
||||
abstract protected double getOreBonus();
|
||||
abstract protected double getDebrisReduction();
|
||||
abstract protected double getBlastDamageDecrease();
|
||||
abstract protected int getDropMultiplier();
|
||||
}
|
||||
|
||||
public static int detonatorID = Config.getInstance().getDetonatorItemID();
|
||||
|
||||
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
||||
|
||||
public static boolean canUseDemolitionsExpertise(Player player) {
|
||||
return SkillTools.unlockLevelReached(player, SkillType.MINING, rank4) && Permissions.demolitionsExpertise(player);
|
||||
}
|
||||
protected static HashSet<Byte> generateTransparentBlockList() {
|
||||
HashSet<Byte> transparentBlocks = new HashSet<Byte>();
|
||||
|
||||
public static int processDemolitionsExpertise(Player player, int damage) {
|
||||
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.MINING);
|
||||
int modifiedDamage;
|
||||
|
||||
if (skillLevel >= BlastMining.rank8) {
|
||||
modifiedDamage = 0;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank6) {
|
||||
modifiedDamage = damage / 4;
|
||||
}
|
||||
else {
|
||||
modifiedDamage = damage / 2;
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isTransparent()) {
|
||||
transparentBlocks.add((byte) material.getId());
|
||||
}
|
||||
}
|
||||
|
||||
return modifiedDamage;
|
||||
return transparentBlocks;
|
||||
}
|
||||
}
|
||||
|
@ -1,149 +0,0 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class BlastMiningDropEventHandler {
|
||||
private MiningManager manager;
|
||||
private int skillLevel;
|
||||
private EntityExplodeEvent event;
|
||||
private float yield;
|
||||
private List<Block> blocks;
|
||||
private List<BlockState> ores = new ArrayList<BlockState>();
|
||||
private List<BlockState> debris = new ArrayList<BlockState>();
|
||||
private List<BlockState> droppedOres = new ArrayList<BlockState>();
|
||||
private float oreBonus;
|
||||
private float debrisReduction;
|
||||
private int dropMultiplier;
|
||||
|
||||
public BlastMiningDropEventHandler(MiningManager manager, EntityExplodeEvent event) {
|
||||
this.manager = manager;
|
||||
this.skillLevel = manager.getSkillLevel();
|
||||
|
||||
this.event = event;
|
||||
this.yield = event.getYield();
|
||||
this.blocks = event.blockList();
|
||||
}
|
||||
|
||||
protected void sortExplosionBlocks() {
|
||||
for (Block block : blocks) {
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
if (BlockChecks.isOre(blockState)) {
|
||||
ores.add(blockState);
|
||||
}
|
||||
else {
|
||||
debris.add(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void processXPGain() {
|
||||
for (BlockState blockState : droppedOres) {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
Mining.awardMiningXp(blockState, manager.getMcMMOPlayer().getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void processDroppedBlocks() {
|
||||
for (BlockState blockState : ores) {
|
||||
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
droppedOres.add(blockState);
|
||||
Mining.handleMiningDrops(blockState);
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
for (int i = 1 ; i < dropMultiplier ; i++) {
|
||||
droppedOres.add(blockState);
|
||||
Mining.handleMiningDrops(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float debrisYield = yield - debrisReduction;
|
||||
|
||||
if (debrisYield > 0) {
|
||||
for (BlockState blockState : debris) {
|
||||
Location location = blockState.getLocation();
|
||||
Material type = blockState.getType();
|
||||
|
||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||
Misc.dropItem(location, new ItemStack(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void modifyEventYield() {
|
||||
event.setYield(0);
|
||||
}
|
||||
|
||||
protected void calcuateDropModifiers() {
|
||||
calculateOreBonus();
|
||||
calculateDebrisReduction();
|
||||
calculateDropMultiplier();
|
||||
}
|
||||
|
||||
private void calculateOreBonus() {
|
||||
if (skillLevel >= BlastMining.rank8) {
|
||||
oreBonus = .70f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank7) {
|
||||
oreBonus = .65f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank6) {
|
||||
oreBonus = .60f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank5) {
|
||||
oreBonus = .55f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank4) {
|
||||
oreBonus = .50f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank3) {
|
||||
oreBonus = .45f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank2) {
|
||||
oreBonus = .40f;
|
||||
}
|
||||
else {
|
||||
debrisReduction = .35f;
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateDebrisReduction() {
|
||||
if (skillLevel >= BlastMining.rank3) {
|
||||
debrisReduction = .30f;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank2) {
|
||||
debrisReduction = .20f;
|
||||
}
|
||||
else {
|
||||
debrisReduction = .10f;
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateDropMultiplier() {
|
||||
if (skillLevel >= BlastMining.rank7) {
|
||||
dropMultiplier = 3;
|
||||
}
|
||||
else if (skillLevel >= BlastMining.rank5) {
|
||||
dropMultiplier = 2;
|
||||
}
|
||||
else {
|
||||
dropMultiplier = 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,19 +3,14 @@ package com.gmail.nossr50.skills.mining;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Mining {
|
||||
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
@ -24,31 +19,11 @@ public class Mining {
|
||||
public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance();
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Mining.
|
||||
* Calculate XP gain for Mining.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param player The {@link Player} using this ability
|
||||
*/
|
||||
public static void miningBlockCheck(BlockState blockState, Player player) {
|
||||
awardMiningXp(blockState, player);
|
||||
|
||||
if (Permissions.doubleDrops(player, SkillType.MINING) && SkillTools.activationSuccessful(player, SkillType.MINING, doubleDropsMaxChance, doubleDropsMaxLevel)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
handleSilkTouchDrops(blockState);
|
||||
}
|
||||
else {
|
||||
handleMiningDrops(blockState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Award XP gain for Mining.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param player The {@link Player} using this ability
|
||||
*/
|
||||
protected static void awardMiningXp(BlockState blockState, Player player) {
|
||||
protected static int getBlockXp(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = Config.getInstance().getXp(SkillType.MINING, blockType);
|
||||
|
||||
@ -59,7 +34,7 @@ public class Mining {
|
||||
xp = ModChecks.getCustomBlock(blockState).getXpGain();
|
||||
}
|
||||
|
||||
Users.getPlayer(player).beginXpGain(SkillType.MINING, xp);
|
||||
return xp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillCommand;
|
||||
import com.gmail.nossr50.skills.SkillManagerStore;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@ -10,8 +12,12 @@ public class MiningCommand extends SkillCommand {
|
||||
private String doubleDropChanceLucky;
|
||||
private String superBreakerLength;
|
||||
private String superBreakerLengthEndurance;
|
||||
private String blastMiningRank;
|
||||
private String blastRadiusIncrease;
|
||||
|
||||
private int blastMiningRank;
|
||||
private int bonusTNTDrops;
|
||||
private double blastRadiusIncrease;
|
||||
private String oreBonus;
|
||||
private String debrisReduction;
|
||||
private String blastDamageDecrease;
|
||||
|
||||
private boolean canSuperBreaker;
|
||||
@ -38,51 +44,13 @@ public class MiningCommand extends SkillCommand {
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
|
||||
//BLAST MINING
|
||||
if (skillValue >= BlastMining.rank8) {
|
||||
blastMiningRank = "8";
|
||||
blastDamageDecrease = "100.00%";
|
||||
blastRadiusIncrease = "4";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank7) {
|
||||
blastMiningRank = "7";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank6) {
|
||||
blastMiningRank = "6";
|
||||
blastDamageDecrease = "50.00%";
|
||||
blastRadiusIncrease = "3";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank5) {
|
||||
blastMiningRank = "5";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank4) {
|
||||
blastMiningRank = "4";
|
||||
blastDamageDecrease = "25.00%";
|
||||
blastRadiusIncrease = "2";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank3) {
|
||||
blastMiningRank = "3";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank2) {
|
||||
blastMiningRank = "2";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "1";
|
||||
}
|
||||
else if (skillValue >= BlastMining.rank1) {
|
||||
blastMiningRank = "1";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
}
|
||||
else {
|
||||
blastMiningRank = "0";
|
||||
blastDamageDecrease = "0.00%";
|
||||
blastRadiusIncrease = "0";
|
||||
}
|
||||
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
|
||||
blastMiningRank = miningManager.getBlastMiningTier();
|
||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
|
||||
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
|
||||
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
|
||||
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -151,17 +119,17 @@ public class MiningCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canBlast) {
|
||||
if (skillValue < BlastMining.rank1) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", BlastMining.rank1)));
|
||||
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1())));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Integer.parseInt(blastMiningRank) - 1))));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
|
||||
}
|
||||
}
|
||||
|
||||
if (canBiggerBombs) {
|
||||
if (skillValue < BlastMining.rank2) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", BlastMining.rank2)));
|
||||
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2())));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
|
||||
@ -169,8 +137,8 @@ public class MiningCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDemoExpert) {
|
||||
if (skillValue < BlastMining.rank4) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", BlastMining.rank4)));
|
||||
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4())));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
|
||||
|
@ -1,50 +1,104 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class MiningManager extends SkillManager{
|
||||
public MiningManager (McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.MINING);
|
||||
}
|
||||
|
||||
public boolean canUseDemolitionsExpertise() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player);
|
||||
}
|
||||
|
||||
public boolean canDetonate() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel());
|
||||
}
|
||||
|
||||
public boolean canUseBlastMining() {
|
||||
return SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel());
|
||||
}
|
||||
|
||||
public boolean canUseBiggerBombs() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return Permissions.biggerBombs(player) && SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Mining.
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
* @param player The {@link Player} using this ability
|
||||
*/
|
||||
public void miningBlockCheck(BlockState blockState) {
|
||||
Player player = getPlayer();
|
||||
int xp = Mining.getBlockXp(blockState);
|
||||
|
||||
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
Mining.handleSilkTouchDrops(blockState);
|
||||
}
|
||||
else {
|
||||
Mining.handleMiningDrops(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detonate TNT for Blast Mining
|
||||
*
|
||||
* @param event The PlayerInteractEvent
|
||||
*/
|
||||
public void detonate(PlayerInteractEvent event) {
|
||||
if (getSkillLevel() < BlastMining.rank1) {
|
||||
public void remoteDetonation() {
|
||||
Player player = getPlayer();
|
||||
|
||||
HashSet<Byte> transparentBlocks = BlastMining.generateTransparentBlockList();
|
||||
Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||
|
||||
if (targetBlock.getType() != Material.TNT || !SkillTools.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RemoteDetonationEventHandler eventHandler = new RemoteDetonationEventHandler(this, event);
|
||||
PlayerProfile profile = getProfile();
|
||||
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
|
||||
|
||||
eventHandler.targetTNT();
|
||||
SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
|
||||
if (eventHandler.getBlock().getType() != Material.TNT) {
|
||||
return;
|
||||
}
|
||||
mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName());
|
||||
tnt.setFuseTicks(0);
|
||||
targetBlock.setData((byte) 0x0);
|
||||
targetBlock.setType(Material.AIR);
|
||||
|
||||
if (!SkillTools.blockBreakSimulate(eventHandler.getBlock(), mcMMOPlayer.getPlayer(), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!eventHandler.cooldownOver()) {
|
||||
return;
|
||||
}
|
||||
|
||||
eventHandler.sendMessages();
|
||||
eventHandler.handleDetonation();
|
||||
eventHandler.setProfileData();
|
||||
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,24 +106,54 @@ public class MiningManager extends SkillManager{
|
||||
*
|
||||
* @param event Event whose explosion is being processed
|
||||
*/
|
||||
public void blastMiningDropProcessing(EntityExplodeEvent event) {
|
||||
if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) {
|
||||
return;
|
||||
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
|
||||
List<BlockState> ores = new ArrayList<BlockState>();
|
||||
List<BlockState> debris = new ArrayList<BlockState>();
|
||||
int xp = 0;
|
||||
|
||||
float oreBonus = (float) (getOreBonus() / 100);
|
||||
float debrisReduction = (float) (getDebrisReduction() / 100);
|
||||
int dropMultiplier = getDropMultiplier();
|
||||
|
||||
float debrisYield = yield - debrisReduction;
|
||||
|
||||
for (Block block : blockList) {
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
if (BlockChecks.isOre(blockState)) {
|
||||
ores.add(blockState);
|
||||
}
|
||||
else {
|
||||
debris.add(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
if (getSkillLevel() < BlastMining.rank1) {
|
||||
return;
|
||||
for (BlockState blockState : ores) {
|
||||
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
}
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(blockState)) {
|
||||
for (int i = 1 ; i < dropMultiplier ; i++) {
|
||||
xp += Mining.getBlockXp(blockState);
|
||||
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlastMiningDropEventHandler eventHandler = new BlastMiningDropEventHandler(this, event);
|
||||
if (debrisYield > 0) {
|
||||
for (BlockState blockState : debris) {
|
||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eventHandler.sortExplosionBlocks();
|
||||
eventHandler.modifyEventYield();
|
||||
|
||||
eventHandler.calcuateDropModifiers();
|
||||
eventHandler.processDroppedBlocks();
|
||||
|
||||
eventHandler.processXPGain();
|
||||
applyXpGain(xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,14 +161,128 @@ public class MiningManager extends SkillManager{
|
||||
*
|
||||
* @param event Event whose explosion radius is being changed
|
||||
*/
|
||||
public void biggerBombs(ExplosionPrimeEvent event) {
|
||||
if (Misc.isNPCEntity(mcMMOPlayer.getPlayer())) {
|
||||
return;
|
||||
public float biggerBombs(float radius) {
|
||||
return (float) (radius + getBlastRadiusModifier());
|
||||
}
|
||||
|
||||
public int processDemolitionsExpertise(int damage) {
|
||||
return (int) (damage * (100.0 - getBlastDamageModifier()));
|
||||
}
|
||||
|
||||
private boolean blastMiningCooldownOver() {
|
||||
Player player = getPlayer();
|
||||
PlayerProfile profile = getProfile();
|
||||
|
||||
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
|
||||
int cooldown = AbilityType.BLAST_MINING.getCooldown();
|
||||
|
||||
if (!SkillTools.cooldownOver(oldTime, cooldown, player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(oldTime, cooldown, player)));
|
||||
return false;
|
||||
}
|
||||
|
||||
BiggerBombsEventHandler eventHandler = new BiggerBombsEventHandler(this, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
eventHandler.calculateRadiusIncrease();
|
||||
eventHandler.modifyBlastRadius();
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public int getBlastMiningTier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.toNumerical();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public double getOreBonus() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getOreBonus();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public double getDebrisReduction() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getDebrisReduction();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public int getDropMultiplier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getDropMultiplier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public double getBlastRadiusModifier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getBlastRadiusModifier();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Blast Mining tier
|
||||
*
|
||||
* @return the Blast Mining tier
|
||||
*/
|
||||
public double getBlastDamageModifier() {
|
||||
int skillLevel = getSkillLevel();
|
||||
|
||||
for (Tier tier : Tier.values()) {
|
||||
if (skillLevel >= tier.getLevel()) {
|
||||
return tier.getBlastDamageDecrease();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,89 +0,0 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class RemoteDetonationEventHandler {
|
||||
private MiningManager manager;
|
||||
private PlayerInteractEvent event;
|
||||
private Block block;
|
||||
private HashSet<Byte> transparentBlocks = new HashSet<Byte>();
|
||||
|
||||
public RemoteDetonationEventHandler(MiningManager manager, PlayerInteractEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.block = event.getClickedBlock();
|
||||
}
|
||||
|
||||
protected void targetTNT() {
|
||||
if (block == null || block.getType() != Material.TNT) {
|
||||
generateTransparentBlockList();
|
||||
block = manager.getMcMMOPlayer().getPlayer().getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||
}
|
||||
else {
|
||||
event.setCancelled(true); // This is the only way I know to avoid the original TNT to be triggered (in case the player is close to it)
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean cooldownOver() {
|
||||
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (!SkillTools.cooldownOver(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player)));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void sendMessages() {
|
||||
Player player = manager.getMcMMOPlayer().getPlayer();
|
||||
|
||||
SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
|
||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||
}
|
||||
|
||||
protected void handleDetonation() {
|
||||
Player player = manager.getMcMMOPlayer().getPlayer();
|
||||
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
|
||||
|
||||
mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName());
|
||||
tnt.setFuseTicks(0);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
protected void setProfileData() {
|
||||
PlayerProfile profile = manager.getMcMMOPlayer().getProfile();
|
||||
|
||||
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
||||
}
|
||||
|
||||
private void generateTransparentBlockList() {
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isTransparent()) {
|
||||
transparentBlocks.add((byte) material.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user