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
|
Version 2.2.042
|
||||||
You can now define custom sounds to be played in sounds.yml (Thank you JeBobs, see notes)
|
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:
|
Notes:
|
||||||
The new sounds.yml config file allows you to override the sounds played by mcMMO.
|
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()) {
|
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
|
||||||
attacker = (Entity) animalTamer;
|
attacker = (Entity) animalTamer;
|
||||||
}
|
}
|
||||||
} else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
} else if (attacker instanceof TNTPrimed tntAttacker && defender instanceof Player) {
|
||||||
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker,
|
if (BlastMining.processBlastMiningExplosion(event, tntAttacker,
|
||||||
(Player) defender)) {
|
(Player) defender)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,8 @@ import org.bukkit.entity.TNTPrimed;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
public class BlastMining {
|
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) {
|
public static double getBlastRadiusModifier(int rank) {
|
||||||
return mcMMO.p.getAdvancedConfig().getBlastRadiusModifier(rank);
|
return mcMMO.p.getAdvancedConfig().getBlastRadiusModifier(rank);
|
||||||
@@ -41,17 +42,22 @@ public class BlastMining {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event,
|
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event,
|
||||||
TNTPrimed tnt, Player defender) {
|
TNTPrimed tntAttacker, Player defender) {
|
||||||
if (!tnt.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)
|
if (!tntAttacker.hasMetadata(MetadataConstants.METADATA_KEY_TRACKED_TNT)
|
||||||
|| !UserManager.hasPlayerDataKey(defender)) {
|
|| !UserManager.hasPlayerDataKey(defender)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = mcMMO.p.getServer().getPlayerExact(
|
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))) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +73,7 @@ public class BlastMining {
|
|||||||
|
|
||||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||||
|
|
||||||
if (event.getFinalDamage() == 0) {
|
if (event.getFinalDamage() <= 0) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user