Fixed issues with dealing damage to Entities

This commit is contained in:
GJ 2013-09-09 12:44:03 -04:00 committed by TfT_02
parent 71ab678945
commit 89ddf8c4fa
3 changed files with 16 additions and 3 deletions

View File

@ -134,6 +134,11 @@ public class EntityListener implements Listener {
Entity defender = event.getEntity(); Entity defender = event.getEntity();
if (defender.hasMetadata(mcMMO.customDamageKey)) {
defender.removeMetadata(mcMMO.customDamageKey, plugin);
return;
}
if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return; return;
} }
@ -344,12 +349,12 @@ public class EntityListener implements Listener {
if (entity.hasMetadata(mcMMO.customNameKey)) { if (entity.hasMetadata(mcMMO.customNameKey)) {
entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString()); entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString());
entity.removeMetadata(mcMMO.customNameKey, mcMMO.p); entity.removeMetadata(mcMMO.customNameKey, plugin);
} }
if (entity.hasMetadata(mcMMO.customVisibleKey)) { if (entity.hasMetadata(mcMMO.customVisibleKey)) {
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean()); entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
entity.removeMetadata(mcMMO.customVisibleKey, mcMMO.p); entity.removeMetadata(mcMMO.customVisibleKey, plugin);
} }
} }

View File

@ -97,6 +97,7 @@ public class mcMMO extends JavaPlugin {
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow"; public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
public final static String bowForceKey = "mcMMO: Bow Force"; public final static String bowForceKey = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance"; public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
public final static String customDamageKey = "mcMMO: Custom Damage";
public static FixedMetadataValue metadataValue; public static FixedMetadataValue metadataValue;

View File

@ -389,7 +389,14 @@ public final class CombatUtils {
startGainXp(mcMMOPlayer, target, skill); startGainXp(mcMMOPlayer, target, skill);
} }
target.damage(damage); int damageTicks = target.getNoDamageTicks();
double lastDamage = target.getLastDamage();
target.setMetadata(mcMMO.customDamageKey, mcMMO.metadataValue);
target.damage(damage, attacker);
target.setNoDamageTicks(damageTicks);
target.setLastDamage(lastDamage);
} }
/** /**