mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
40 lines
1.3 KiB
Java
40 lines
1.3 KiB
Java
package net.william278.huskhomes.command;
|
|
|
|
import net.william278.huskhomes.HuskHomes;
|
|
import net.william278.huskhomes.player.OnlineUser;
|
|
import net.william278.huskhomes.util.Permission;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class WarpCommand extends CommandBase implements TabCompletable, ConsoleExecutable {
|
|
|
|
public WarpCommand(@NotNull HuskHomes implementor) {
|
|
super("warp", Permission.COMMAND_WARP, implementor);
|
|
}
|
|
|
|
@Override
|
|
public void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
|
if (args.length == 1) {
|
|
final String warpName = args[0];
|
|
plugin.getTeleportManager().teleportToWarp(onlineUser, warpName);
|
|
} else {
|
|
plugin.getLocales().getLocale("error_invalid_syntax", "/warp [name]")
|
|
.ifPresent(onlineUser::sendMessage);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public List<String> onTabComplete(@NotNull OnlineUser onlineUser, @NotNull String[] args) {
|
|
return plugin.getCache().warps.stream()
|
|
.filter(s -> s.startsWith(args.length >= 1 ? args[0] : ""))
|
|
.sorted().collect(Collectors.toList());
|
|
}
|
|
|
|
@Override
|
|
public void onConsoleExecute(@NotNull String[] args) {
|
|
//todo
|
|
}
|
|
}
|