mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
Animation Command
This commit is contained in:
1 parent
ee72d22593
commit
2bd5f25410
3 files changed
+41
-14
No files matched your search
@@ -30,7 +30,7 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return "<player> <animation>";
|
||||
return "<player> <subcommand>";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,27 +41,53 @@ public class AnimationCommand extends CommandKamkeelBase {
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
|
||||
String playername = args[0];
|
||||
String animationName = args[1];
|
||||
|
||||
data = PlayerDataController.instance.getPlayersData(sender, playername);
|
||||
if (data.isEmpty()) {
|
||||
throw new CommandException("Unknown player: " + playername);
|
||||
}
|
||||
|
||||
selectedAnimation = AnimationController.getInstance().getAnimationFromName(animationName);
|
||||
|
||||
processSubCommand(sender, args[1], Arrays.copyOfRange(args, 2, args.length));
|
||||
data.get(0).animationData.updateClient();
|
||||
data.get(0).savePlayerDataOnFile();
|
||||
}
|
||||
|
||||
@SubCommand(desc = "enable animation")
|
||||
public void on(ICommandSender sender, String[] args) throws CommandException {
|
||||
data.get(0).animationData.setEnabled(true);
|
||||
sendMessage(sender, String.format("Animations enabled for Player %s", data.get(0).player.getCommandSenderName()));
|
||||
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "Set animation",
|
||||
usage = "<animation>"
|
||||
)
|
||||
public void set(ICommandSender sender, String[] args) throws CommandException {
|
||||
if(args.length != 1){
|
||||
throw new CommandException("Please include the animation name:" + "<player> set <animation name>");
|
||||
}
|
||||
String animationName = args[0];
|
||||
selectedAnimation = AnimationController.getInstance().getAnimationFromName(animationName);
|
||||
if (selectedAnimation == null) {
|
||||
throw new CommandException("Unknown animation: " + animationName);
|
||||
}
|
||||
|
||||
processSubCommand(sender, args[2], Arrays.copyOfRange(args, 3, args.length));
|
||||
}
|
||||
|
||||
@SubCommand(
|
||||
desc = "play animation",
|
||||
usage = "<player> <animation> play"
|
||||
)
|
||||
public void play(ICommandSender sender, String[] args) throws CommandException {
|
||||
data.get(0).animationData.setAnimation(selectedAnimation);
|
||||
sendMessage(sender, String.format("Animation %s set for Player %s", selectedAnimation.getName(), data.get(0).player.getCommandSenderName()));
|
||||
}
|
||||
|
||||
@SubCommand(desc = "disable animation")
|
||||
public void off(ICommandSender sender, String[] args) throws CommandException {
|
||||
data.get(0).animationData.setEnabled(false);
|
||||
sendMessage(sender, String.format("Animations disabled for Player %s", data.get(0).player.getCommandSenderName()));
|
||||
}
|
||||
|
||||
@SubCommand(desc = "play animation")
|
||||
public void clear(ICommandSender sender, String[] args) throws CommandException {
|
||||
data.get(0).animationData.setEnabled(false);
|
||||
data.get(0).animationData.setAnimation(null);
|
||||
sendMessage(sender, String.format("Animations cleared for Player %s", data.get(0).player.getCommandSenderName()));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public class CommandKamkeel extends CommandBase{
|
||||
registerCommand(new NpcCommand());
|
||||
registerCommand(new CloneCommand());
|
||||
registerCommand(new ConfigCommand());
|
||||
registerCommand(new AnimationCommand());
|
||||
}
|
||||
|
||||
public void registerCommand(CommandKamkeelBase command){
|
||||
|
||||
@@ -232,8 +232,8 @@ public class DataTransform {
|
||||
inv = compound;
|
||||
}
|
||||
npc.updateHitbox();
|
||||
this.isActive = isActive;
|
||||
npc.updateAI= true;
|
||||
npc.updateAI = true;
|
||||
this.isActive = isActive;
|
||||
npc.updateClient = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user