Skip to content

Commit

Permalink
Add /npc panimate (does not persist animations as yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 19, 2022
1 parent 53d7a23 commit 719f115
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -130,6 +130,7 @@
import net.citizensnpcs.util.Anchor;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.PlayerAnimation;
import net.citizensnpcs.util.StringHelper;
import net.citizensnpcs.util.Util;

Expand Down Expand Up @@ -1618,6 +1619,25 @@ public void pathto(CommandContext args, CommandSender sender, NPC npc) {
npc.getNavigator().setTarget(loc);
}

@Command(
aliases = { "npc" },
usage = "panimate [animation]",
desc = "Plays a player animation",
modifiers = { "panimate" },
min = 2,
max = 2,
permission = "citizens.npc.panimate")
@Requirements(selected = true, ownership = true, types = EntityType.PLAYER)
public void playerAnimate(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
PlayerAnimation animation = Util.matchEnum(PlayerAnimation.values(), args.getString(1));
if (animation == null) {
Messaging.sendErrorTr(sender, Messages.UNKNOWN_PLAYER_ANIMATION,
Util.listValuesPretty(PlayerAnimation.values()));
return;
}
animation.play((Player) npc.getEntity(), 64);
}

@Command(
aliases = { "npc" },
usage = "playerlist (-a,r)",
Expand Down
1 change: 1 addition & 0 deletions main/src/main/java/net/citizensnpcs/util/Messages.java
Expand Up @@ -392,6 +392,7 @@ public class Messages {
public static final String UNDO_UNSUCCESSFUL = "citizens.commands.npc.undo.unsuccessful";
public static final String UNKNOWN_COMMAND = "citizens.commands.unknown-command";
public static final String UNKNOWN_MATERIAL = "citizens.commands.npc.item.unknown-material";
public static final String UNKNOWN_PLAYER_ANIMATION = "citizens.commands.npc.panimate.unknown-animation";
public static final String USING_MINECRAFT_AI = "citizens.commands.npc.ai.started";
public static final String VILLAGER_LEVEL_SET = "citizens.commands.npc.villager.level-set";
public static final String VILLAGER_TYPE_SET = "citizens.commands.npc.villager.type-set";
Expand Down
1 change: 1 addition & 0 deletions main/src/main/resources/messages_en.properties
Expand Up @@ -161,6 +161,7 @@ citizens.commands.npc.panda.sitting=Started sitting.
citizens.commands.npc.panda.stopped-sitting=Stopped sitting.
citizens.commands.npc.panda.main-gene-set=Main gene set to [[{0}]].
citizens.commands.npc.panda.hidden-gene-set=Hidden gene set to [[{0}]].
citizens.commands.npc.panimate.unknown-animation=Unknown animation. Valid animations are [[{0}]].
citizens.commands.npc.passive.set=[[{0}]] will no longer damage entities.
citizens.commands.npc.passive.unset=[[{0}]] will now damage entities.
citizens.commands.npc.pathfindingrange.set=Pathfinding range set to [[{0}]].
Expand Down

0 comments on commit 719f115

Please sign in to comment.