diff options
Diffstat (limited to 'src/main/java/cat/freya/khs/command/world/Tp.java')
-rw-r--r-- | src/main/java/cat/freya/khs/command/world/Tp.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/cat/freya/khs/command/world/Tp.java b/src/main/java/cat/freya/khs/command/world/Tp.java new file mode 100644 index 0000000..ff6190a --- /dev/null +++ b/src/main/java/cat/freya/khs/command/world/Tp.java @@ -0,0 +1,48 @@ +package cat.freya.khs.command.world; + +import cat.freya.khs.Main; +import cat.freya.khs.command.util.ICommand; +import cat.freya.khs.configuration.Config; +import cat.freya.khs.configuration.Localization; +import cat.freya.khs.util.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class Tp implements ICommand { + public void execute(Player sender, String[] args) { + Location test = new Location(args[0], 0, 0,0); + if(!test.exists()) { + sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_DOESNT_EXIT")); + return; + } + World world = test.load(); + if(world == null) { + sender.sendMessage(Config.errorPrefix + Localization.message("WORLD_LOAD_FAILED")); + return; + } + Location loc = new Location(world.getName(), world.getSpawnLocation()); + loc.teleport(sender); + } + + public String getLabel() { + return "tp"; + } + + public String getUsage() { + return "<world>"; + } + + public String getDescription() { + return "Teleport to another world"; + } + + public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) { + if(parameter.equals("world")) { + return Main.getInstance().getWorlds(); + } + return null; + } +} |