|
@@ -10,7 +10,8 @@ import org.bukkit.entity.TNTPrimed;
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
|
|
public class BlastMining {
|
|
|
- public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
|
|
+ public static final int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
|
|
|
+ private static final double BLAST_MINING_PVP_DAMAGE_CAP = 24D;
|
|
|
|
|
|
public static double getBlastRadiusModifier(int rank) {
|
|
|
return mcMMO.p.getAdvancedConfig().getBlastRadiusModifier(rank);
|
|
@@ -41,17 +42,22 @@ public class BlastMining {
|
|
|
}
|
|
|
|
|
|
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event,
|
|
|
- TNTPrimed tnt, Player defender) {
|
|
|
- if (!tnt.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)
|
|
|
+ TNTPrimed tntAttacker, Player defender) {
|
|
|
+ if (!tntAttacker.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)
|
|
|
|| !UserManager.hasPlayerDataKey(defender)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
|
|
Player player = mcMMO.p.getServer().getPlayerExact(
|
|
|
- tnt.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
|
|
+ tntAttacker.getMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT).get(0).asString());
|
|
|
|
|
|
if (!(player != null && player.equals(defender))) {
|
|
|
+ double cappedDamage = Math.min(event.getDamage(), BLAST_MINING_PVP_DAMAGE_CAP);
|
|
|
+ event.setDamage(Math.max(cappedDamage, 0D));
|
|
|
+ if (event.getFinalDamage() <= 0) {
|
|
|
+ event.setCancelled(true);
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -67,7 +73,7 @@ public class BlastMining {
|
|
|
|
|
|
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
|
|
|
|
|
- if (event.getFinalDamage() == 0) {
|
|
|
+ if (event.getFinalDamage() <= 0) {
|
|
|
event.setCancelled(true);
|
|
|
return false;
|
|
|
}
|