use of net.citizensnpcs.util.PlayerAnimation in project Citizens2 by CitizensDev.
the class AnimationTriggerPrompt method acceptInput.
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("back")) {
return (Prompt) context.getSessionData("previous");
}
if (input.equalsIgnoreCase("finish")) {
context.setSessionData(WaypointTriggerPrompt.CREATED_TRIGGER_KEY, new AnimationTrigger(animations));
return (Prompt) context.getSessionData(WaypointTriggerPrompt.RETURN_PROMPT_KEY);
}
PlayerAnimation animation = Util.matchEnum(PlayerAnimation.values(), input);
if (animation == null) {
Messaging.sendErrorTr((CommandSender) context.getForWhom(), Messages.INVALID_ANIMATION, input, getValidAnimations());
}
animations.add(animation);
Messaging.sendTr((CommandSender) context.getForWhom(), Messages.ANIMATION_ADDED, input);
return this;
}
use of net.citizensnpcs.util.PlayerAnimation 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 net.citizensnpcs.util.PlayerAnimation 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!
}
}
}
Aggregations