Plex/src/main/java/dev/plex/command/impl/WorldCMD.java

46 lines
1.7 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.command.impl;
import com.google.common.collect.ImmutableList;
2022-01-04 03:04:39 +00:00
import dev.plex.command.PlexCommand;
2021-01-03 07:21:15 +00:00
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.rank.enums.Rank;
2022-01-27 21:23:01 +00:00
import java.util.List;
import java.util.stream.Collectors;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandPermissions(level = Rank.OP, permission = "plex.world", source = RequiredCommandSource.IN_GAME)
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
public class WorldCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length != 1)
2020-11-06 01:29:38 +00:00
{
return usage();
2020-11-06 01:29:38 +00:00
}
World world = getNonNullWorld(args[0]);
playerSender.teleportAsync(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0));
2022-02-25 07:09:55 +00:00
return messageComponent("playerWorldTeleport", world.getName());
}
@Override
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
if (args.length == 1)
2020-11-06 01:29:38 +00:00
{
return Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList());
2020-11-06 01:29:38 +00:00
}
return ImmutableList.of();
}
}