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;
|
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.CommandSource;
|
|
|
|
import dev.plex.command.source.RequiredCommandSource;
|
2020-11-06 01:29:38 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2021-01-03 07:21:15 +00:00
|
|
|
import dev.plex.command.PlexCommand;
|
|
|
|
import dev.plex.rank.enums.Rank;
|
2020-11-02 00:06:08 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
|
|
|
|
|
|
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.IN_GAME)
|
|
|
|
@CommandParameters(description = "Teleport to a world.", usage = "/<command> <world>")
|
|
|
|
public class WorldCMD extends PlexCommand
|
|
|
|
{
|
2020-11-06 01:29:38 +00:00
|
|
|
public WorldCMD()
|
|
|
|
{
|
2020-11-02 00:06:08 +00:00
|
|
|
super("world");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-11-03 00:19:26 +00:00
|
|
|
public void execute(CommandSource 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]);
|
|
|
|
sender.getPlayer().teleport(new Location(world, 0, world.getHighestBlockYAt(0, 0) + 1, 0, 0, 0));
|
|
|
|
send(tl("playerWorldTeleport", world.getName()));
|
2020-11-02 00:06:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-11-03 00:19:26 +00:00
|
|
|
public List<String> onTabComplete(CommandSource sender, String[] args)
|
2020-11-02 00:06:08 +00:00
|
|
|
{
|
|
|
|
List<String> worlds = new ArrayList<>();
|
|
|
|
for (World world : Bukkit.getWorlds())
|
2020-11-06 01:29:38 +00:00
|
|
|
{
|
2020-11-02 00:06:08 +00:00
|
|
|
worlds.add(world.getName());
|
2020-11-06 01:29:38 +00:00
|
|
|
}
|
2020-11-02 00:06:08 +00:00
|
|
|
if (args.length == 1)
|
2020-11-06 01:29:38 +00:00
|
|
|
{
|
2020-11-02 00:06:08 +00:00
|
|
|
return worlds;
|
2020-11-06 01:29:38 +00:00
|
|
|
}
|
2020-11-02 00:06:08 +00:00
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|