summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command/map')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java54
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java47
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java53
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java97
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java112
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java112
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java67
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java97
8 files changed, 639 insertions, 0 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java
new file mode 100644
index 0000000..55b4267
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java
@@ -0,0 +1,54 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+
+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 AddMap extends Command {
+
+ public void execute(Player sender, String[] args) {
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map != null) {
+ sender.sendMessage(errorPrefix + message("MAP_ALREADY_EXISTS"));
+ } else if(!args[0].matches("[a-zA-Z0-9]*") || args[0].length() < 1) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP_NAME"));
+ } else {
+ Maps.setMap(args[0], new Map(args[0]));
+ sender.sendMessage(messagePrefix + message("MAP_CREATED").addAmount(args[0]));
+ }
+ }
+
+ public String getLabel() {
+ return "add";
+ }
+
+ public String getUsage() {
+ return "<name>";
+ }
+
+ public String getDescription() {
+ return "Add a map to the plugin!";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("name")) {
+ return Collections.singletonList("name");
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java
new file mode 100644
index 0000000..79490a7
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java
@@ -0,0 +1,47 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+import java.util.Collection;
+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 ListMaps extends Command {
+
+ public void execute(Player sender, String[] args) {
+ Collection<Map> maps = Maps.getAllMaps();
+ if(maps.size() < 1) {
+ sender.sendMessage(errorPrefix + message("NO_MAPS"));
+ return;
+ }
+ StringBuilder response = new StringBuilder(messagePrefix + message("LIST_MAPS"));
+ for(Map map : maps) {
+ response.append("\n ").append(map.getName()).append(": ").append(map.isNotSetup() ? ChatColor.RED + "NOT SETUP" : ChatColor.GREEN + "SETUP").append(ChatColor.WHITE);
+ }
+ sender.sendMessage(response.toString());
+ }
+
+ public String getLabel() {
+ return "list";
+ }
+
+ public String getUsage() {
+ return "";
+ }
+
+ public String getDescription() {
+ return "List all maps in the plugin";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java
new file mode 100644
index 0000000..216cca9
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java
@@ -0,0 +1,53 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+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 RemoveMap extends Command {
+
+ public void execute(Player sender, String[] args) {
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ } else if(!Maps.removeMap(args[0])){
+ sender.sendMessage(errorPrefix + message("MAP_FAIL_DELETE").addAmount(args[0]));
+ } else {
+ sender.sendMessage(messagePrefix + message("MAP_DELETED").addAmount(args[0]));
+ }
+ }
+
+ public String getLabel() {
+ return "remove";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Remove a map from the plugin!";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java
new file mode 100644
index 0000000..f3eb4d7
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java
@@ -0,0 +1,97 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitRunnable;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class SaveMap extends Command {
+
+ public static boolean runningBackup = false;
+
+ public void execute(Player sender, String[] args) {
+ if (!mapSaveEnabled) {
+ sender.sendMessage(errorPrefix + message("MAPSAVE_DISABLED"));
+ return;
+ }
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
+ return;
+ }
+ sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
+ sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
+ World world = map.getSpawn().getWorld();
+ if (world == null) {
+ throw new RuntimeException("Unable to get spawn world");
+ }
+ world.save();
+ BukkitRunnable runnable = new BukkitRunnable() {
+ public void run() {
+ sender.sendMessage(
+ map.getWorldLoader().save()
+ );
+ runningBackup = false;
+ }
+ };
+ runnable.runTaskAsynchronously(Main.getInstance());
+ runningBackup = true;
+ }
+
+ public String getLabel() {
+ return "save";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Saves current map for the game. May lag server.";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java
new file mode 100644
index 0000000..8362e02
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java
@@ -0,0 +1,112 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class SetBorder extends Command {
+
+ public void execute(Player sender, String[] args) {
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
+ return;
+ }
+ if (args.length < 4) {
+ map.setWorldBorderData(0, 0, 0, 0, 0);
+ addToConfig("worldBorder.enabled",false);
+ saveConfig();
+ sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
+ Main.getInstance().getGame().getCurrentMap().getWorldBorder().resetWorldBorder();
+ return;
+ }
+ int num,delay,change;
+ try { num = Integer.parseInt(args[1]); } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
+ return;
+ }
+ try { delay = Integer.parseInt(args[2]); } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1]));
+ return;
+ }
+ try { change = Integer.parseInt(args[3]); } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2]));
+ return;
+ }
+ if (num < 100) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_MIN_SIZE"));
+ return;
+ }
+ if (change < 1) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_CHANGE_SIZE"));
+ return;
+ }
+ map.setWorldBorderData(
+ sender.getLocation().getBlockX(),
+ sender.getLocation().getBlockZ(),
+ num,
+ delay,
+ change
+ );
+ Maps.setMap(map.getName(), map);
+ sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
+ map.getWorldBorder().resetWorldBorder();
+ }
+
+ public String getLabel() {
+ return "border";
+ }
+
+ public String getUsage() {
+ return "<map> <*size> <*delay> <*move>";
+ }
+
+ public String getDescription() {
+ return "Sets worldboarder's center location, size in blocks, and delay in minutes per shrink. Add no arguments to disable.";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return Collections.singletonList(parameter);
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java
new file mode 100644
index 0000000..92bf5a4
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java
@@ -0,0 +1,112 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class SetBounds extends Command {
+
+ public void execute(Player sender, String[] args) {
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.isSpawnNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
+ return;
+ }
+ if (!sender.getWorld().getName().equals(map.getSpawnName())) {
+ sender.sendMessage(errorPrefix + message("BOUNDS_WRONG_WORLD"));
+ return;
+ }
+ if (sender.getLocation().getBlockX() == 0 || sender.getLocation().getBlockZ() == 0) {
+ sender.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
+ return;
+ }
+ boolean first = true;
+ int bxs = map.getBoundsMin().getBlockX();
+ int bzs = map.getBoundsMin().getBlockZ();
+ int bxl = map.getBoundsMax().getBlockX();
+ int bzl = map.getBoundsMax().getBlockZ();
+ if (bxs != 0 && bzs != 0 && bxl != 0 && bzl != 0) {
+ bxs = bzs = bxl = bzl = 0;
+ }
+ if (bxl == 0) {
+ bxl = sender.getLocation().getBlockX();
+ } else if (map.getBoundsMax().getX() < sender.getLocation().getBlockX()) {
+ first = false;
+ bxs = bxl;
+ bxl = sender.getLocation().getBlockX();
+ } else {
+ first = false;
+ bxs = sender.getLocation().getBlockX();
+ }
+ if (bzl == 0) {
+ bzl = sender.getLocation().getBlockZ();
+ } else if (map.getBoundsMax().getZ() < sender.getLocation().getBlockZ()) {
+ first = false;
+ bzs = bzl;
+ bzl = sender.getLocation().getBlockZ();
+ } else {
+ first = false;
+ bzs = sender.getLocation().getBlockZ();
+ }
+ map.setBoundMin(bxs, bzs);
+ map.setBoundMax(bxl, bzl);
+ Maps.setMap(map.getName(), map);
+ sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
+ }
+
+ public String getLabel() {
+ return "bounds";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Sets the map bounds for the game.";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java
new file mode 100644
index 0000000..2df5824
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java
@@ -0,0 +1,67 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class SetMap extends Command {
+
+ public void execute(Player sender, String[] args) {
+
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+
+ if(map.isNotSetup()){
+ sender.sendMessage(errorPrefix + message("MAP_NOT_SETUP"));
+ return;
+ }
+
+ if (!Main.getInstance().getBoard().contains(sender)) {
+ sender.sendMessage(errorPrefix + message("GAME_NOT_INGAME"));
+ return;
+ }
+
+ Main.getInstance().getGame().setCurrentMap(map);
+ for(Player player : Main.getInstance().getBoard().getPlayers()) {
+ player.teleport(map.getLobby());
+ }
+
+ }
+
+ public String getLabel() {
+ return "goto";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Set the current lobby to another map";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java
new file mode 100644
index 0000000..46b41f7
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java
@@ -0,0 +1,97 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class Setup extends Command {
+
+ public void execute(Player sender, String[] args) {
+
+ String msg = message("SETUP").toString();
+ int count = 0;
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
+ msg = msg + "\n" + message("SETUP_GAME");
+ count++;
+ }
+ if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
+ msg = msg + "\n" + message("SETUP_LOBBY");
+ count++;
+ }
+ if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !Map.worldExists(map.getSeekerLobbyName())) {
+ msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
+ count++;
+ }
+ if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld)) {
+ msg = msg + "\n" + message("SETUP_EXIT");
+ count++;
+ }
+ if (map.getBoundsMin().getBlockX() == 0 || map.getBoundsMin().getBlockZ() == 0 ||
+ map.getBoundsMax().getBlockX() == 0 || map.getBoundsMax().getBlockX() == 0) {
+ msg = msg + "\n" + message("SETUP_BOUNDS");
+ count++;
+ }
+ if (mapSaveEnabled && !Map.worldExists(map.getGameSpawnName())) {
+ msg = msg + "\n" + message("SETUP_SAVEMAP");
+ count++;
+ }
+ if (count < 1) {
+ sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
+ } else {
+ sender.sendMessage(msg);
+ }
+ }
+
+ public String getLabel() {
+ return "setup";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Shows what needs to be setup";
+ }
+
+ public List<String> autoComplete(String parameter) {
+ if(parameter != null && parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
+} \ No newline at end of file