mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Fix Blast Mining and change its behavior slightly
Fixed bug where Blast Minings ability "Demolition Expert" would not work with certain CB versions. DanageCause.BLOCK_EXPLOSION was not passed, ENTITY_EXPLOSION was used instead. Changed behavior of the Blast Mining ability "Demolition Expert"; now only decreases damage for the ability user and for Blast Mining explosions.
This commit is contained in:
parent
ccca3fff26
commit
8fd94b625c
@ -34,12 +34,14 @@ Version 1.5.01-dev
|
||||
= Fixed bug where the console would not correctly show party chat colors
|
||||
= Fixed bug where party chat was using non thread safe methods
|
||||
= Fixed bug where Blast Mining unlock levels could be to high in certain occasions
|
||||
= Fixed bug where Blast Minings ability "Demolition Expert" would not work
|
||||
! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
|
||||
! Changed the way mcMMO handles bonus damage, updated for the new damage event API
|
||||
! Changed player data saving. Save tasks are now asynchronous
|
||||
! Vanished players no longer get hit by AoE effects
|
||||
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
|
||||
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
|
||||
! Changed behavior of the Blast Mining ability "Demolition Expert"; now only decreases damage for the ability user
|
||||
! Updated for new getOnlinePlayers() behavior
|
||||
- Removed salvage ability from Repair, salvage has it's own (child) skill now
|
||||
|
||||
|
@ -53,6 +53,7 @@ import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
@ -192,6 +193,11 @@ public class EntityListener implements Listener {
|
||||
attacker = (Entity) animalTamer;
|
||||
}
|
||||
}
|
||||
else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
||||
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player && attacker instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
@ -285,19 +291,6 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
break;
|
||||
|
||||
case BLOCK_EXPLOSION:
|
||||
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||
|
||||
if (miningManager.canUseDemolitionsExpertise()) {
|
||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
|
||||
if (event.getFinalDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -4,9 +4,15 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
public class BlastMining {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@ -84,4 +90,32 @@ public class BlastMining {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean processBlastMiningExplosion(EntityDamageByEntityEvent event, TNTPrimed tnt, Player defender) {
|
||||
if (!tnt.hasMetadata(mcMMO.tntMetadataKey) || !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(mcMMO.tntMetadataKey).get(0).asString());
|
||||
|
||||
if (!player.equals(defender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MiningManager miningManager = UserManager.getPlayer(defender).getMiningManager();
|
||||
|
||||
if (!miningManager.canUseDemolitionsExpertise()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
event.setDamage(DamageModifier.BASE, miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
|
||||
if (event.getFinalDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user