Skip to content

Commit 21187ed

Browse files
committed
Add target to /vel
Signed-off-by: Austin L Mayes <me@austinlm.me>
1 parent 3594159 commit 21187ed

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Bukkit/src/main/java/net/avicus/compendium/commands/UtilityCommands.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,19 @@ public void run() {
8787
}
8888

8989
@Command(aliases = {"vel",
90-
"velocity"}, desc = "Apply velocity to yourself.", min = 3, max = 3, help = "x y z")
90+
"velocity"}, desc = "Apply velocity to someone.", min = 3, max = 4, help = "x y z target")
9191
@CommandPermissions("compendium.vel")
9292
public static void velocity(CommandContext cmd, CommandSender sender) throws CommandException {
93-
if (!(sender instanceof Player)) {
93+
if (cmd.argsLength() != 4 && !(sender instanceof Player)) {
9494
throw new CommandException("You must be a player to use this command.");
9595
}
9696

97+
Player target = cmd.argsLength() == 4 ? Bukkit.getPlayer(cmd.getString(3)) : (Player) sender;
9798
String xString = cmd.getString(0);
9899
String yString = cmd.getString(1);
99100
String zString = cmd.getString(2);
100101
try {
101-
((Player) sender).setVelocity(new Vector(Float.parseFloat(xString), Float.parseFloat(yString),
102+
target.setVelocity(new Vector(Float.parseFloat(xString), Float.parseFloat(yString),
102103
Float.parseFloat(zString)));
103104
} catch (Exception e) {
104105
sender.sendMessage(ChatColor.RED + "Error in number syntax");

0 commit comments

Comments
 (0)