diff --git a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java index 615ebf2b23..ab9c289390 100644 --- a/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java +++ b/src/main/java/net/aufdemrand/denizen/events/entity/EntityDamagedScriptEvent.java @@ -168,10 +168,10 @@ else if (name.equals("cause")) { return cause; } else if (name.equals("damager") && damager != null) { - return damager; + return damager.getDenizenObject(); } else if (name.equals("projectile") && projectile != null) { - return projectile; + return projectile.getDenizenObject(); } else if (name.startsWith("damage_")) { for (EntityDamageEvent.DamageModifier dm : EntityDamageEvent.DamageModifier.values()) { diff --git a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java index 4ce76acbaf..7360f044b5 100644 --- a/src/main/java/net/aufdemrand/denizen/objects/dEntity.java +++ b/src/main/java/net/aufdemrand/denizen/objects/dEntity.java @@ -1404,8 +1404,16 @@ public String getAttribute(Attribute attribute) { // --> if (attribute.startsWith("has_flag")) { String flag_name; - if (attribute.hasContext(1)) flag_name = attribute.getContext(1); - else return null; + if (attribute.hasContext(1)) { + flag_name = attribute.getContext(1); + } + else { + return null; + } + if (isPlayer() || isCitizensNPC()) { + dB.echoError("Reading flag for PLAYER or NPC as if it were an ENTITY!"); + return null; + } return new Element(FlagManager.entityHasFlag(this, flag_name)).getAttribute(attribute.fulfill(1)); } @@ -1417,19 +1425,27 @@ public String getAttribute(Attribute attribute) { // --> if (attribute.startsWith("flag")) { String flag_name; - if (attribute.hasContext(1)) flag_name = attribute.getContext(1); - else return null; + if (attribute.hasContext(1)) { + flag_name = attribute.getContext(1); + } + else { + return null; + } + if (isPlayer() || isCitizensNPC()) { + dB.echoError("Reading flag for PLAYER or NPC as if it were an ENTITY!"); + return null; + } if (attribute.getAttribute(2).equalsIgnoreCase("is_expired") - || attribute.startsWith("isexpired")) + || attribute.startsWith("isexpired")) { return new Element(!FlagManager.entityHasFlag(this, flag_name)) .getAttribute(attribute.fulfill(2)); - if (attribute.getAttribute(2).equalsIgnoreCase("size") && !FlagManager.entityHasFlag(this, flag_name)) + } + if (attribute.getAttribute(2).equalsIgnoreCase("size") && !FlagManager.entityHasFlag(this, flag_name)) { return new Element(0).getAttribute(attribute.fulfill(2)); + } if (FlagManager.entityHasFlag(this, flag_name)) { - FlagManager.Flag flag = DenizenAPI.getCurrentInstance().flagManager() - .getEntityFlag(this, flag_name); - return new dList(flag.toString(), true, flag.values()) - .getAttribute(attribute.fulfill(1)); + FlagManager.Flag flag = DenizenAPI.getCurrentInstance().flagManager().getEntityFlag(this, flag_name); + return new dList(flag.toString(), true, flag.values()).getAttribute(attribute.fulfill(1)); } return new Element(identify()).getAttribute(attribute); }