use of org.bukkit.EntityEffect in project Glowstone by GlowstoneMC.
the class GlowEntity method playEffect.
@Override
public void playEffect(EntityEffect type) {
if (type.getApplicable().isInstance(this)) {
EntityStatusMessage message = new EntityStatusMessage(entityId, type);
world.getRawPlayers().stream().filter(player -> player.canSeeEntity(this)).forEach(player -> player.getSession().send(message));
}
}
use of org.bukkit.EntityEffect in project Denizen-For-Bukkit by DenizenScript.
the class AnimateCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
List<PlayerTag> forPlayers = (List<PlayerTag>) scriptEntry.getObject("for");
PlayerAnimation animation = scriptEntry.hasObject("animation") ? (PlayerAnimation) scriptEntry.getObject("animation") : null;
EntityEffect effect = scriptEntry.hasObject("effect") ? (EntityEffect) scriptEntry.getObject("effect") : null;
String nmsAnimation = scriptEntry.hasObject("nms_animation") ? (String) scriptEntry.getObject("nms_animation") : null;
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), (animation != null ? db("animation", animation.name()) : effect != null ? db("effect", effect.name()) : db("animation", nmsAnimation)), db("entities", entities), db("for", forPlayers));
}
for (EntityTag entity : entities) {
if (entity.isSpawned()) {
try {
if (animation != null && entity.getBukkitEntity() instanceof Player) {
Player player = (Player) entity.getBukkitEntity();
animation.play(player);
} else if (effect != null) {
if (forPlayers != null) {
for (PlayerTag player : forPlayers) {
NMSHandler.getPacketHelper().sendEntityEffect(player.getPlayerEntity(), entity.getBukkitEntity(), effect.getData());
}
} else {
entity.getBukkitEntity().playEffect(effect);
}
} else if (nmsAnimation != null) {
EntityAnimation entityAnimation = NMSHandler.getAnimationHelper().getEntityAnimation(nmsAnimation);
entityAnimation.play(entity.getBukkitEntity());
} else {
Debug.echoError("No way to play the given animation on entity '" + entity + "'");
}
} catch (Exception e) {
Debug.echoError(scriptEntry, "Error playing that animation!");
Debug.echoError(e);
}
}
}
}
use of org.bukkit.EntityEffect in project Denizen-For-Bukkit by DenizenScript.
the class AnimateCommand method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {
// Get objects
List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
PlayerAnimation animation = scriptEntry.hasObject("animation") ? (PlayerAnimation) scriptEntry.getObject("animation") : null;
EntityEffect effect = scriptEntry.hasObject("effect") ? (EntityEffect) scriptEntry.getObject("effect") : null;
String nmsAnimation = scriptEntry.hasObject("nms_animation") ? (String) scriptEntry.getObject("nms_animation") : null;
// Report to dB
dB.report(scriptEntry, getName(), (animation != null ? aH.debugObj("animation", animation.name()) : effect != null ? aH.debugObj("effect", effect.name()) : aH.debugObj("animation", nmsAnimation)) + aH.debugObj("entities", entities.toString()));
// Go through all the entities and animate them
for (dEntity entity : entities) {
if (entity.isSpawned()) {
try {
if (animation != null && entity.getBukkitEntity() instanceof Player) {
Player player = (Player) entity.getBukkitEntity();
animation.play(player);
} else if (effect != null) {
entity.getBukkitEntity().playEffect(effect);
} else {
EntityAnimation entityAnimation = NMSHandler.getInstance().getAnimationHelper().getEntityAnimation(nmsAnimation);
entityAnimation.play(entity.getBukkitEntity());
}
} catch (Exception e) {
dB.echoError(scriptEntry.getResidingQueue(), "Error playing that animation!");
}
// We tried!
}
}
}
use of org.bukkit.EntityEffect in project Glowstone by GlowstoneMC.
the class GlowEntity method playEffectKnownAndSelf.
public void playEffectKnownAndSelf(EntityEffect type) {
if (type.getApplicable().isInstance(this)) {
EntityStatusMessage message = new EntityStatusMessage(entityId, type);
if (this instanceof GlowPlayer) {
((GlowPlayer) this).getSession().send(message);
}
world.getRawPlayers().stream().filter(player -> player.canSeeEntity(this)).forEach(player -> player.getSession().send(message));
}
}
Aggregations