2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.command.impl;
|
2020-11-02 00:06:08 +00:00
|
|
|
|
|
|
|
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.exception.CommandArgumentException;
|
|
|
|
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;
|
2022-01-27 09:00:50 +00:00
|
|
|
import net.kyori.adventure.text.Component;
|
2020-11-02 00:06:08 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
2022-01-27 09:00:50 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2020-11-02 00:06:08 +00:00
|
|
|
|
2022-01-30 01:31:10 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, permission = "plex.world", source = RequiredCommandSource.IN_GAME)
|
2022-01-27 09:00:50 +00:00
|
|
|
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
2020-11-02 00:06:08 +00:00
|
|
|
public class WorldCMD extends PlexCommand
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
2022-01-27 05:28:30 +00:00
|
|
|
public Component execute(CommandSender sender, String[] args)
|
2020-11-02 00:06:08 +00:00
|
|
|
{
|
2020-11-03 00:19:26 +00:00
|
|
|
if (args.length != 1)
|
2020-11-06 01:29:38 +00:00
|
|
|
{
|
2020-11-03 00:19:26 +00:00
|
|
|
throw new CommandArgumentException();
|
2020-11-06 01:29:38 +00:00
|
|
|
}
|
2020-11-03 00:19:26 +00:00
|
|
|
World world = getNonNullWorld(args[0]);
|
2022-01-27 09:00:50 +00:00
|
|
|
((Player)sender).teleportAsync(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0));
|
|
|
|
return tl("playerWorldTeleport", world.getName());
|
2020-11-02 00:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-01-27 09:00:50 +00:00
|
|
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
2020-11-02 00:06:08 +00:00
|
|
|
{
|
|
|
|
if (args.length == 1)
|
2020-11-06 01:29:38 +00:00
|
|
|
{
|
2022-01-27 09:00:50 +00:00
|
|
|
return Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList());
|
2020-11-06 01:29:38 +00:00
|
|
|
}
|
2020-11-02 00:06:08 +00:00
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|