/** * Extending Effect classes can use this to determine the Entity this * Effect is targeted upon. This is probably a very rare case, such as * an Effect that "links" two Entities together somehow. (Idea!) * * This may return null, even for an Effect that was set with a target Entity, * if the Entity gets GC'd. */ public Entity getTargetEntity() { return target == null ? null : target.getEntity(); }
/** * Extending Effect classes can use this to determine the Entity this * Effect is centered upon. * * This may return null, even for an Effect that was set with an Entity, * if the Entity gets GC'd. */ public Entity getEntity() { return origin == null ? null : origin.getEntity(); }
@Nullable public Entity getOriginEntity() { return origin == null ? null : origin.getEntity(); }
@Nullable public Entity getTargetEntity() { return target == null ? null : target.getEntity(); }
public boolean hasValidEntity() { Entity entity = this.getEntity(); return entity != null && entity.isValid(); } }
protected void playEffect(DynamicLocation origin, DynamicLocation target) { if (requireTargetEntity && (target == null || target.getEntity() == null)) { return; } if (playAtOrigin && origin != null) { performEffects(origin, target); } if (playAtTarget && target != null) { performEffects(target, origin); } }
switch (player.getVisibility()) { case TARGET: if (target != null && target.getEntity() instanceof Player) { targetPlayer = (Player)target.getEntity(); if (origin != null && origin.getEntity() instanceof Player) { targetPlayer = (Player)origin.getEntity(); parameterMap = new MemoryConfiguration(); Entity originEntity = origin == null ? null : origin.getEntity(); if (originEntity != null && originEntity instanceof Player) { parameterMap.set("$name", originEntity.getName()); parameterMap.set("$name", "Unknown"); Entity targetEntity = target == null ? null : target.getEntity(); if (targetEntity != null && targetEntity instanceof Player) { parameterMap.set("$target", targetEntity.getName());
Location sourceLocation = source == null ? null : source.getLocation(); if (sourceLocation == null) return; Entity sourceEntity = source == null ? null : source.getEntity(); if (requireEntity && sourceEntity == null) return;