summaryrefslogtreewikicommitdiff
path: root/src/main/java/dev/tylerm/khs/command/world/Tp.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/tylerm/khs/command/world/Tp.java')
-rw-r--r--src/main/java/dev/tylerm/khs/command/world/Tp.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/dev/tylerm/khs/command/world/Tp.java b/src/main/java/dev/tylerm/khs/command/world/Tp.java
new file mode 100644
index 0000000..a2ada0a
--- /dev/null
+++ b/src/main/java/dev/tylerm/khs/command/world/Tp.java
@@ -0,0 +1,48 @@
+package dev.tylerm.khs.command.world;
+
+import dev.tylerm.khs.Main;
+import dev.tylerm.khs.command.util.ICommand;
+import dev.tylerm.khs.configuration.Config;
+import dev.tylerm.khs.configuration.Localization;
+import dev.tylerm.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;
+ }
+}