mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-09-05 12:45:34 +02:00
Reduce Blast Mining PVP damage Fixes #5213
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
Version 2.2.042
|
||||
You can now define custom sounds to be played in sounds.yml (Thank you JeBobs, see notes)
|
||||
Reduced Blast Mining PVP damage to other players
|
||||
|
||||
Notes:
|
||||
The new sounds.yml config file allows you to override the sounds played by mcMMO.
|
||||
|
@@ -385,8 +385,8 @@ public class EntityListener implements Listener {
|
||||
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
|
||||
attacker = (Entity) animalTamer;
|
||||
}
|
||||
} else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
||||
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker,
|
||||
} else if (attacker instanceof TNTPrimed tntAttacker && defender instanceof Player) {
|
||||
if (BlastMining.processBlastMiningExplosion(event, tntAttacker,
|
||||
(Player) defender)) {
|
||||
return;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user