Finish command refactoring

This commit is contained in:
William278 committed 2023-03-20 12:57:52 +00:00
1 parent 34eb2c1f54
commit 8b809b6b5b
34 files changed
+427 -589

No files matched your search

@@ -2,6 +2,7 @@ package net.william278.huskhomes.command;
import me.lucko.commodore.CommodoreProvider;
import net.william278.huskhomes.BukkitHuskHomes;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.user.BukkitUser;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
@@ -34,7 +35,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command,
@NotNull String alias, @NotNull String[] args) {
return this.command.suggest(sender instanceof Player player ? BukkitUser.adapt(player) : plugin.getConsole(), args);
return this.command.getSuggestions(sender instanceof Player player ? BukkitUser.adapt(player) : plugin.getConsole(), args);
}
public void register() {
@@ -99,8 +100,8 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
EDIT_WARP_COMMAND(new EditWarpCommand(BukkitHuskHomes.getInstance())),
TP_COMMAND(new TpCommand(BukkitHuskHomes.getInstance())),
TP_HERE_COMMAND(new TpHereCommand(BukkitHuskHomes.getInstance())),
TPA_COMMAND(new TpaCommand(BukkitHuskHomes.getInstance())),
TPA_HERE_COMMAND(new TpaHereCommand(BukkitHuskHomes.getInstance())),
TPA_COMMAND(new TeleportRequestCommand(BukkitHuskHomes.getInstance(), TeleportRequest.Type.TPA)),
TPA_HERE_COMMAND(new TeleportRequestCommand(BukkitHuskHomes.getInstance(), TeleportRequest.Type.TPA_HERE)),
TPACCEPT_COMMAND(new TpRespondCommand(BukkitHuskHomes.getInstance(), true)),
TPDECLINE_COMMAND(new TpRespondCommand(BukkitHuskHomes.getInstance(), false)),
RTP_COMMAND(new RtpCommand(BukkitHuskHomes.getInstance())),
@@ -154,9 +154,9 @@ public interface HuskHomes extends TaskRunner, EventDispatcher {
*
* @return the {@link Position} of the spawn, or an empty {@link Optional} if it has not been set
*/
default Optional<? extends Position> getSpawn() {
default Optional<Position> getSpawn() {
return getSettings().isCrossServer() && getSettings().isGlobalSpawn()
? getDatabase().getWarp(getSettings().getGlobalSpawnName())
? getDatabase().getWarp(getSettings().getGlobalSpawnName()).map(warp -> (Position) warp)
: getLocalCachedSpawn().map(spawn -> spawn.getPosition(getServerName()));
}
@@ -12,8 +12,7 @@ public abstract class Command extends Node implements TabProvider {
private final String usage;
protected Command(@NotNull String name, @NotNull List<String> aliases, @NotNull String usage,
@NotNull HuskHomes plugin) {
protected Command(@NotNull String name, @NotNull List<String> aliases, @NotNull String usage, @NotNull HuskHomes plugin) {
super(name, aliases, plugin);
this.usage = usage;
}
@@ -65,4 +64,9 @@ public abstract class Command extends Node implements TabProvider {
return Map.of();
}
@NotNull
public final HuskHomes getPlugin() {
return plugin;
}
}
@@ -0,0 +1,29 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public abstract class InGameCommand extends Command {
protected InGameCommand(@NotNull String name, @NotNull List<String> aliases, @NotNull String usage,
@NotNull HuskHomes plugin) {
super(name, aliases, usage, plugin);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
.ifPresent(executor::sendMessage);
return;
}
this.execute(user, args);
}
public abstract void execute(@NotNull OnlineUser executor, @NotNull String[] args);
}
@@ -1,14 +1,18 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.World;
import net.william278.huskhomes.teleport.Teleportable;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.ConsoleUser;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.UUID;
public abstract class Node implements Executable {
@@ -86,6 +90,17 @@ public abstract class Node implements Executable {
return Optional.empty();
}
protected Optional<Float> parseFloatArg(@NotNull String[] args, int index) {
try {
if (args.length > index) {
return Optional.of(Float.parseFloat(args[index]));
}
} catch (NumberFormatException e) {
return Optional.empty();
}
return Optional.empty();
}
protected Optional<Double> parseDoubleArg(@NotNull String[] args, int index) {
try {
if (args.length > index) {
@@ -97,6 +112,25 @@ public abstract class Node implements Executable {
return Optional.empty();
}
protected Optional<Double> parseCoordinateArg(@NotNull String[] args, int index, double relativeTo) {
try {
if (args.length > index) {
final String arg = args[index];
if (arg.startsWith("~")) {
final String coordinate = arg.substring(1);
if (coordinate.isBlank()) {
return Optional.of(relativeTo);
}
return Optional.of(relativeTo + Double.parseDouble(coordinate));
}
return Optional.of(Double.parseDouble(arg));
}
} catch (NumberFormatException e) {
return Optional.empty();
}
return Optional.empty();
}
protected Optional<String> parseStringArg(@NotNull String[] args, int index) {
if (args.length > index) {
return Optional.of(args[index]);
@@ -104,6 +138,19 @@ public abstract class Node implements Executable {
return Optional.empty();
}
protected Optional<World> parseWorldArg(@NotNull String[] args, int index) {
if (args.length > index) {
final String worldName = args[index];
final World.Environment environment = worldName.endsWith("_the_end") ? World.Environment.THE_END :
worldName.endsWith("nether") ? World.Environment.NETHER : World.Environment.OVERWORLD;
return Optional.of(plugin.getWorlds().stream()
.filter(world -> world.getName().equalsIgnoreCase(worldName))
.findFirst()
.orElse(new World(worldName, new UUID(0, 0), environment)));
}
return Optional.empty();
}
protected Optional<String> parseGreedyString(@NotNull String[] args, int startIndex) {
if (args.length > startIndex) {
final StringJoiner sentence = new StringJoiner(" ");
@@ -115,9 +162,39 @@ public abstract class Node implements Executable {
return Optional.empty();
}
protected Position getBasePosition(@NotNull CommandUser executor) {
return executor instanceof OnlineUser user ? user.getPosition() : plugin.getSpawn()
.orElse(new Position(0, 0, 0, 0, 0, plugin.getWorlds().get(0), plugin.getServerName()));
}
protected Optional<Position> parsePositionArgs(@NotNull Position basePosition, @NotNull String[] args, int startIndex) {
// Parse x, y, and z
final Optional<Double> x = parseCoordinateArg(args, startIndex, basePosition.getX());
final Optional<Double> y = parseCoordinateArg(args, startIndex + 1, basePosition.getY());
final Optional<Double> z = parseCoordinateArg(args, startIndex + 2, basePosition.getZ());
if (x.isEmpty() || y.isEmpty() || z.isEmpty()) {
return Optional.empty();
}
// Parse world and server name
final Optional<World> world = parseWorldArg(args, startIndex + 3);
final Optional<String> server = parseStringArg(args, startIndex + 4);
// Parse yaw, pitch
int angleStartIndex = (world.isEmpty() ? 3 : server.isEmpty() ? 4 : 5);
final Optional<Float> yaw = parseFloatArg(args, startIndex + angleStartIndex);
final Optional<Float> pitch = parseFloatArg(args, startIndex + angleStartIndex + 1);
return Optional.of(new Position(x.get(), y.get(), z.get(),
yaw.orElse(basePosition.getYaw()), pitch.orElse(basePosition.getPitch()),
world.orElse(basePosition.getWorld()), server.orElse(basePosition.getServer())));
}
protected Optional<Teleportable> resolveTeleportable(@NotNull CommandUser executor, @NotNull String[] args) {
return parseStringArg(args, 0).map(Teleportable::username)
.or(() -> executor instanceof Teleportable ? Optional.of((Teleportable) executor) : Optional.empty());
}
}
@@ -1,35 +1,28 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional;
public abstract class SetPositionCommand extends Command {
public abstract class SetPositionCommand extends InGameCommand {
protected SetPositionCommand(@NotNull String name, @NotNull HuskHomes plugin) {
super(name, List.of(), "<name>", plugin);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Optional<String> name = parseStringArg(args, 0);
if (name.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(executor::sendMessage);
return;
}
final Optional<String> name = parseStringArg(args, 0);
if (name.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(user::sendMessage);
return;
}
this.execute(user, name.get());
this.execute(executor, name.get());
}
protected abstract void execute(@NotNull OnlineUser setter, @NotNull String name);
@@ -2,28 +2,21 @@ package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.util.ValidationException;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class SetSpawnCommand extends Command {
public class SetSpawnCommand extends InGameCommand {
protected SetSpawnCommand(@NotNull HuskHomes plugin) {
super("setspawn", List.of(), "", plugin);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
.ifPresent(executor::sendMessage);
return;
}
final Position position = user.getPosition();
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Position position = executor.getPosition();
try {
if (plugin.getSettings().isCrossServer() && plugin.getSettings().isGlobalSpawn()) {
final String warpName = plugin.getSettings().getGlobalSpawnName();
@@ -0,0 +1,57 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.manager.RequestsManager;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Optional;
public class TeleportRequestCommand extends InGameCommand implements UserListTabProvider {
private final TeleportRequest.Type requestType;
protected TeleportRequestCommand(@NotNull HuskHomes plugin, @NotNull TeleportRequest.Type requestType) {
super(requestType == TeleportRequest.Type.TPA ? "tpa" : "tpahere", List.of(), "<player>", plugin);
this.requestType = requestType;
}
@Override
public void execute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
final RequestsManager manager = plugin.getManager().requests();
if (manager.isIgnoringRequests(onlineUser)) {
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
.ifPresent(onlineUser::sendMessage);
return;
}
final Optional<String> optionalTarget = parseStringArg(args, 0);
if (optionalTarget.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(onlineUser::sendMessage);
return;
}
final String target = optionalTarget.get();
if (target.equalsIgnoreCase(onlineUser.getUsername())) {
plugin.getLocales().getLocale("error_teleport_request_self")
.ifPresent(onlineUser::sendMessage);
return;
}
try {
manager.sendTeleportRequest(onlineUser, target, requestType);
} catch (IllegalArgumentException e) {
plugin.getLocales().getLocale("error_player_not_found", target)
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales()
.getLocale(requestType == TeleportRequest.Type.TPA ? "tpa" : "tpahere" + "_request_sent", target)
.ifPresent(onlineUser::sendMessage);
}
}
@@ -1,6 +1,8 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.network.Message;
import net.william278.huskhomes.network.Payload;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.Teleport;
@@ -9,42 +11,32 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public class TpAllCommand extends Command {
public class TpAllCommand extends InGameCommand {
protected TpAllCommand(@NotNull HuskHomes implementor) {
super("tpall", Permission.COMMAND_TPALL, implementor);
protected TpAllCommand(@NotNull HuskHomes plugin) {
super("tpall", List.of(), "", plugin);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (args.length != 0) {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpaall")
.ifPresent(onlineUser::sendMessage);
return;
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Position targetPosition = executor.getPosition();
for (OnlineUser user : plugin.getOnlineUsers()) {
Teleport.builder(plugin)
.teleporter(user)
.target(targetPosition)
.toTeleport().execute();
}
// Determine players to teleport and teleport them
plugin.getCache().updatePlayerListCache(plugin, onlineUser).thenAccept(fetchedPlayers -> {
final List<String> players = fetchedPlayers.stream()
.filter(userName -> !userName.equalsIgnoreCase(onlineUser.getUsername())).toList();
if (players.isEmpty()) {
plugin.getLocales().getLocale("error_no_players_online").ifPresent(onlineUser::sendMessage);
return;
}
// Send a message
plugin.getLocales().getLocale("teleporting_all_players", Integer.toString(players.size()))
.ifPresent(onlineUser::sendMessage);
// Teleport every player
final Position targetPosition = onlineUser.getPosition();
players.forEach(playerName -> Teleport.builder(plugin, onlineUser)
.setTeleporter(playerName)
.setTarget(targetPosition)
.toTeleport()
.thenAccept(Teleport::execute));
});
if (plugin.getSettings().isCrossServer()) {
Message.builder()
.target(Message.TARGET_ALL)
.type(Message.Type.TELEPORT_TO_POSITION)
.payload(Payload.withPosition(targetPosition))
.build().send(plugin.getMessenger(), executor);
}
plugin.getLocales().getLocale("teleporting_all_players")
.ifPresent(executor::sendMessage);
}
}
@@ -1,220 +1,90 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.teleport.*;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.position.Server;
import net.william278.huskhomes.position.World;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class TpCommand extends Command implements TabProvider, ConsoleExecutable {
public class TpCommand extends Command implements TabProvider {
protected TpCommand(@NotNull HuskHomes implementor) {
super("tp", Permission.COMMAND_TP, implementor, "tpo");
super("tp", List.of("tpo"), "[<player|position>] [target]", implementor);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
// Ensure a valid target was found
final Optional<TeleportTarget> teleportTarget = getTeleportTarget(args, onlineUser);
if (teleportTarget.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", "/tp <target> [destination]")
.ifPresent(onlineUser::sendMessage);
return;
}
// Determine the player to teleport
final String targetPlayerToTeleport = ((teleportTarget.get() instanceof TargetPlayer) && args.length == 2)
? args[0] : ((teleportTarget.get() instanceof TargetPosition)
? args.length > 3 ? (isCoordinate(args[1]) && isCoordinate(args[2]) && isCoordinate(args[3]) ? args[0] : onlineUser.getUsername())
: onlineUser.getUsername() : onlineUser.getUsername());
// Find the online user to teleport
plugin.getCache().updatePlayerListCache(plugin, onlineUser).thenRun(() -> {
// Get the list of potential teleports, filtered against vanished players, but ensuring the executor is in the list
final Set<String> players = plugin.getCache().getPlayers();
players.add(onlineUser.getUsername());
// Find the player to teleport
final String playerToTeleport = players.stream()
.filter(user -> user.equalsIgnoreCase(targetPlayerToTeleport)).findFirst()
.or(() -> Optional.ofNullable(targetPlayerToTeleport.equals("@s") ? onlineUser.getUsername() : null))
.or(() -> plugin.getCache().getPlayers().stream().filter(user -> user.toLowerCase().startsWith(targetPlayerToTeleport)).findFirst())
.orElse(null);
// Ensure the player to teleport exists
if (playerToTeleport == null) {
plugin.getLocales().getLocale("error_player_not_found", targetPlayerToTeleport)
.ifPresent(onlineUser::sendMessage);
return;
}
// Ensure the user has permission to teleport the player to teleport
if (!playerToTeleport.equals(onlineUser.getUsername())) {
if (!onlineUser.hasPermission(Permission.COMMAND_TP_OTHER.node)) {
plugin.getLocales().getLocale("error_no_permission")
.ifPresent(onlineUser::sendMessage);
return;
}
}
// Execute the teleport
if (teleportTarget.get() instanceof TargetPlayer targetPlayer) {
// Carry out the teleport to a player, by name
Teleport.builder(plugin, onlineUser)
.setTeleporter(playerToTeleport)
.setTarget(targetPlayer.playerName)
.toTeleport()
.thenAccept(teleport -> teleport.execute().thenAccept(result -> {
if (result.successful()) {
result.getTeleporter()
.flatMap(teleporter -> plugin.getLocales().getLocale("teleporting_other_complete",
teleporter.getUsername(), targetPlayer.playerName))
.ifPresent(onlineUser::sendMessage);
} else {
plugin.getLocales().getLocale("error_player_not_found", targetPlayer.playerName)
.ifPresent(onlineUser::sendMessage);
}
}));
} else if (teleportTarget.get() instanceof TargetPosition targetPosition) {
// Handle coordinate teleport targets
if (!onlineUser.hasPermission(Permission.COMMAND_TP_TO_COORDINATES.node)) {
plugin.getLocales().getLocale("error_no_permission").ifPresent(onlineUser::sendMessage);
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
switch (args.length) {
case 1 -> {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
.ifPresent(executor::sendMessage);
return;
}
// Carry out the teleport to a position
Teleport.builder(plugin, onlineUser)
.setTeleporter(playerToTeleport)
.setTarget(targetPosition.position)
.toTeleport()
.thenAccept(teleport -> teleport.execute().thenAccept(result -> {
if (!result.successful() || playerToTeleport.equalsIgnoreCase(onlineUser.getUsername()) || result.getDestination().isEmpty()) {
return;
}
final Position destination = result.getDestination().get();
result.getTeleporter()
.flatMap(teleporter -> plugin.getLocales()
.getLocale("teleporting_other_complete_position", teleporter.getUsername(),
Integer.toString((int) destination.getX()),
Integer.toString((int) destination.getY()),
Integer.toString((int) destination.getZ())))
.ifPresent(onlineUser::sendMessage);
}));
this.execute(executor, user, Target.username(args[0]), args);
}
});
case 2 -> execute(executor, Teleportable.username(args[0]), Target.username(args[1]), args);
default -> {
final Position basePosition = getBasePosition(executor);
Optional<Position> target = parsePositionArgs(basePosition, args, 0);
if (target.isPresent()) {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
.ifPresent(executor::sendMessage);
return;
}
this.execute(executor, user, target.get(), args);
return;
}
target = parsePositionArgs(basePosition, args, 1);
if (target.isPresent() && args.length >= 1) {
this.execute(executor, Teleportable.username(args[0]), target.get(), args);
return;
}
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(executor::sendMessage);
}
}
}
/**
* Determines the teleport target from a set of arguments, which may be comprised of usernames and/or position
* coordinates with a world and server.
*
* @param args The arguments to parse.
* @param relativeTo The position to use as a relative reference. This is used for relative coordinate handling
* (e.g. {@code ~-10 ~ ~20})
* @return The teleport target, if it could be parsed, otherwise and empty {@link Optional}.
*/
@NotNull
private Optional<TeleportTarget> getTeleportTarget(@NotNull String[] args, @NotNull OnlineUser relativeTo) {
if (args.length == 1 || args.length == 2) {
return Optional.of(new TargetPlayer(args[args.length - 1]));
}
if (args.length > 2 && args.length < 7) {
final Optional<TeleportTarget> targetPosition = Position.parse(args, relativeTo.getPosition())
.map(TargetPosition::new);
return targetPosition.or(() -> Position.parse(Arrays.copyOfRange(args, 1, args.length),
relativeTo.getPosition()).map(TargetPosition::new));
}
return Optional.empty();
}
/**
* Determines if a string is a valid (relative) position coordinate double target.
*
* @param coordinate The string to check.
* @return {@code true} if the string is a valid coordinate, otherwise {@code false}.
*/
private boolean isCoordinate(@NotNull String coordinate) {
// Execute a teleport
private void execute(@NotNull CommandUser executor, @NotNull Teleportable teleportable, @NotNull Target target,
@NotNull String[] args) {
try {
if (coordinate.startsWith("~")) {
coordinate = coordinate.substring(1);
final TeleportBuilder builder = Teleport.builder(plugin)
.teleporter(teleportable)
.target(target);
if (executor instanceof OnlineUser user) {
builder.executor(user);
}
if (coordinate.isBlank()) {
return true;
}
Double.parseDouble(coordinate);
return true;
} catch (NumberFormatException e) {
return false;
builder.toTeleport().execute();
} catch (TeleportationException e) {
e.displayMessage(executor, plugin, args);
}
}
@Override
public void onConsoleExecute(@NotNull String[] args) {
if (args.length < 2 || args.length > 6) {
plugin.log(Level.WARNING, "Invalid syntax. Usage: tp <player> <destination>");
return;
}
final OnlineUser playerToTeleport = plugin.findOnlinePlayer(args[0]).orElse(null);
if (playerToTeleport == null) {
plugin.log(Level.WARNING, "Player not found: " + args[0]);
return;
}
final TeleportTarget teleportTarget;
if (args.length == 2) {
teleportTarget = new TargetPlayer(args[1]);
} else {
try {
teleportTarget = new TargetPosition(new Position(
Double.parseDouble(args[1]),
Double.parseDouble(args[2]),
Double.parseDouble(args[3]),
0f, 0f,
args.length >= 5 ? new World(args[4], UUID.randomUUID()) : plugin.getWorlds().get(0),
args.length == 6 ? new Server(args[5]) : plugin.getServerName()));
} catch (NumberFormatException e) {
plugin.log(Level.WARNING, "Invalid syntax. Usage: tp <player> <x> <y> <z> [world] [server]");
return;
}
}
// Execute the console teleport
final TeleportBuilder builder = Teleport.builder(plugin, playerToTeleport)
.setTeleporter(playerToTeleport.getUsername());
if (teleportTarget instanceof TargetPlayer targetPlayer) {
builder.setTarget(targetPlayer.playerName);
} else {
builder.setTarget(((TargetPosition) teleportTarget).position);
}
builder.toTeleport().thenAccept(teleport -> teleport.execute().thenAccept(result -> {
if (result.successful()) {
plugin.log(Level.INFO, "Successfully teleported " + playerToTeleport.getUsername());
} else {
plugin.log(Level.WARNING, "Failed to teleport " + playerToTeleport.getUsername() + " to " + teleportTarget);
}
}));
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
final boolean serveCoordinateCompletions = user != null && user.hasPermission(Permission.COMMAND_TP_TO_COORDINATES.node);
final Position basePosition = getBasePosition(user);
final boolean serveCoordinateCompletions = user.hasPermission(getPermission("coordinates"));
switch (args.length) {
case 0, 1 -> {
final ArrayList<String> completions = new ArrayList<>();
completions.addAll(serveCoordinateCompletions
? List.of("~", "~ ~", "~ ~ ~",
Integer.toString((int) user.getPosition().getX()),
((int) user.getPosition().getX() + " " + (int) user.getPosition().getY()),
((int) user.getPosition().getX() + " " + (int) user.getPosition().getY() + " " + (int) user.getPosition().getZ()))
: Collections.emptyList());
Integer.toString((int) basePosition.getX()),
((int) basePosition.getX() + " " + (int) basePosition.getY()),
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
: List.of());
completions.addAll(plugin.getCache().getPlayers());
return completions.stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
@@ -222,19 +92,16 @@ public class TpCommand extends Command implements TabProvider, ConsoleExecutable
}
case 2 -> {
final ArrayList<String> completions = new ArrayList<>();
if (isCoordinate(args[0])) {
if (user == null) {
return completions;
}
completions.addAll(List.of("~", Integer.toString((int) user.getPosition().getY())));
completions.addAll(List.of("~ ~", (int) user.getPosition().getY() + " " + (int) user.getPosition().getZ()));
if (isCoordinate(args, 0)) {
completions.addAll(List.of("~", Integer.toString((int) basePosition.getY())));
completions.addAll(List.of("~ ~", (int) basePosition.getY() + " " + (int) basePosition.getZ()));
} else {
completions.addAll(serveCoordinateCompletions
? List.of("~", "~ ~", "~ ~ ~",
Integer.toString((int) user.getPosition().getX()),
((int) user.getPosition().getX() + " " + (int) user.getPosition().getY()),
((int) user.getPosition().getX() + " " + (int) user.getPosition().getY() + " " + (int) user.getPosition().getZ()))
: Collections.emptyList());
Integer.toString((int) basePosition.getX()),
((int) basePosition.getX() + " " + (int) basePosition.getY()),
((int) basePosition.getX() + " " + (int) basePosition.getY() + " " + (int) basePosition.getZ()))
: List.of());
completions.addAll(plugin.getCache().getPlayers());
}
return completions.stream()
@@ -243,17 +110,17 @@ public class TpCommand extends Command implements TabProvider, ConsoleExecutable
}
case 3 -> {
final ArrayList<String> completions = new ArrayList<>();
if (isCoordinate(args[0]) && isCoordinate(args[1])) {
if (isCoordinate(args, 1) && isCoordinate(args, 2)) {
if (!serveCoordinateCompletions) {
return completions;
}
completions.addAll(List.of("~", Integer.toString((int) user.getPosition().getZ())));
} else if (isCoordinate(args[1])) {
completions.addAll(List.of("~", Integer.toString((int) basePosition.getZ())));
} else if (isCoordinate(args, 1)) {
if (!serveCoordinateCompletions) {
return completions;
}
completions.addAll(List.of("~", Integer.toString((int) user.getPosition().getY())));
completions.addAll(List.of("~ ~", (int) user.getPosition().getY() + " " + (int) user.getPosition().getZ()));
completions.addAll(List.of("~", Integer.toString((int) basePosition.getY())));
completions.addAll(List.of("~ ~", (int) basePosition.getY() + " " + (int) basePosition.getZ()));
}
return completions.stream()
.filter(s -> s.toLowerCase().startsWith(args[2].toLowerCase()))
@@ -261,54 +128,24 @@ public class TpCommand extends Command implements TabProvider, ConsoleExecutable
}
case 4 -> {
final ArrayList<String> completions = new ArrayList<>();
if (isCoordinate(args[1]) && isCoordinate(args[2]) && !isCoordinate(args[0])) {
if (isCoordinate(args, 1) && isCoordinate(args, 2) && !isCoordinate(args, 0)) {
if (!serveCoordinateCompletions) {
return completions;
}
completions.addAll(List.of("~", Integer.toString((int) user.getPosition().getZ())));
completions.addAll(List.of("~", Integer.toString((int) basePosition.getZ())));
}
return completions.stream()
.filter(s -> s.toLowerCase().startsWith(args[3].toLowerCase()))
.sorted().collect(Collectors.toList());
}
default -> {
return Collections.emptyList();
return List.of();
}
}
}
/**
* Represents a target position to teleport to
*/
private static final class TargetPosition extends TeleportTarget {
/**
* The target {@link Position}
*/
private final Position position;
private TargetPosition(@NotNull Position position) {
this.position = position;
}
private boolean isCoordinate(@NotNull String[] args, int index) {
return parseCoordinateArg(args, index, 0d).isPresent();
}
/**
* Represents a target player to teleport to
*/
private static final class TargetPlayer extends TeleportTarget {
/**
* Name of the target player
*/
private final String playerName;
private TargetPlayer(@NotNull String playerName) {
this.playerName = playerName;
}
}
/**
* Identifies the target of a teleport command operation
*/
private static abstract class TeleportTarget {
}
}
@@ -1,6 +1,9 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.teleport.Target;
import net.william278.huskhomes.teleport.Teleportable;
import net.william278.huskhomes.teleport.TeleportationException;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.util.Permission;
@@ -9,53 +12,34 @@ import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class TpHereCommand extends Command implements TabProvider {
public class TpHereCommand extends InGameCommand implements UserListTabProvider {
protected TpHereCommand(@NotNull HuskHomes implementor) {
super("tphere", Permission.COMMAND_TPHERE, implementor, "tpohere");
protected TpHereCommand(@NotNull HuskHomes plugin) {
super("tphere", List.of("tpohere"), "<player>", plugin);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
CompletableFuture.runAsync(() -> {
if (args.length != 1) {
plugin.getLocales().getLocale("error_invalid_syntax", "/tphere <player>")
.ifPresent(onlineUser::sendMessage);
return;
}
final String targetPlayerName = args[0];
plugin.findPlayer(onlineUser, targetPlayerName).thenAccept(teleporterName -> {
if (teleporterName.isEmpty()) {
plugin.getLocales().getLocale("error_player_not_found", targetPlayerName)
.ifPresent(onlineUser::sendMessage);
return;
}
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Optional<String> optionalTarget = parseStringArg(args, 0);
if (optionalTarget.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(executor::sendMessage);
return;
}
Teleport.builder(plugin, onlineUser)
.setTeleporter(teleporterName.get())
.setTarget(onlineUser.getPosition())
.toTeleport()
.thenAccept(teleport -> teleport.execute().thenAccept(result -> {
if (result.successful()) {
result.getTeleporter()
.flatMap(teleporter -> plugin.getLocales().getLocale("teleporting_other_complete",
teleporter.getUsername(), onlineUser.getUsername()))
.ifPresent(onlineUser::sendMessage);
}
}));
});
});
try {
Teleport.builder(plugin)
.executor(executor)
.teleporter(optionalTarget.get())
.target(executor.getPosition())
.toTeleport().execute();
} catch (TeleportationException e) {
e.displayMessage(executor, plugin, args);
}
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? plugin.getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
}
@@ -2,35 +2,34 @@ package net.william278.huskhomes.command;
import de.themoep.minedown.adventure.MineDown;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.manager.RequestsManager;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.user.SavedUser;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
public class TpIgnoreCommand extends Command {
import java.util.List;
protected TpIgnoreCommand(@NotNull HuskHomes implementor) {
super("tpignore", Permission.COMMAND_TPIGNORE, implementor);
public class TpIgnoreCommand extends InGameCommand {
protected TpIgnoreCommand(@NotNull HuskHomes plugin) {
super("tpignore", List.of(), "", plugin);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (args.length != 0) {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpignore")
.ifPresent(onlineUser::sendMessage);
return;
}
public void execute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
final RequestsManager manager = plugin.getManager().requests();
final boolean isIgnoringRequests = !manager.isIgnoringRequests(onlineUser);
// Update local value
final boolean isIgnoringRequests = !plugin.getRequestManager().isIgnoringRequests(onlineUser);
plugin.getRequestManager().setIgnoringRequests(onlineUser, isIgnoringRequests);
final SavedUser user = plugin.getDatabase().getUserData(onlineUser.getUuid())
.orElseThrow(() -> new IllegalStateException("User data not found for " + onlineUser.getUsername()));
user.setIgnoringTeleports(isIgnoringRequests);
manager.setIgnoringRequests(onlineUser, isIgnoringRequests);
plugin.getDatabase().updateUserData(user);
// Update value on the database and send a message | todo: Clean this up
plugin.getDatabase().getUserData(onlineUser.getUuid())
.thenAcceptAsync(userData -> userData.ifPresent(data -> plugin.getDatabase()
.updateUserData(new SavedUser(onlineUser, data.homeSlots(), isIgnoringRequests, data.rtpCooldown()))
.thenRun(() -> plugin.getLocales().getRawLocale("tpignore_toggle_" + (isIgnoringRequests ? "on" : "off"),
plugin.getLocales().getRawLocale("tpignore_toggle_button").orElse(""))
.ifPresent(locale -> onlineUser.sendMessage(new MineDown(locale))))));
plugin.getLocales().getRawLocale("tpignore_toggle_" + (isIgnoringRequests ? "on" : "off"),
plugin.getLocales().getRawLocale("tpignore_toggle_button").orElse(""))
.map(MineDown::new)
.ifPresent(onlineUser::sendMessage);
}
}
@@ -4,31 +4,22 @@ import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.teleport.TeleportationException;
import net.william278.huskhomes.user.CommandUser;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.user.SavedUser;
import net.william278.huskhomes.user.User;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class TpOfflineCommand extends Command implements TabProvider {
public class TpOfflineCommand extends InGameCommand implements UserListTabProvider {
protected TpOfflineCommand(@NotNull HuskHomes plugin) {
super("tpoffline", List.of(), "<player>", plugin);
}
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
if (!(executor instanceof OnlineUser user)) {
plugin.getLocales().getLocale("error_in_game_only")
.ifPresent(executor::sendMessage);
return;
}
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Optional<String> optionalUser = parseStringArg(args, 0);
if (optionalUser.isEmpty()) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
@@ -45,7 +36,7 @@ public class TpOfflineCommand extends Command implements TabProvider {
return;
}
this.teleportToOfflinePosition(user, targetUserData.get(), args);
this.teleportToOfflinePosition(executor, targetUserData.get(), args);
}
private void teleportToOfflinePosition(@NotNull OnlineUser user, @NotNull User target, @NotNull String[] args) {
@@ -71,12 +62,4 @@ public class TpOfflineCommand extends Command implements TabProvider {
}
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? plugin.getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
}
@@ -2,49 +2,32 @@ package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Optional;
/**
* A command used for responding to tp requests - can either be a /tpaccept or /tpdecline command, controlled by the
* acceptRequestCommand flag
*/
public class TpRespondCommand extends Command implements TabProvider {
public class TpRespondCommand extends InGameCommand implements UserListTabProvider {
private final boolean acceptRequestCommand;
private final boolean accept;
protected TpRespondCommand(@NotNull HuskHomes implementor, boolean acceptRequestCommand) {
super(acceptRequestCommand ? "tpaccept" : "tpdecline", acceptRequestCommand ? Permission.COMMAND_TPACCEPT : Permission.COMMAND_TPDECLINE, implementor);
this.acceptRequestCommand = acceptRequestCommand;
protected TpRespondCommand(@NotNull HuskHomes plugin, boolean accept) {
super(accept ? "tpaccept" : "tpdecline", List.of(), "[player]", plugin);
this.accept = accept;
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (args.length > 1) {
plugin.getLocales().getLocale("error_invalid_syntax", "/" + command + " [player]")
.ifPresent(onlineUser::sendMessage);
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
final Optional<String> requesterName = parseStringArg(args, 0);
if (requesterName.isPresent()) {
plugin.getManager().requests().respondToTeleportRequestBySenderName(executor, requesterName.get(), accept);
return;
}
if (args.length == 1) {
// Respond to the request from specified sender name
plugin.getRequestManager().respondToTeleportRequestBySenderName(onlineUser, args[0], acceptRequestCommand);
return;
}
plugin.getRequestManager().respondToTeleportRequest(onlineUser, acceptRequestCommand);
plugin.getManager().requests().respondToTeleportRequest(executor, accept);
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? plugin.getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
}
@@ -1,63 +1,38 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.network.Message;
import net.william278.huskhomes.network.Payload;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.teleport.TeleportBuilder;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
public class TpaAllCommand extends Command {
public class TpaAllCommand extends InGameCommand {
protected TpaAllCommand(@NotNull HuskHomes implementor) {
super("tpaall", Permission.COMMAND_TPA_ALL, implementor);
protected TpaAllCommand(@NotNull HuskHomes plugin) {
super("tpaall", List.of(), "", plugin);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
public void execute(@NotNull OnlineUser executor, @NotNull String[] args) {
if (plugin.getManager().requests().isIgnoringRequests(executor)) {
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
.ifPresent(onlineUser::sendMessage);
.ifPresent(executor::sendMessage);
return;
}
if (args.length != 0) {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpaall")
.ifPresent(onlineUser::sendMessage);
return;
}
// Determine players to teleport and teleport them
plugin.getCache().updatePlayerListCache(plugin, onlineUser).thenAccept(playerList -> {
final List<String> players = plugin.getCache().getPlayers().stream()
.filter(userName -> !userName.equalsIgnoreCase(onlineUser.getUsername())).toList();
if (players.isEmpty()) {
plugin.getLocales().getLocale("error_no_players_online").ifPresent(onlineUser::sendMessage);
return;
}
// Send a teleport request to every player
final AtomicInteger counter = new AtomicInteger(0);
final List<CompletableFuture<Void>> sentRequestsFuture = new ArrayList<>();
players.forEach(playerName -> sentRequestsFuture.add(plugin.getRequestManager()
.sendTeleportRequest(onlineUser, playerName, TeleportRequest.Type.TPA_HERE)
.thenAccept(sent -> counter.addAndGet(sent.isPresent() ? 1 : 0))));
// Send a message when all requests have been sent
CompletableFuture.allOf(sentRequestsFuture.toArray(new CompletableFuture[0])).thenRun(() -> {
if (counter.get() == 0) {
plugin.getLocales().getLocale("error_no_players_online")
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("tpaall_request_sent", Integer.toString(counter.get()))
.ifPresent(onlineUser::sendMessage);
});
});
plugin.getManager().requests().sendTeleportAllRequest(executor);
plugin.getLocales().getLocale("teleporting_all_players")
.ifPresent(executor::sendMessage);
}
}
@@ -1,60 +0,0 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class TpaCommand extends Command implements TabProvider {
protected TpaCommand(@NotNull HuskHomes implementor) {
super("tpa", Permission.COMMAND_TPA, implementor);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
.ifPresent(onlineUser::sendMessage);
return;
}
if (args.length == 1) {
plugin.getRequestManager()
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.Type.TPA)
.thenAccept(sent -> {
if (sent.isEmpty()) {
if (args[0].equalsIgnoreCase(onlineUser.getUsername())) {
plugin.getLocales().getLocale("error_teleport_request_self")
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("error_player_not_found", args[0])
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("tpa_request_sent", sent.get().getRecipientName())
.ifPresent(onlineUser::sendMessage);
});
} else {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpa <player>")
.ifPresent(onlineUser::sendMessage);
}
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? plugin.getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
}
@@ -1,60 +0,0 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.util.Permission;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class TpaHereCommand extends Command implements TabProvider {
protected TpaHereCommand(@NotNull HuskHomes implementor) {
super("tpahere", Permission.COMMAND_TPAHERE, implementor);
}
@Override
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
if (plugin.getRequestManager().isIgnoringRequests(onlineUser)) {
plugin.getLocales().getLocale("error_ignoring_teleport_requests")
.ifPresent(onlineUser::sendMessage);
return;
}
if (args.length == 1) {
plugin.getRequestManager()
.sendTeleportRequest(onlineUser, args[0], TeleportRequest.Type.TPA_HERE)
.thenAccept(sent -> {
if (sent.isEmpty()) {
if (args[0].equalsIgnoreCase(onlineUser.getUsername())) {
plugin.getLocales().getLocale("error_teleport_request_self")
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("error_player_not_found", args[0])
.ifPresent(onlineUser::sendMessage);
return;
}
plugin.getLocales().getLocale("tpahere_request_sent", sent.get().getRecipientName())
.ifPresent(onlineUser::sendMessage);
});
} else {
plugin.getLocales().getLocale("error_invalid_syntax", "/tpahere <player>")
.ifPresent(onlineUser::sendMessage);
}
}
@Override
@NotNull
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? plugin.getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
}
@@ -0,0 +1,25 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.user.CommandUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public interface UserListTabProvider extends TabProvider {
@Override
@Nullable
default List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return args.length <= 1 ? getPlugin().getCache().getPlayers().stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()) : Collections.emptyList();
}
@NotNull
HuskHomes getPlugin();
}
@@ -115,6 +115,26 @@ public class RequestsManager {
.findFirst());
}
public void sendTeleportAllRequest(@NotNull OnlineUser requester) {
final long expiry = Instant.now().getEpochSecond() + plugin.getSettings().getTeleportRequestExpiryTime();
final TeleportRequest request = new TeleportRequest(requester, TeleportRequest.Type.TPA_HERE, expiry);
for (OnlineUser onlineUser : plugin.getOnlineUsers()) {
if (onlineUser.equals(requester)) {
continue;
}
request.setRecipientName(onlineUser.getUsername());
sendLocalTeleportRequest(request, onlineUser);
}
if (plugin.getSettings().isCrossServer()) {
Message.builder()
.type(Message.Type.TELEPORT_REQUEST)
.payload(Payload.withTeleportRequest(request))
.target(Message.TARGET_ALL)
.build().send(plugin.getMessenger(), requester);
}
}
/**
* Sends a teleport request of the given type to the specified user, by name, if they exist.
*
@@ -122,7 +142,8 @@ public class RequestsManager {
* @param targetUser The user to send the request to
* @param type The type of request to send
*/
public void sendTeleportRequest(@NotNull OnlineUser requester, @NotNull String targetUser, @NotNull TeleportRequest.Type type) throws IllegalArgumentException {
public void sendTeleportRequest(@NotNull OnlineUser requester, @NotNull String targetUser,
@NotNull TeleportRequest.Type type) throws IllegalArgumentException {
final long expiry = Instant.now().getEpochSecond() + plugin.getSettings().getTeleportRequestExpiryTime();
final TeleportRequest request = new TeleportRequest(requester, type, expiry);
final Optional<OnlineUser> localTarget = plugin.findOnlinePlayer(targetUser);
@@ -130,7 +151,6 @@ public class RequestsManager {
if (localTarget.get().equals(requester)) {
throw new IllegalArgumentException("Cannot send a teleport request to yourself");
}
request.setRecipientName(localTarget.get().getUsername());
sendLocalTeleportRequest(request, localTarget.get());
return;
}
@@ -156,6 +176,8 @@ public class RequestsManager {
* sent because the recipient is ignoring requests or is vanished ({@link OnlineUser#isVanished()})
*/
public void sendLocalTeleportRequest(@NotNull TeleportRequest request, @NotNull OnlineUser recipient) {
request.setRecipientName(recipient.getUsername());
// Silently ignore the request if the recipient is ignoring requests or is vanished
if (isIgnoringRequests(recipient) || recipient.isVanished()) {
request.setStatus(TeleportRequest.Status.IGNORED);
@@ -12,6 +12,11 @@ import java.util.UUID;
*/
public class Message {
/**
* Message target indicating all players
*/
public static final String TARGET_ALL = "ALL";
@Expose
private UUID id;
@Expose
@@ -8,8 +8,6 @@ import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
@@ -11,7 +11,7 @@ import redis.clients.jedis.JedisPubSub;
import java.util.logging.Level;
/**
* Redis message broker implementation
* Redis PubSub broker implementation
*/
public class RedisBroker extends PluginMessageBroker {
private JedisPool jedisPool;
@@ -50,9 +50,9 @@ public class RedisBroker extends PluginMessageBroker {
final Message message = plugin.getGson().fromJson(encodedMessage, Message.class);
plugin.getOnlineUsers().stream()
.filter(online -> online.getUsername().equalsIgnoreCase(message.getTarget()))
.findFirst()
.ifPresent(receiver -> handle(receiver, message));
.filter(online -> message.getTarget().equals(Message.TARGET_ALL)
|| online.getUsername().equals(message.getTarget()))
.forEach(receiver -> handle(receiver, message));
}
}, getSubChannelId());
}
@@ -79,7 +79,8 @@ public class Teleport {
// Teleport a local user
final OnlineUser teleporter = localTeleporter.get();
if (target instanceof Username username) {
final Optional<OnlineUser> localTarget = username.findLocally(plugin);
final Optional<OnlineUser> localTarget = username.name().equals("@s")
? Optional.of(executor) : username.findLocally(plugin);
if (localTarget.isPresent()) {
fireEvent((event) -> {
executeEconomyActions();
@@ -37,6 +37,9 @@ public class TeleportBuilder {
}
private void validateTeleport() throws IllegalStateException {
if (teleporter == null) {
throw new IllegalStateException("Teleporter must be set");
}
if (executor == null) {
if (teleporter instanceof OnlineUser onlineUser) {
executor = onlineUser;
@@ -44,9 +47,6 @@ public class TeleportBuilder {
throw new IllegalStateException("Executor must be set if teleporter is not an OnlineUser");
}
}
if (teleporter == null) {
throw new IllegalStateException("Teleporter must be set");
}
if (target == null) {
throw new IllegalStateException("Target must be set");
}
+1 -1
View File
@@ -8,7 +8,7 @@ teleporting_action_bar_processing: '[Teleporting…](#00fb9a)'
teleporting_action_bar_cancelled: '[Телепортацията отказана!](#ff7e5e)'
teleporting_other_complete: '[Teleported %1% to %2%.](#00fb9a)'
teleporting_other_complete_position: '[Teleported %1% to ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Teleporting](#00fb9a) [%1%](#00fb9a bold) [player(s) to your position…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Finding a safe random position to teleport you to…](#00fb9a)'
tpa_request_sent: '[You sent a teleport request asking to teleport to](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [to teleport to you.](#00fb9a)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teleportiere…](#00fb9a)'
teleporting_action_bar_cancelled: '[Teleportation abgebrochen!](#ff7e5e)'
teleporting_other_complete: '[%1% wurde zu %2% teleportiert.](#00fb9a)'
teleporting_other_complete_position: '[%1% wurde zu ⚐ x: %2%, y: %3%, z: %4% teleportiert.](#00fb9a)'
teleporting_all_players: '[Teleportiere](#00fb9a) [%1%](#00fb9a bold) [Spieler zu deiner Position…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Eine zufällige sichere Position um dich zu teleportieren, wird gesucht…](#00fb9a)'
tpa_request_sent: '[Du hast](#00fb9a) [%1%](#00fb9a bold) [eine Teleportanfrage gesendet.](#00fb9a)'
tpahere_request_sent: '[Du hast eine Teleportanfrage gestellt und](#00fb9a) [%1%](#00fb9a bold) [gebeten sich zu dir zu teleportieren.](#00fb9a)'
tpaall_request_sent: '[Du hast eine Teleportanfrage gestellt und](#00fb9a) [%1%](#00fb9a bold) [Spieler gebeten sich zu dir zu teleportieren.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [hat darum gebeten, sich zu dir zu teleportieren.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [hat darum gebeten, dass du dich zu ihm teleportierst.](#00fb9a)'
teleport_request_buttons: '[Optionen:](gray) [[✔ Akzeptieren…]](#00fb9a show_text=&#00fb9a&Teleportanfrage akzeptieren\n&8Klicke, um die Teleportanfrage von %1% zu akzeptieren run_command=/huskhomes:tpaccept %1%) [[❌ Ablehnen…]](#ff3300 show_text=&#ff3300&Teleportanfrage ablehnen\n&8Klicke, um die Teleportanfrage von %1% abzulehnen run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teleporting…](#00fb9a)'
teleporting_action_bar_cancelled: '[Teleportation cancelled!](#ff7e5e)'
teleporting_other_complete: '[Teleported %1% to %2%.](#00fb9a)'
teleporting_other_complete_position: '[Teleported %1% to ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Teleporting](#00fb9a) [%1%](#00fb9a bold) [player(s) to your position…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Finding a safe random position to teleport you to…](#00fb9a)'
tpa_request_sent: '[You sent a teleport request asking to teleport to](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [player(s) to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [has requested to teleport to you.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [has requested that you teleport to them.](#00fb9a)'
teleport_request_buttons: '[Options:](gray) [[✔ Accept…]](#00fb9a show_text=&#00fb9a&Accept teleport request\n&8Click to accept %1%''s request run_command=/huskhomes:tpaccept %1%) [[❌ Decline…]](#ff3300 show_text=&#ff3300&Decline teleport request\n&8Click to decline %1%''s request run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teletransportando...](#00fb9a)'
teleporting_action_bar_cancelled: '[¡Teleportación cancelada!](#ff7e5e)'
teleporting_other_complete: '[Teletransportado %1% a %2%.](#00fb9a)'
teleporting_other_complete_position: '[Teletransportado %1% a ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Teletransportando a ](#00fb9a) [%1%](#00fb9a bold) [jugador(es) a su posición...](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Finding a safe random position to teleport you to…](#00fb9a)'
tpa_request_sent: '[Has enviado una solicitud de teletransporte a](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[Has enviado una solicitud de teletransporte pidiendo a](#00fb9a) [%1%](#00fb9a bold) [que se teletransporte hacia ti.](#00fb9a)'
tpaall_request_sent: '[Has enviado una solicitud de teletransporte a](#00fb9a) [%1%](#00fb9a bold) [jugador(es) para teletransportarse hacia ti.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [ha solicitado teletransportarse hacia ti.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [ha solicitado que te teletransportes a ellos.](#00fb9a)'
teleport_request_buttons: '[Opciones:](gray) [[✔ Aceptar…]](#00fb9a show_text=&#00fb9a&Aceptar solicitud de teletransporte\n&8Clic para aceptar la solicitud de %1%. run_command=/huskhomes:tpaccept %1%) [[❌ Rechazar…]](#ff3300 show_text=&#ff3300&Decline teleport request\n&8Clic para rechazar la solicitud de %1%. run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teletrasporto in corso...](#00fb9a)'
teleporting_action_bar_cancelled: '[Teletrasporto cancellato!](#ff7e5e)'
teleporting_other_complete: '[Hai teletrasportato %1% da %2%.](#00fb9a)'
teleporting_other_complete_position: '[Hai telerasportato %1% a ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Stai teletrasportando](#00fb9a) [%1%](#00fb9a bold) [giocatore(i) nella tua posizione…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Ricerca di un punto di teletrasporto sicuro…](#00fb9a)'
tpa_request_sent: '[Hai richiesto di teletrasportarti da](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[Hai richiesto il teletrasporto a](#00fb9a) [%1%](#00fb9a bold) [ verso la tua posizione.](#00fb9a)'
tpaall_request_sent: '[Hai chiesto a](#00fb9a) [%1%](#00fb9a bold) [ giocatore(i) di teletrasportarsi da te.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [ha richiesto di teletrasportarsi da te.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [ha richiesto di teletrasportarti da lui.](#00fb9a)'
teleport_request_buttons: '[Opzioni:](gray) [[✔ Accetta…]](#00fb9a show_text=&#00fb9a&Accetta la richiesta di teletrasporto\n&8Clicca per accettare la richiesta di %1% run_command=/huskhomes:tpaccept %1%) [[❌ Decline…]](#ff3300 show_text=&#ff3300&Decline teleport request\n&8Click to decline %1%''s request run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teleporting…](#00fb9a)'
teleporting_action_bar_cancelled: '[Teleportacja anulowana!](#ff7e5e)'
teleporting_other_complete: '[Teleported %1% to %2%.](#00fb9a)'
teleporting_other_complete_position: '[Teleported %1% to ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Teleporting](#00fb9a) [%1%](#00fb9a bold) [player(s) to your position…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Finding a safe random position to teleport you to…](#00fb9a)'
tpa_request_sent: '[You sent a teleport request asking to teleport to](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [player(s) to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [has requested to teleport to you.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [has requested that you teleport to them.](#00fb9a)'
teleport_request_buttons: '[Options:](gray) [[✔ Accept…]](#00fb9a show_text=&#00fb9a&Accept teleport request\n&8Click to accept %1%''s request run_command=/huskhomes:tpaccept %1%) [[❌ Decline…]](#ff3300 show_text=&#ff3300&Decline teleport request\n&8Click to decline %1%''s request run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Işınlanılıyor…](#00fb9a)'
teleporting_action_bar_cancelled: '[Işınlanma iptal edildi!](#ff7e5e)'
teleporting_other_complete: '[%1% den %2% ye ışınlanıldı.](#00fb9a)'
teleporting_other_complete_position: '[%1% ⚐ konumuna ışınlandı x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[%1%](#00fb9a bold) [oyuncu(lar) konumunuza ışınlanıyor……](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Sizi ışınlamak için güvenli bir rasgele konum aranıyor…](#00fb9a)'
tpa_request_sent: '[%1%](#00fb9a bold) [hedefine ışınlanmak için bir ışınlanma isteği gönderdiniz.](#00fb9a)'
tpahere_request_sent: '[%1%](#00fb9a bold) [adlı oyuncunun size ışınlanmasını isteyen bir ışınlanma isteği gönderdiniz.](#00fb9a)'
tpaall_request_sent: '[%1%](#00fb9a bold) [oyuncunun size ışınlanmasını isteyen bir ışınlanma isteği gönderdiniz.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [size ışınlanmak istiyor.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold)[, ona ışınlanmanızı istiyor.](#00fb9a)'
teleport_request_buttons: '[Seçenekler:](gray) [[✔ Kabul et…]](#00fb9a show_text=&#00fb9a&Işınlanma isteğini kabul et\n&8%1% adlı oyuncunun isteğini kabul etmek için tıklayın run_command=/huskhomes:tpaccept %1%) [[❌ Reddet…]](#ff3300 show_text=&#ff3300&Işınlanmayı reddet request\n&8%1% adlı oyuncunun isteğini reddetmek için tıklayın run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[Teleporting…](#00fb9a)'
teleporting_action_bar_cancelled: '[Телепортацію скасовано!](#ff7e5e)'
teleporting_other_complete: '[Teleported %1% to %2%.](#00fb9a)'
teleporting_other_complete_position: '[Teleported %1% to ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[Teleporting](#00fb9a) [%1%](#00fb9a bold) [player(s) to your position…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[Finding a safe random position to teleport you to…](#00fb9a)'
tpa_request_sent: '[You sent a teleport request asking to teleport to](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request asking](#00fb9a) [%1%](#00fb9a bold) [player(s) to teleport to you.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [has requested to teleport to you.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [has requested that you teleport to them.](#00fb9a)'
teleport_request_buttons: '[Options:](gray) [[✔ Accept…]](#00fb9a show_text=&#00fb9a&Accept teleport request\n&8Click to accept %1%''s request run_command=/huskhomes:tpaccept %1%) [[❌ Decline…]](#ff3300 show_text=&#ff3300&Decline teleport request\n&8Click to decline %1%''s request run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[传送……](#00fb9a)'
teleporting_action_bar_cancelled: '[传送取消!](#ff7e5e)'
teleporting_other_complete: '[将 %1% 传送到 %2%.](#00fb9a)'
teleporting_other_complete_position: '[将 %1% 传送到 ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[将](#00fb9a) [%1%](#00fb9a bold) [名玩家传送到您的位置…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[正在寻找一个安全的随机位置传送您…](#00fb9a)'
tpa_request_sent: '[已发送传送请求, 传送到](#00fb9a) [%1%](#00fb9a bold)[.](#00fb9a)'
tpahere_request_sent: '[已发送传送请求, 请求](#00fb9a) [%1%](#00fb9a bold) [传送过来.](#00fb9a)'
tpaall_request_sent: '[已发送传送请求, 请求](#00fb9a) [%1%](#00fb9a bold) [传送过来.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [请求传送过来.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [请求您传送过去.](#00fb9a)'
teleport_request_buttons: '[选项:](gray) [[✔ 接受…]](#00fb9a show_text=&#00fb9a&接受传送请求\n&8点击接受 %1% 的请求 run_command=/huskhomes:tpaccept %1%) [[❌ 拒绝…]](#ff3300 show_text=&#ff3300&拒绝传送请求\n&8点击拒绝 %1% 的请求 run_command=/huskhomes:tpdeny %1%)'
+2 -2
View File
@@ -8,11 +8,11 @@ teleporting_action_bar_processing: '[傳送中……](#00fb9a)'
teleporting_action_bar_cancelled: '[傳送取消!](#ff7e5e)'
teleporting_other_complete: '[將 %1% 傳送到 %2%.](#00fb9a)'
teleporting_other_complete_position: '[將 %1% 傳送到 ⚐ x: %2%, y: %3%, z: %4%.](#00fb9a)'
teleporting_all_players: '[將](#00fb9a) [%1%](#00fb9a bold) [名玩家傳送到您的位置…](#00fb9a)'
teleporting_all_players: '[Teleporting all players to your position…](#00fb9a)'
teleporting_random_generation: '[正在尋找一個安全的隨機位置…](#00fb9a)'
tpa_request_sent: '[您發送了一個傳送請求給](#00fb9a) [%1%](#00fb9a bold)'
tpahere_request_sent: '[您發送了一個傳送請求, 請求](#00fb9a) [%1%](#00fb9a bold) [傳送過來.](#00fb9a)'
tpaall_request_sent: '[你向所有玩家發送了一個傳送請求,要求](#00fb9a) [%1%](#00fb9a bold) [個玩家傳送到你身邊!.](#00fb9a)'
tpaall_request_sent: '[You sent a teleport request to every player asking them to teleport to you.](#00fb9a)'
tpa_request_received: '[%1%](#00fb9a bold) [請求傳送過來.](#00fb9a)'
tpahere_request_received: '[%1%](#00fb9a bold) [請求您傳送過去.](#00fb9a)'
teleport_request_buttons: '[傳送請求:](gray) [[✔ 接受…]](#00fb9a show_text=&#00fb9a&接受傳送請求\n&8點擊接受 %1% 的請求 run_command=/huskhomes:tpaccept %1%) [[❌ 拒絕…]](#ff3300 show_text=&#ff3300&拒絕傳送請求\n&8點擊拒絕 %1% 的請求 run_command=/huskhomes:tpdeny %1%)'