summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java8
-rw-r--r--src/main/java/org/bukkit/command/defaults/VanillaCommand.java12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java b/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java
index 4caf2bbe..3dfb0483 100644
--- a/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java
@@ -29,7 +29,7 @@ public class PlaySoundCommand extends VanillaCommand {
final Player player = Bukkit.getPlayerExact(playerArg);
if (player == null) {
- sender.sendMessage(ChatColor.RED + "Can't find player %s" + playerArg);
+ sender.sendMessage(ChatColor.RED + "Can't find player " + playerArg);
return false;
}
@@ -51,11 +51,11 @@ public class PlaySoundCommand extends VanillaCommand {
case 6:
volume = getDouble(sender, args[5], 0.0D, Float.MAX_VALUE);
case 5:
- z = getDouble(sender, args[4]);
+ z = getRelativeDouble(z, sender, args[4]);
case 4:
- y = getDouble(sender, args[3]);
+ y = getRelativeDouble(y, sender, args[3]);
case 3:
- x = getDouble(sender, args[2]);
+ x = getRelativeDouble(x, sender, args[2]);
case 2:
// Noop
}
diff --git a/src/main/java/org/bukkit/command/defaults/VanillaCommand.java b/src/main/java/org/bukkit/command/defaults/VanillaCommand.java
index 997cb39c..e8ade12c 100644
--- a/src/main/java/org/bukkit/command/defaults/VanillaCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VanillaCommand.java
@@ -58,6 +58,18 @@ public abstract class VanillaCommand extends Command {
}
}
+ public static double getRelativeDouble(double original, CommandSender sender, String input) {
+ if (input.startsWith("~")) {
+ double value = getDouble(sender, input.substring(1));
+ if (value == MIN_COORD_MINUS_ONE) {
+ return MIN_COORD_MINUS_ONE;
+ }
+ return original + value;
+ } else {
+ return getDouble(sender, input);
+ }
+ }
+
public static double getDouble(CommandSender sender, String input) {
try {
return Double.parseDouble(input);