mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Fixing a 7 year old damage bug.
This commit is contained in:
parent
aa25ba6338
commit
7ee65a7e65
@ -8,6 +8,7 @@ Key:
|
|||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 2.1.23
|
Version 2.1.23
|
||||||
|
Fixed a 7 year old bug where damage in mcMMO from Skills was getting reduced by damage reduction TWICE
|
||||||
Fixed a bug with Double Drops for Mining
|
Fixed a bug with Double Drops for Mining
|
||||||
Fixed a bug where killing entities with Rupture would not properly credit you as the killer
|
Fixed a bug where killing entities with Rupture would not properly credit you as the killer
|
||||||
Fixed a bug where Serrated Strikes was applying Rupture twice
|
Fixed a bug where Serrated Strikes was applying Rupture twice
|
||||||
|
@ -5,13 +5,11 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
|||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||||
@ -32,7 +30,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -368,7 +365,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Aren't we applying the damage twice????
|
// Aren't we applying the damage twice????
|
||||||
target.damage(callFakeDamageEvent(attacker, target, damage, modifiers));
|
target.damage(getFakeDamageFinalResult(attacker, target, damage, modifiers));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,7 +381,8 @@ public final class CombatUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.damage(callFakeDamageEvent(attacker, target, cause, damage));
|
if(canDamage(attacker, target, cause, damage))
|
||||||
|
target.damage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) {
|
public static void dealNoInvulnerabilityTickDamage(LivingEntity target, double damage, Entity attacker) {
|
||||||
@ -392,7 +390,7 @@ public final class CombatUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double incDmg = callFakeDamageEvent(attacker, target, DamageCause.CUSTOM, damage);
|
double incDmg = getFakeDamageFinalResult(attacker, target, DamageCause.CUSTOM, damage);
|
||||||
|
|
||||||
double newHealth = Math.max(0, target.getHealth() - incDmg);
|
double newHealth = Math.max(0, target.getHealth() - incDmg);
|
||||||
|
|
||||||
@ -409,9 +407,10 @@ public final class CombatUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int noDamageTicks = target.getNoDamageTicks();
|
//IFrame storage
|
||||||
|
// int noDamageTicks = target.getNoDamageTicks();
|
||||||
|
|
||||||
double incDmg = callFakeDamageEvent(attacker, target, DamageCause.CUSTOM, damage);
|
double incDmg = getFakeDamageFinalResult(attacker, target, DamageCause.CUSTOM, damage);
|
||||||
|
|
||||||
double newHealth = Math.max(0, target.getHealth() - incDmg);
|
double newHealth = Math.max(0, target.getHealth() - incDmg);
|
||||||
|
|
||||||
@ -421,19 +420,17 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
|
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
|
||||||
|
|
||||||
if(newHealth == 0)
|
if(newHealth == 0 && !(target instanceof Player))
|
||||||
{
|
{
|
||||||
target.damage(99999, attacker);
|
target.damage(99999, attacker);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector beforeRuptureVec = new Vector(target.getVelocity().getX(), target.getVelocity().getY(), target.getVelocity().getZ()); ;
|
// Vector beforeRuptureVec = new Vector(target.getVelocity().getX(), target.getVelocity().getY(), target.getVelocity().getZ()); ;
|
||||||
target.damage(damage, attacker);
|
target.setHealth(newHealth);
|
||||||
|
// target.setNoDamageTicks(noDamageTicks); //Do not add additional IFrames
|
||||||
target.setNoDamageTicks(noDamageTicks);
|
// target.setVelocity(beforeRuptureVec);
|
||||||
target.setVelocity(beforeRuptureVec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -597,7 +594,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
// It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
||||||
if (callFakeDamageEvent(player, entity, 1.0) == 0) {
|
if (getFakeDamageFinalResult(player, entity, 1.0) == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -652,14 +649,13 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static double callFakeDamageEvent(Entity attacker, Entity target, double damage) {
|
public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) {
|
||||||
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
|
public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause damageCause, double damage) {
|
||||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
|
||||||
|
|
||||||
if (damageEvent.isCancelled()) {
|
if (damageEvent.isCancelled()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -668,15 +664,31 @@ public final class CombatUtils {
|
|||||||
return damageEvent.getFinalDamage();
|
return damageEvent.getFinalDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double callFakeDamageEvent(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) {
|
public static boolean canDamage(Entity attacker, Entity target, DamageCause damageCause, double damage) {
|
||||||
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, modifiers);
|
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
|
||||||
|
|
||||||
|
if (damageEvent.isCancelled()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double callFakeDamageEvent(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) {
|
return true;
|
||||||
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
|
public static EntityDamageEvent sendEntityDamageEvent(Entity attacker, Entity target, DamageCause damageCause, double damage) {
|
||||||
|
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||||
|
return damageEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getFakeDamageFinalResult(Entity attacker, Entity target, Map<DamageModifier, Double> modifiers) {
|
||||||
|
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||||
|
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getFakeDamageFinalResult(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
|
||||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
|
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user