summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command/world
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command/world')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java82
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/world/Delete.java76
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/world/List.java57
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/world/Tp.java49
4 files changed, 0 insertions, 264 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java
deleted file mode 100644
index e399993..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.world;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.command.util.ICommand;
-import net.tylermurphy.hideAndSeek.util.Location;
-import org.bukkit.World;
-import org.bukkit.WorldType;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class Create implements ICommand {
-
- public void execute(Player sender, String[] args) {
- List<String> worlds = Main.getInstance().getWorlds();
- if(worlds.contains(args[0])) {
- sender.sendMessage(errorPrefix + message("WORLD_EXISTS").addAmount(args[0]));
- return;
- }
- WorldType type;
- World.Environment environment;
- switch (args[1]) {
- case "normal":
- type = WorldType.NORMAL;
- environment = World.Environment.NORMAL;
- break;
- case "flat":
- type = WorldType.FLAT;
- environment = World.Environment.NORMAL;
- break;
- case "nether":
- type = WorldType.NORMAL;
- environment = World.Environment.NETHER;
- break;
- case "end":
- type = WorldType.NORMAL;
- environment = World.Environment.THE_END;
- break;
- default:
- sender.sendMessage(errorPrefix + message("INVALID_WORLD_TYPE").addAmount(args[1]));
- return;
- }
-
- Location temp = new Location(args[0], 0, 0, 0);
-
- if (temp.load(type, environment) == null) {
- sender.sendMessage(errorPrefix + message("WORLD_ADDED_FAILED"));
- } else {
- sender.sendMessage(messagePrefix + message("WORLD_ADDED").addAmount(args[0]));
- }
-
- }
-
- public String getLabel() {
- return "create";
- }
-
- public String getUsage() {
- return "<name> <type>";
- }
-
- public String getDescription() {
- return "Create a new world";
- }
-
- public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
- if(parameter.equals("name")) {
- return Collections.singletonList("name");
- }
- if(parameter.equals("type")) {
- return Arrays.asList("normal", "flat", "nether", "end");
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Delete.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Delete.java
deleted file mode 100644
index 985ccdc..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Delete.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.world;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.command.Confirm;
-import net.tylermurphy.hideAndSeek.command.util.ICommand;
-import net.tylermurphy.hideAndSeek.world.WorldLoader;
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.File;
-import java.util.List;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class Delete implements ICommand {
-
- public void execute(Player sender, String[] args) {
- java.util.List<String> worlds = Main.getInstance().getWorlds();
- if(!worlds.contains(args[0])) {
- sender.sendMessage(errorPrefix + message("WORLD_DOESNT_EXIST").addAmount(args[0]));
- return;
- }
-
- Confirm.Confirmation confirmation = new Confirm.Confirmation(args[0], world -> {
- java.util.List<String> worlds_now = Main.getInstance().getWorlds();
- if(!worlds_now.contains(world)) {
- sender.sendMessage(errorPrefix + message("WORLD_DOESNT_EXIST").addAmount(world));
- return;
- }
- World bukkit_world = Bukkit.getWorld(world);
- if(bukkit_world != null && bukkit_world.getPlayers().size() > 0) {
- sender.sendMessage(errorPrefix + message("WORLD_NOT_EMPTY"));
- return;
- }
- String path = Main.getInstance().getWorldContainer().getPath() + File.separator + world;
- if (!Bukkit.getServer().unloadWorld(world, false)) {
- sender.sendMessage(errorPrefix + message("WORLD_REMOVED_FAILED"));
- return;
- }
- try {
- WorldLoader.deleteDirectory(new File(path));
- } catch (Exception e) {
- sender.sendMessage(errorPrefix + message("WORLD_REMOVED_FAILED"));
- return;
- }
- sender.sendMessage(messagePrefix + message("WORLD_REMOVED").addAmount(world));
- });
-
- Confirm.confirmations.put(sender.getUniqueId(), confirmation);
- sender.sendMessage(messagePrefix + message("CONFIRMATION"));
-
- }
-
- public String getLabel() {
- return "delete";
- }
-
- public String getUsage() {
- return "<name>";
- }
-
- public String getDescription() {
- return "Delete a world";
- }
-
- public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
- if(parameter.equals("name")) {
- return Main.getInstance().getWorlds();
- }
- return null;
- }
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/List.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/List.java
deleted file mode 100644
index bdb98e5..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/world/List.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.world;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.command.util.ICommand;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class List implements ICommand {
-
- public void execute(Player sender, String[] args) {
- java.util.List<String> worlds = Main.getInstance().getWorlds();
- if(worlds.isEmpty()) {
- sender.sendMessage(errorPrefix + message("NO_WORLDS"));
- } else {
- StringBuilder response = new StringBuilder(messagePrefix + message("LIST_WORLDS"));
- for (String world : worlds) {
- String status = ChatColor.GRAY + "NOT LOADED";
- World bukkit_world = Bukkit.getWorld(world);
- if(bukkit_world != null) {
- if(bukkit_world.getEnvironment() == World.Environment.NETHER) {
- status = ChatColor.RED + "NETHER";
- } else if(bukkit_world.getEnvironment() == World.Environment.THE_END) {
- status = ChatColor.YELLOW + "THE END";
- } else {
- status = ChatColor.GREEN + bukkit_world.getWorldType().toString();
- }
- }
- response.append("\n ").append(world).append(": ").append(status).append(ChatColor.WHITE);
- }
- sender.sendMessage(response.toString());
- }
- }
-
- public String getLabel() {
- return "list";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "List all worlds in the server";
- }
-
- public java.util.List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
- return null;
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Tp.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Tp.java
deleted file mode 100644
index b166297..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Tp.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.world;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.command.util.ICommand;
-import net.tylermurphy.hideAndSeek.util.Location;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-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(errorPrefix + message("WORLD_DOESNT_EXIT"));
- return;
- }
- World world = test.load();
- if(world == null) {
- sender.sendMessage(errorPrefix + 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;
- }
-}