geforkt von Mirrors/Paper
Account for relative coordinates in PlaySound. Fixes BUKKIT-4639
By: Wesley Wolfe <weswolf@aol.com>
Dieser Commit ist enthalten in:
Ursprung
804827463e
Commit
47d09288b4
@ -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
|
||||
}
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren