blob: a2ada0a4f9bd7d38d0db65de6dd58e8a90a47450 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;
}
}
|