summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/About.java47
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java62
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java110
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Help.java88
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java34
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Join.java49
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java29
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java48
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Send.java69
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java106
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java96
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java43
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java83
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Start.java53
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java31
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Top.java29
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java29
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java53
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java17
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java49
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java50
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java31
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java62
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java59
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java26
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java55
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java123
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java63
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java47
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java54
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java)64
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java79
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java65
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java77
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java60
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java77
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java94
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java113
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java41
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java58
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java69
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java188
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java20
-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
47 files changed, 1991 insertions, 973 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
deleted file mode 100644
index 54af32b..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-public class About implements ICommand {
-
- public void execute(Player sender, String[] args) {
- sender.sendMessage(
- String.format("%s%sHide and Seek %s(%s1.6.2%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY,ChatColor.WHITE,ChatColor.GRAY) +
- String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
- String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
- );
- }
-
- public String getLabel() {
- return "about";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Get information about the plugin";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java
new file mode 100644
index 0000000..a25185d
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Confirm.java
@@ -0,0 +1,62 @@
+package net.tylermurphy.hideAndSeek.command;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.*;
+import java.util.function.Consumer;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class Confirm implements ICommand {
+
+ public static final Map<UUID, Confirmation> confirmations = new HashMap<>();
+
+ public void execute(Player sender, String[] args) {
+ Confirmation confirmation = confirmations.get(sender.getUniqueId());
+ confirmations.remove(sender.getUniqueId());
+ if(confirmation == null) {
+ sender.sendMessage(errorPrefix + message("NO_CONFIRMATION"));
+ } else {
+ long now = System.currentTimeMillis();
+ float secs = (now - confirmation.start) / 1000F;
+ if(secs > 10) {
+ sender.sendMessage(errorPrefix + message("CONFIRMATION_TIMED_OUT"));
+ return;
+ }
+ confirmation.callback.accept(confirmation.data);
+ }
+ }
+
+ public String getLabel() {
+ return "confirm";
+ }
+
+ public String getUsage() {
+ return "";
+ }
+
+ public String getDescription() {
+ return "Confirm another command if required";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
+ public static class Confirmation {
+ public final Consumer<String> callback;
+ public final String data;
+ public final long start;
+
+ public Confirmation(String data, Consumer<String> callback) {
+ this.callback = callback;
+ this.data = data;
+ this.start = System.currentTimeMillis();
+ }
+
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
deleted file mode 100644
index 61d0c46..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package net.tylermurphy.hideAndSeek.command;
-
-import com.cryptomorin.xseries.XMaterial;
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.game.PlayerLoader;
-import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Consumer;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Config.exitPosition;
-
-public class Debug implements ICommand {
-
- private static final Map<Integer, Consumer<Player>> debugMenuFunctions = new HashMap<>();
- private Inventory debugMenu;
-
- public void execute(Player sender, String[] args) {
- if(debugMenu == null) createMenu();
- sender.openInventory(debugMenu);
- }
-
- private void createMenu(){
- debugMenu = Main.getInstance().getServer().createInventory(null, 18, "Debug Menu");
- debugMenu.setItem(0, createOption(0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- Main.getInstance().getBoard().addHider(player);
- PlayerLoader.loadHider(player, Main.getInstance().getGame().getGameWorld());
- if(Main.getInstance().getGame().getStatus() != Status.STARTING)
- PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
- }));
- debugMenu.setItem(1, createOption(1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- Main.getInstance().getBoard().addSeeker(player);
- PlayerLoader.loadSeeker(player, Main.getInstance().getGame().getGameWorld());
- if(Main.getInstance().getGame().getStatus() != Status.STARTING)
- PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
- }));
- debugMenu.setItem(2, createOption(2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- Main.getInstance().getBoard().addSpectator(player);
- PlayerLoader.loadSpectator(player, Main.getInstance().getGame().getGameWorld());
- }));
- debugMenu.setItem(3, createOption(3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
- Main.getInstance().getBoard().remove(player);
- PlayerLoader.unloadPlayer(player);
- player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()));
- }));
- debugMenu.setItem(4, createOption(4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
- if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
- player.setHealth(0.1);
- }
- }));
- debugMenu.setItem(6, createOption(6, Material.ENDER_PEARL, "&d&lTeleport: &fGame spawn", 1, player -> {
- if(mapSaveEnabled) {
- if(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()) == null) Main.getInstance().getGame().getWorldLoader().loadMap();
- }
- player.teleport(new Location(Bukkit.getWorld(Main.getInstance().getGame().getGameWorld()), spawnPosition.getX(), spawnPosition.getY(), spawnPosition.getZ()));
- }));
- debugMenu.setItem(7, createOption(7, Material.ENDER_PEARL, "&d&lTeleport: &fLobby", 2, player -> player.teleport(new Location(Bukkit.getWorld(lobbyWorld), lobbyPosition.getX(), lobbyPosition.getY(), lobbyPosition.getZ()))));
- debugMenu.setItem(8, createOption(8, Material.ENDER_PEARL, "&d&lTeleport: &fExit", 3, player -> player.teleport(new Location(Bukkit.getWorld(exitWorld), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ()))));
- debugMenu.setItem(9, createOption(9, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, PlayerLoader::openBlockHuntPicker));
- debugMenu.setItem(10, createOption(10, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
- }
-
- private ItemStack createOption(int slow, Material material, String name, int amount, Consumer<Player> callback){
- ItemStack temp = new ItemStack(material, amount);
- ItemMeta meta = temp.getItemMeta();
- meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
- temp.setItemMeta(meta);
- debugMenuFunctions.put(slow, callback);
- return temp;
- }
-
- public static void handleOption(Player player, int slotId){
- Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
- Consumer<Player> callback = debugMenuFunctions.get(slotId);
- if(callback != null) callback.accept(player);
- }, 0);
- }
-
- public String getLabel() {
- return "debug";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Run debug commands";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
index 97224d7..41db5a9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
@@ -1,36 +1,70 @@
-/*
- * 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;
-import net.md_5.bungee.api.ChatColor;
-import net.tylermurphy.hideAndSeek.util.CommandHandler;
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.util.Pair;
+import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collections;
+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 Help implements ICommand {
public void execute(Player sender, String[] args) {
+ final int pageSize = 4;
+ List<Pair<String, ICommand>> commands = Main.getInstance().getCommandGroup().getCommands();
+ int pages = (commands.size() - 1) / pageSize + 1;
+ int page;
+ try {
+ if(args.length < 1) {
+ page = 1;
+ } else {
+ page = Integer.parseInt(args[0]);
+ if (page < 1) {
+ throw new IllegalArgumentException("Inavlid Input");
+ }
+ }
+ } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
+ return;
+ }
+ String spacer = ChatColor.GRAY + "?" + ChatColor.WHITE;
StringBuilder message = new StringBuilder();
- for(ICommand command : CommandHandler.COMMAND_REGISTER.values()) {
- message.append(String.format("%s/hs %s%s %s%s\n %s%s%s", ChatColor.AQUA, ChatColor.WHITE, command.getLabel().toLowerCase(), ChatColor.BLUE, command.getUsage(), ChatColor.GRAY, ChatColor.ITALIC, command.getDescription() + "\n"));
+ message.append(String.format("%s================ %sHelp: Page (%s/%s) %s================",
+ ChatColor.AQUA, ChatColor.WHITE, page, pages, ChatColor.AQUA));
+ int lines = 0;
+ for(Pair<String, ICommand> pair : commands.stream().skip((long) (page - 1) * pageSize).limit(pageSize).collect(Collectors.toList())) {
+ ICommand command = pair.getRight();
+ String label = pair.getLeft();
+ String start = label.substring(0, label.indexOf(" "));
+ String invoke = label.substring(label.indexOf(" ")+1);
+ message.append(String.format("\n%s %s/%s %s%s %s%s\n%s %s%s%s",
+ spacer,
+ ChatColor.AQUA,
+ start,
+ ChatColor.WHITE,
+ invoke,
+ ChatColor.BLUE,
+ command.getUsage(),
+ spacer,
+ ChatColor.GRAY,
+ ChatColor.ITALIC,
+ command.getDescription()
+ ));
+ lines += 2;
}
- message = new StringBuilder(message.substring(0, message.length() - 1));
+ if(lines / 2 < pageSize) {
+ for(int i = 0; i < pageSize * 2 - lines; i++) {
+ message.append("\n").append(spacer);
+ }
+ }
+ message.append("\n").append(ChatColor.AQUA).append("===============================================");
sender.sendMessage(message.toString());
}
@@ -39,11 +73,15 @@ public class Help implements ICommand {
}
public String getUsage() {
- return "";
+ return "<*page>";
}
public String getDescription() {
return "Get the commands for the plugin";
}
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return Collections.singletonList(parameter);
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java b/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java
deleted file mode 100644
index 275d189..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import org.bukkit.entity.Player;
-
-public interface ICommand {
-
- void execute(Player sender, String[] args);
-
- String getLabel();
-
- String getUsage();
-
- String getDescription();
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
index 941cec0..0c01265 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
@@ -1,27 +1,14 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+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;
@@ -29,7 +16,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Join implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@@ -42,7 +29,18 @@ public class Join implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INGAME"));
return;
}
-
+ if(args.length > 0) {
+ if(Main.getInstance().getBoard().size() > 0) {
+ sender.sendMessage(errorPrefix + message("LOBBY_IN_USE"));
+ return;
+ }
+ net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ Main.getInstance().getGame().setCurrentMap(map);
+ }
Main.getInstance().getGame().join(player);
}
@@ -51,11 +49,18 @@ public class Join implements ICommand {
}
public String getUsage() {
- return "";
+ return "<*map>";
}
public String getDescription() {
return "Joins the lobby if game is set to manual join/leave";
}
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
index 092ff50..109930b 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
@@ -1,27 +1,12 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import org.bukkit.Bukkit;
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;
@@ -29,7 +14,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Leave implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@@ -57,4 +42,8 @@ public class Leave implements ICommand {
return "Leaves the lobby if game is set to manual join/leave";
}
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
index 56f4517..0c2b6b1 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
@@ -1,30 +1,13 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.configuration.Config;
-import net.tylermurphy.hideAndSeek.configuration.Items;
-import net.tylermurphy.hideAndSeek.configuration.Localization;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.*;
import net.tylermurphy.hideAndSeek.game.util.Status;
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.Config.messagePrefix;
@@ -38,9 +21,18 @@ public class Reload implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- Config.loadConfig();
- Localization.loadLocalization();
- Items.loadItems();
+
+ try {
+ Config.loadConfig();
+ Maps.loadMaps();
+ Localization.loadLocalization();
+ Items.loadItems();
+ Leaderboard.loadLeaderboard();
+ } catch (Exception e) {
+ sender.sendMessage(errorPrefix + message("CONFIG_ERROR"));
+ return;
+ }
+
sender.sendMessage(messagePrefix + message("CONFIG_RELOAD"));
}
@@ -55,5 +47,9 @@ public class Reload implements ICommand {
public String getDescription() {
return "Reloads the config";
}
-
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java
new file mode 100644
index 0000000..43620c5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Send.java
@@ -0,0 +1,69 @@
+package net.tylermurphy.hideAndSeek.command;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+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 org.jetbrains.annotations.NotNull;
+
+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 Send implements ICommand {
+
+ 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);
+ Main.getInstance().getBoard().reloadLobbyBoards();
+ for(Player player : Main.getInstance().getBoard().getPlayers()) {
+ map.getLobby().teleport(player);
+ }
+
+ }
+
+ public String getLabel() {
+ return "send";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Set the current lobby to another map";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
deleted file mode 100644
index b456e6a..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class SetBorder implements ICommand {
-
- public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
- sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
- return;
- }
- if (spawnPosition == null) {
- sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
- return;
- }
- if (args.length < 3) {
- worldBorderEnabled = false;
- addToConfig("worldBorder.enabled",false);
- saveConfig();
- sender.sendMessage(messagePrefix + message("WORLDBORDER_DISABLE"));
- Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
- return;
- }
- int num,delay,change;
- try { num = Integer.parseInt(args[0]); } catch (Exception e) {
- sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[0]));
- return;
- }
- try { delay = Integer.parseInt(args[1]); } catch (Exception e) {
- sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[1]));
- return;
- }
- try { change = Integer.parseInt(args[2]); } 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;
- }
- Vector vec = new Vector();
- vec.setX(sender.getLocation().getBlockX());
- vec.setY(0);
- vec.setZ(sender.getLocation().getBlockZ());
- if (spawnPosition.distance(vec) > 100) {
- sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
- return;
- }
- worldBorderPosition = vec;
- worldBorderSize = num;
- worldBorderDelay = delay;
- worldBorderChange = change;
- worldBorderEnabled = true;
- addToConfig("worldBorder.x", worldBorderPosition.getBlockX());
- addToConfig("worldBorder.z", worldBorderPosition.getBlockZ());
- addToConfig("worldBorder.delay", worldBorderDelay);
- addToConfig("worldBorder.size", worldBorderSize);
- addToConfig("worldBorder.enabled", true);
- addToConfig("worldBorder.move", worldBorderChange);
- sender.sendMessage(messagePrefix + message("WORLDBORDER_ENABLE").addAmount(num).addAmount(delay));
- saveConfig();
- Main.getInstance().getGame().getBorder().resetWorldBorder(spawnWorld);
- }
-
- public String getLabel() {
- return "setBorder";
- }
-
- public String getUsage() {
- return "<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.";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
deleted file mode 100644
index 434e4a6..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.entity.Player;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class SetBounds implements ICommand {
-
- public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
- sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
- return;
- }
- if (spawnPosition == null) {
- sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
- return;
- }
- if (!sender.getWorld().getName().equals(spawnWorld)) {
- 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;
- if (saveMinX != 0 && saveMinZ != 0 && saveMaxX != 0 && saveMaxZ != 0) {
- saveMinX = 0; saveMinZ= 0; saveMaxX = 0; saveMaxZ = 0;
- }
- if (saveMaxX == 0) {
- addToConfig("bounds.max.x", sender.getLocation().getBlockX());
- saveMaxX = sender.getLocation().getBlockX();
- } else if (saveMaxX < sender.getLocation().getBlockX()) {
- first = false;
- addToConfig("bounds.max.x", sender.getLocation().getBlockX());
- addToConfig("bounds.min.x", saveMaxX);
- saveMinX = saveMaxX;
- saveMaxX = sender.getLocation().getBlockX();
- } else {
- first = false;
- addToConfig("bounds.min.x", sender.getLocation().getBlockX());
- saveMinX = sender.getLocation().getBlockX();
- }
- if (saveMaxZ == 0) {
- addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
- saveMaxZ = sender.getLocation().getBlockZ();
- } else if (saveMaxZ < sender.getLocation().getBlockZ()) {
- first = false;
- addToConfig("bounds.max.z", sender.getLocation().getBlockZ());
- addToConfig("bounds.min.z", saveMaxZ);
- saveMinZ = saveMaxZ;
- saveMaxZ = sender.getLocation().getBlockZ();
- } else {
- first = false;
- addToConfig("bounds.min.z", sender.getLocation().getBlockZ());
- saveMinZ = sender.getLocation().getBlockZ();
- }
- sender.sendMessage(messagePrefix + message("BOUNDS").addAmount(first ? 1 : 2));
- saveConfig();
- }
-
- public String getLabel() {
- return "setBounds";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Sets the map bounds for the game.";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
new file mode 100644
index 0000000..7da404f
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/SetExitLocation.java
@@ -0,0 +1,43 @@
+package net.tylermurphy.hideAndSeek.command;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
+import net.tylermurphy.hideAndSeek.command.location.Locations;
+import net.tylermurphy.hideAndSeek.util.Location;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+
+public class SetExitLocation implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
+ addToConfig("exit.x", sender.getLocation().getBlockX());
+ addToConfig("exit.y", sender.getLocation().getBlockY());
+ addToConfig("exit.z", sender.getLocation().getBlockZ());
+ addToConfig("exit.world", sender.getLocation().getWorld().getName());
+ exitPosition = Location.from(sender);
+ saveConfig();
+ });
+ }
+
+ public String getLabel() {
+ return "setexit";
+ }
+
+ public String getUsage() {
+ return "";
+ }
+
+ public String getDescription() {
+ return "Sets the plugins exit location";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
deleted file mode 100644
index e961188..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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;
-
-import net.tylermurphy.hideAndSeek.Main;
-import org.bukkit.entity.Player;
-
-import java.io.File;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class Setup implements ICommand {
-
- public void execute(Player sender, String[] args) {
-
- String msg = message("SETUP").toString();
- int count = 0;
-
- if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
- msg = msg + "\n" + message("SETUP_GAME");
- count++;
- }
- if (lobbyPosition.getBlockX() == 0 && lobbyPosition.getBlockY() == 0 && lobbyPosition.getBlockZ() == 0) {
- msg = msg + "\n" + message("SETUP_LOBBY");
- count++;
- }
- if (seekerLobbyPosition.getBlockX() == 0 && seekerLobbyPosition.getBlockY() == 0 && seekerLobbyPosition.getBlockZ() == 0) {
- msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
- count++;
- }
- if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
- msg = msg + "\n" + message("SETUP_EXIT");
- count++;
- }
- if (saveMinX == 0 || saveMinZ == 0 || saveMaxX == 0 || saveMaxZ == 0) {
- msg = msg + "\n" + message("SETUP_BOUNDS");
- count++;
- }
- if (mapSaveEnabled) {
- File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + Main.getInstance().getGame().getGameWorld());
- if (!destenation.exists()) {
- 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 "";
- }
-
- public String getDescription() {
- return "Shows what needs to be setup";
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
index 18bcbba..5184933 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
@@ -1,31 +1,14 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
-import java.util.Optional;
-import java.util.Random;
+import java.util.List;
+import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
@@ -34,7 +17,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Start implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
+ if (Main.getInstance().getGame().checkCurrentMap()) {
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
@@ -52,22 +35,13 @@ public class Start implements ICommand {
}
String seekerName;
if (args.length < 1) {
- Optional<Player> rand = Main.getInstance().getBoard().getPlayers().stream().skip(new Random().nextInt(Main.getInstance().getBoard().size())).findFirst();
- if (!rand.isPresent()) {
- Main.getInstance().getLogger().warning("Failed to select random seeker.");
- return;
- }
- seekerName = rand.get().getName();
+ Main.getInstance().getGame().start();
+ return;
} else {
seekerName = args[0];
}
- Player temp = Bukkit.getPlayer(seekerName);
- if (temp == null) {
- sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
- return;
- }
- Player seeker = Main.getInstance().getBoard().getPlayer(temp.getUniqueId());
- if (seeker == null) {
+ Player seeker = Bukkit.getPlayer(seekerName);
+ if (seeker == null || !Main.getInstance().getBoard().contains(seeker)) {
sender.sendMessage(errorPrefix + message("START_INVALID_NAME").addPlayer(seekerName));
return;
}
@@ -79,11 +53,18 @@ public class Start implements ICommand {
}
public String getUsage() {
- return "<player>";
+ return "<*player>";
}
public String getDescription() {
return "Starts the game either with a random seeker or chosen one";
}
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("player")) {
+ return Main.getInstance().getBoard().getPlayers().stream().map(Player::getName).collect(Collectors.toList());
+ }
+ return null;
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
index 9280b53..498e30d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
@@ -1,27 +1,12 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@@ -30,8 +15,8 @@ import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
public class Stop implements ICommand {
public void execute(Player sender, String[] args) {
- if (Main.getInstance().getGame().isNotSetup()) {
- sender.sendMessage(errorPrefix + "Game is not setup. Run /hs setup to see what you needed to do");
+ if (Main.getInstance().getGame().checkCurrentMap()) {
+ sender.sendMessage(errorPrefix + message("GAME_SETUP"));
return;
}
if (Main.getInstance().getGame().getStatus() == Status.STARTING || Main.getInstance().getGame().getStatus() == Status.PLAYING) {
@@ -54,4 +39,8 @@ public class Stop implements ICommand {
return "Stops the game";
}
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
index 72a695c..13f3069 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
@@ -1,29 +1,13 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import java.util.Collections;
import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@@ -74,10 +58,15 @@ public class Top implements ICommand {
}
public String getUsage() {
- return "<page>";
+ return "<*page>";
}
public String getDescription() {
return "Gets the top players in the server.";
}
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return Collections.singletonList(parameter);
+ }
+
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
index e12d2d4..fb61fb2 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
@@ -1,29 +1,14 @@
-/*
- * 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;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import java.util.Collections;
+import java.util.List;
import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
@@ -70,10 +55,14 @@ public class Wins implements ICommand {
}
public String getUsage() {
- return "<player>";
+ return "<*player>";
}
public String getDescription() {
return "Get the win information for yourself or another player.";
}
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return Collections.singletonList(parameter);
+ }
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java
new file mode 100644
index 0000000..5e4afb5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/LocationUtils.java
@@ -0,0 +1,53 @@
+package net.tylermurphy.hideAndSeek.command.location;
+
+import net.tylermurphy.hideAndSeek.Main;
+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 org.jetbrains.annotations.NotNull;
+
+import java.util.function.Consumer;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+/**
+ * @author bobby29831
+ */
+public class LocationUtils {
+
+ public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer<Map> consumer) {
+
+ if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
+ player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
+ return;
+ }
+
+ if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
+ player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
+ return;
+ }
+
+ Map map = null;
+ if(mapName != null) {
+ map = Maps.getMap(mapName);
+ if (map == null) {
+ player.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ }
+
+ try {
+ consumer.accept(map);
+ } catch (Exception e) {
+ player.sendMessage(errorPrefix + e.getMessage());
+ return;
+ }
+
+ if(map != null)
+ Maps.setMap(mapName, map);
+ player.sendMessage(messagePrefix + message(place.message()));
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java
new file mode 100644
index 0000000..c1316f8
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/Locations.java
@@ -0,0 +1,17 @@
+package net.tylermurphy.hideAndSeek.command.location;
+
+/**
+ * @author bobby29831
+ */
+public enum Locations {
+
+ GAME,
+ LOBBY,
+ EXIT,
+ SEEKER;
+
+ public String message() {
+ return this + "_SPAWN";
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
deleted file mode 100644
index 93c0d8c..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.location;
-
-import net.tylermurphy.hideAndSeek.command.ICommand;
-import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
-import net.tylermurphy.hideAndSeek.command.location.util.Locations;
-import org.bukkit.entity.Player;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-public class SetExitLocation implements ICommand {
-
- public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.EXIT, vector -> {
- exitWorld = sender.getLocation().getWorld().getName();
- exitPosition = vector;
- });
- }
-
- public String getLabel() {
- return "setexit";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Sets hide and seeks exit location to current position and world";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
deleted file mode 100644
index eb228f9..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.location;
-
-import net.tylermurphy.hideAndSeek.command.ICommand;
-import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
-import net.tylermurphy.hideAndSeek.command.location.util.Locations;
-import org.bukkit.entity.Player;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-public class SetLobbyLocation implements ICommand {
-
- public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.LOBBY, vector -> {
- lobbyWorld = sender.getLocation().getWorld().getName();
- lobbyPosition = vector;
- });
- }
-
- public String getLabel() {
- return "setlobby";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Sets hide and seeks lobby location to current position";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
deleted file mode 100644
index c6c3ccb..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.location;
-
-import net.tylermurphy.hideAndSeek.command.ICommand;
-import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
-import net.tylermurphy.hideAndSeek.command.location.util.Locations;
-import org.bukkit.entity.Player;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-public class SetSeekerLobbyLocation implements ICommand {
-
- public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.SEEKER, vector -> {
- seekerLobbyWorld = sender.getLocation().getWorld().getName();
- seekerLobbyPosition = vector;
- });
- }
-
- public String getLabel() {
- return "setseekerlobby";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Sets hide and seeks seeker lobby location to current position";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
deleted file mode 100644
index 5ecfb8d..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.location;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.command.ICommand;
-import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
-import net.tylermurphy.hideAndSeek.command.location.util.Locations;
-import org.bukkit.entity.Player;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-public class SetSpawnLocation implements ICommand {
-
- public void execute(Player sender, String[] args) {
- LocationUtils.setLocation(sender, Locations.GAME, vector -> {
- if (worldBorderEnabled && vector.distance(worldBorderPosition) > 100) {
- sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
- throw new RuntimeException("World border not enabled or not in valid position!");
- }
-
- if (!sender.getLocation().getWorld().getName().equals(spawnWorld)) {
- Main.getInstance().getGame().getWorldLoader().unloadMap();
- Main.getInstance().getGame().getWorldLoader().setNewMap(sender.getLocation().getWorld().getName());
- }
-
- spawnWorld = sender.getLocation().getWorld().getName();
- spawnPosition = vector;
- });
- }
-
- public String getLabel() {
- return "setspawn";
- }
-
- public String getUsage() {
- return "";
- }
-
- public String getDescription() {
- return "Sets hide and seeks spawn location to current position";
- }
-
-}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java
deleted file mode 100644
index 50d1776..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/LocationUtils.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.location.util;
-
-import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.function.Consumer;
-
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-
-/**
- * @author bobby29831
- */
-public class LocationUtils {
-
- /**
- * Provides a vector for a player
- * @param player the player to create the vector for
- * @return the vector
- */
- private static @Nullable Vector vector(Player player) {
- if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
- player.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
- return null;
- }
-
- if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){
- player.sendMessage(errorPrefix + message("NOT_AT_ZERO"));
- return null;
- }
-
- Location loc = player.getLocation();
- return new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
- }
-
- public static void setLocation(Player player, Locations place, @Nullable Consumer<Vector> consumer) {
- Vector vec = vector(player);
-
- World world = player.getLocation().getWorld();
- if(world == null) {
- throw new RuntimeException("Unable to get world: " + spawnWorld);
- }
-
- consumer.accept(vec);
-
- player.sendMessage(messagePrefix + message(place.message()));
- addToConfig(place.path("x"), vec.getX());
- addToConfig(place.path("y"), vec.getY());
- addToConfig(place.path("z"), vec.getZ());
- addToConfig(place.path("world"), player.getLocation().getWorld().getName());
- saveConfig();
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java
deleted file mode 100644
index 35f74ea..0000000
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/util/Locations.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package net.tylermurphy.hideAndSeek.command.location.util;
-
-/**
- * @author bobby29831
- */
-public enum Locations {
-
- GAME("spawns.game"),
- LOBBY("spawns.lobby"),
- EXIT("spawns.exit"),
- SEEKER("spawns.seeker");
-
- private final String path;
- Locations(String path) {
- this.path = path;
- }
-
- public String message() {
- return this + "_SPAWN";
- }
-
- public String path(String additive) {
- return path + "." + additive;
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java
new file mode 100644
index 0000000..72f0740
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Add.java
@@ -0,0 +1,55 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+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 org.jetbrains.annotations.NotNull;
+
+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 Add implements ICommand {
+
+ 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(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("name")) {
+ return Collections.singletonList("name");
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java
new file mode 100644
index 0000000..209d0d6
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Debug.java
@@ -0,0 +1,123 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import com.cryptomorin.xseries.XMaterial;
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.PlayerLoader;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.*;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class Debug implements ICommand {
+
+ private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
+
+ public void execute(Player sender, String[] args) {
+ net.tylermurphy.hideAndSeek.configuration.Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ Inventory debugMenu = createMenu(map, sender);
+ sender.openInventory(debugMenu);
+ }
+
+ private Inventory createMenu(net.tylermurphy.hideAndSeek.configuration.Map map, Player sender){
+ Map<Integer, Consumer<Player>> functions = new HashMap<>();
+ Inventory debugMenu = Main.getInstance().getServer().createInventory(null, 9, "Debug Menu");
+ debugMenu.setItem(0, createOption(functions, 0, XMaterial.LEATHER_CHESTPLATE.parseMaterial(), "&6Become a &lHider", 1, player -> {
+ if(mapSaveEnabled) {
+ if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
+ }
+ Main.getInstance().getBoard().addHider(player);
+ PlayerLoader.loadHider(player, map);
+ if(Main.getInstance().getGame().getStatus() != Status.STARTING)
+ PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
+ }));
+ debugMenu.setItem(1, createOption(functions, 1, XMaterial.GOLDEN_CHESTPLATE.parseMaterial(), "&cBecome a &lSeeker", 1, player -> {
+ if(mapSaveEnabled) {
+ if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
+ }
+ Main.getInstance().getBoard().addSeeker(player);
+ PlayerLoader.loadSeeker(player, map);
+ if(Main.getInstance().getGame().getStatus() != Status.STARTING)
+ PlayerLoader.resetPlayer(player, Main.getInstance().getBoard());
+ }));
+ debugMenu.setItem(2, createOption(functions, 2, XMaterial.IRON_CHESTPLATE.parseMaterial(), "&8Become a &lSpectator", 1, player -> {
+ if(mapSaveEnabled) {
+ if(map.getGameSpawn().getWorld() == null) map.getWorldLoader().loadMap();
+ }
+ Main.getInstance().getBoard().addSpectator(player);
+ PlayerLoader.loadSpectator(player, map);
+ }));
+ debugMenu.setItem(3, createOption(functions, 3, XMaterial.BARRIER.parseMaterial(), "&cUnload from Game", 1, player -> {
+ Main.getInstance().getBoard().remove(player);
+ PlayerLoader.unloadPlayer(player);
+ exitPosition.teleport(player);
+ }));
+ debugMenu.setItem(4, createOption(functions, 4, XMaterial.BARRIER.parseMaterial(), "&cDie In Game", 2, player -> {
+ if((Main.getInstance().getBoard().isSeeker(player) || Main.getInstance().getBoard().isHider(player)) && Main.getInstance().getGame().getStatus() == Status.PLAYING){
+ player.setHealth(0.1);
+ }
+ }));
+ if(map.isBlockHuntEnabled()) {
+ debugMenu.setItem(7, createOption(functions, 7, XMaterial.GLASS.parseMaterial(), "&dEnable Disguise", 1, player -> {
+ PlayerLoader.openBlockHuntPicker(player, map);
+ }));
+ debugMenu.setItem(8, createOption(functions, 8, XMaterial.PLAYER_HEAD.parseMaterial(), "&dDisable Disguise", 1, player -> Main.getInstance().getDisguiser().reveal(player)));
+ }
+ debugMenuFunctions.put(sender, functions);
+ return debugMenu;
+ }
+
+ private ItemStack createOption(Map<Integer, Consumer<Player>> functions, int slow, Material material, String name, int amount, Consumer<Player> callback){
+ ItemStack temp = new ItemStack(material, amount);
+ ItemMeta meta = temp.getItemMeta();
+ meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
+ temp.setItemMeta(meta);
+ functions.put(slow, callback);
+ return temp;
+ }
+
+ public static void handleOption(Player player, int slotId){
+ Main.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {
+ Consumer<Player> callback = debugMenuFunctions.get(player).get(slotId);
+ if(callback != null) callback.accept(player);
+ }, 0);
+ }
+
+ public String getLabel() {
+ return "debug";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Run debug commands";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/GoTo.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java
new file mode 100644
index 0000000..7d27642
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/GoTo.java
@@ -0,0 +1,63 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+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 GoTo implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ 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").addAmount(map.getName()));
+ return;
+ }
+ switch (args[1].toLowerCase()) {
+ case "spawn":
+ map.getSpawn().teleport(sender); break;
+ case "lobby":
+ map.getLobby().teleport(sender); break;
+ case "seekerlobby":
+ map.getSeekerLobby().teleport(sender); break;
+ case "exit":
+ exitPosition.teleport(sender); break;
+ default:
+ sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1].toLowerCase()));
+ }
+ }
+
+ public String getLabel() {
+ return "goto";
+ }
+
+ public String getUsage() {
+ return "<map> <spawn>";
+ }
+
+ public String getDescription() {
+ return "Teleport to a map spawn zone";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ } else if(parameter.equals("spawn")) {
+ return Arrays.asList("spawn","lobby","seekerlobby","exit");
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java
new file mode 100644
index 0000000..ac2badf
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/List.java
@@ -0,0 +1,47 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+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) {
+ 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 java.util.List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java
new file mode 100644
index 0000000..d681848
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Remove.java
@@ -0,0 +1,54 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+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 org.jetbrains.annotations.NotNull;
+
+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 Remove implements ICommand {
+
+ 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(@NotNull String parameter, @NotNull String typed) {
+ if(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/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java
index 1e66395..03e23a8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Save.java
@@ -1,35 +1,22 @@
-/*
- * 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;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
-import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
+import org.jetbrains.annotations.NotNull;
+
+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 implements ICommand {
+public class Save implements ICommand {
public static boolean runningBackup = false;
@@ -42,21 +29,31 @@ public class SaveMap implements ICommand {
sender.sendMessage(errorPrefix + message("GAME_INPROGRESS"));
return;
}
- if (spawnPosition.getBlockX() == 0 && spawnPosition.getBlockY() == 0 && spawnPosition.getBlockZ() == 0) {
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ if (map.getSpawn().isNotSetup()) {
sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
return;
}
+ if (map.isBoundsNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_MAP_BOUNDS"));
+ return;
+ }
sender.sendMessage(messagePrefix + message("MAPSAVE_START"));
sender.sendMessage(warningPrefix + message("MAPSAVE_WARNING"));
- World world = Bukkit.getServer().getWorld(spawnWorld);
+ World world = map.getSpawn().load();
if (world == null) {
- throw new RuntimeException("Unable to get world: " + spawnWorld);
+ sender.sendMessage(warningPrefix + message("MAPSAVE_FAIL_WORLD"));
+ return;
}
world.save();
BukkitRunnable runnable = new BukkitRunnable() {
public void run() {
sender.sendMessage(
- Main.getInstance().getGame().getWorldLoader().save()
+ map.getWorldLoader().save()
);
runningBackup = false;
}
@@ -66,15 +63,22 @@ public class SaveMap implements ICommand {
}
public String getLabel() {
- return "saveMap";
+ return "save";
}
public String getUsage() {
- return "";
+ return "<map>";
}
public String getDescription() {
- return "Saves current map for the game. May lag server.";
+ return "Saves the map to its own separate playable map";
}
-
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/Status.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java
new file mode 100644
index 0000000..90615e5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Status.java
@@ -0,0 +1,79 @@
+package net.tylermurphy.hideAndSeek.command.map;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+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 Status implements ICommand {
+
+ 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.getSpawn().exists()) {
+ msg = msg + "\n" + message("SETUP_GAME");
+ count++;
+ }
+ if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !map.getLobby().exists()) {
+ msg = msg + "\n" + message("SETUP_LOBBY");
+ count++;
+ }
+ if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !map.getSeekerLobby().exists()) {
+ msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
+ count++;
+ }
+ if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !exitPosition.exists()) {
+ msg = msg + "\n" + message("SETUP_EXIT");
+ count++;
+ }
+ if (map.isBoundsNotSetup()) {
+ msg = msg + "\n" + message("SETUP_BOUNDS");
+ count++;
+ }
+ if (mapSaveEnabled && !map.getGameSpawn().exists()) {
+ msg = msg + "\n" + message("SETUP_SAVEMAP");
+ count++;
+ }
+ if (map.isBlockHuntEnabled() && map.getBlockHunt().isEmpty()) {
+ msg = msg + "\n" + message("SETUP_BLOCKHUNT");
+ }
+ if (count < 1) {
+ sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
+ } else {
+ sender.sendMessage(msg);
+ }
+ }
+
+ public String getLabel() {
+ return "status";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Shows what needs to be setup on a map";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/blockhunt/Enabled.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java
new file mode 100644
index 0000000..2567427
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/Enabled.java
@@ -0,0 +1,65 @@
+package net.tylermurphy.hideAndSeek.command.map.blockhunt;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+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 Enabled implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ if (!Main.getInstance().supports(9)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
+ 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;
+ }
+ boolean bool = Boolean.parseBoolean(args[1]);
+ map.setBlockhunt(bool, map.getBlockHunt());
+ Maps.setMap(map.getName(), map);
+ sender.sendMessage(messagePrefix + message("BLOCKHUNT_SET_TO")
+ .addAmount(bool ? ChatColor.GREEN + "true" : ChatColor.RED + "false") + ChatColor.WHITE);
+ }
+
+ public String getLabel() {
+ return "enabled";
+ }
+
+ public String getUsage() {
+ return "<map> <bool>";
+ }
+
+ public String getDescription() {
+ return "Sets blockhunt enabled or disabled in a current map";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ }
+ if(parameter.equals("bool")) {
+ return Arrays.asList("true", "false");
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java
new file mode 100644
index 0000000..fea08ef
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Add.java
@@ -0,0 +1,77 @@
+package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+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 Add implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ if (!Main.getInstance().supports(9)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
+ 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;
+ }
+ Material block;
+ try { block = Material.valueOf(args[1]); }
+ catch (IllegalArgumentException e) {
+ sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
+ return;
+ }
+ List<Material> blocks = map.getBlockHunt();
+ if(blocks.contains(block)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_EXISTS").addAmount(args[1]));
+ }
+ blocks.add(block);
+ map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
+ Maps.setMap(map.getName(), map);
+ sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_ADDED").addAmount(args[1]));
+ }
+
+ public String getLabel() {
+ return "add";
+ }
+
+ public String getUsage() {
+ return "<map> <block>";
+ }
+
+ public String getDescription() {
+ return "Add a blockhunt block to a map!";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ } else if(parameter.equals("block")) {
+ return Arrays.stream(Material.values())
+ .filter(Material::isBlock)
+ .map(Material::toString)
+ .filter(s -> s.toUpperCase().startsWith(typed.toUpperCase()))
+ .collect(Collectors.toList());
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java
new file mode 100644
index 0000000..de783ce
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/List.java
@@ -0,0 +1,60 @@
+package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+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 List implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ if (!Main.getInstance().supports(9)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
+ return;
+ }
+ Map map = Maps.getMap(args[0]);
+ if(map == null) {
+ sender.sendMessage(errorPrefix + message("INVALID_MAP"));
+ return;
+ }
+ java.util.List<Material> blocks = map.getBlockHunt();
+ if(blocks.isEmpty()) {
+ sender.sendMessage(errorPrefix + message("NO_BLOCKS"));
+ return;
+ }
+ StringBuilder response = new StringBuilder(messagePrefix + message("BLOCKHUNT_LIST_BLOCKS"));
+ for(int i = 0; i < blocks.size(); i++) {
+ response.append(String.format("\n%s. %s", i, blocks.get(i).toString()));
+ }
+ sender.sendMessage(response.toString());
+ }
+
+ public String getLabel() {
+ return "list";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "List all blockhunt blocks in a map";
+ }
+
+ public java.util.List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/blockhunt/blocks/Remove.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java
new file mode 100644
index 0000000..1c16fdc
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/blockhunt/blocks/Remove.java
@@ -0,0 +1,77 @@
+package net.tylermurphy.hideAndSeek.command.map.blockhunt.blocks;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+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 Remove implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ if (!Main.getInstance().supports(9)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_UNSUPPORTED"));
+ 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;
+ }
+ Material block;
+ try { block = Material.valueOf(args[1]); }
+ catch (IllegalArgumentException e) {
+ sender.sendMessage(errorPrefix + message("COMMAND_INVALID_ARG").addAmount(args[1]));
+ return;
+ }
+ java.util.List<Material> blocks = map.getBlockHunt();
+ if(!blocks.contains(block)) {
+ sender.sendMessage(errorPrefix + message("BLOCKHUNT_BLOCK_DOESNT_EXIT").addAmount(args[1]));
+ }
+ blocks.remove(block);
+ map.setBlockhunt(map.isBlockHuntEnabled(), blocks);
+ Maps.setMap(map.getName(), map);
+ sender.sendMessage(messagePrefix + message("BLOCKHUNT_BLOCK_REMOVED").addAmount(args[1]));
+ }
+
+ public String getLabel() {
+ return "remove";
+ }
+
+ public String getUsage() {
+ return "<map> <block>";
+ }
+
+ public String getDescription() {
+ return "Remove a blockhunt block from a map!";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(parameter.equals("map")) {
+ return Maps.getAllMaps().stream().map(net.tylermurphy.hideAndSeek.configuration.Map::getName).collect(Collectors.toList());
+ } else if(parameter.equals("block")) {
+ return Arrays.stream(Material.values())
+ .filter(Material::isBlock)
+ .map(Material::toString)
+ .filter(s -> s.toUpperCase().startsWith(typed.toUpperCase()))
+ .collect(Collectors.toList());
+ }
+ return null;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java
new file mode 100644
index 0000000..64bf5d4
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Border.java
@@ -0,0 +1,94 @@
+package net.tylermurphy.hideAndSeek.command.map.set;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+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 org.jetbrains.annotations.NotNull;
+
+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 Border implements ICommand {
+
+ 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.getSpawn().isNotSetup()) {
+ 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).addAmount(change));
+ map.getWorldBorder().resetWorldBorder();
+ }
+
+ public String getLabel() {
+ return "border";
+ }
+
+ public String getUsage() {
+ return "<map> <*size> <*delay> <*move>";
+ }
+
+ public String getDescription() {
+ return "Sets a maps world border information";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/set/Bounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java
new file mode 100644
index 0000000..3d1f036
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Bounds.java
@@ -0,0 +1,113 @@
+package net.tylermurphy.hideAndSeek.command.map.set;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.configuration.Map;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.game.util.Status;
+import net.tylermurphy.hideAndSeek.util.Location;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+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 Bounds implements ICommand {
+
+ 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.getSpawn().isNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_GAME_SPAWN"));
+ return;
+ }
+ if (map.getSeekerLobby().isNotSetup()) {
+ sender.sendMessage(errorPrefix + message("ERROR_GAME_SEEKER_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);
+ if(!map.isBoundsNotSetup()) {
+ if(!map.getSpawn().isNotSetup()) {
+ if(map.getSpawn().isNotInBounds(bxs, bxl, bzs, bzl)) {
+ map.setSpawn(Location.getDefault());
+ sender.sendMessage(warningPrefix + message("WARN_SPAWN_RESET"));
+ }
+ }
+ if(!map.getSeekerLobby().isNotSetup()) {
+ if(map.getSeekerLobby().isNotInBounds(bxs, bxl, bzs, bzl)) {
+ map.setSeekerLobby(Location.getDefault());
+ sender.sendMessage(warningPrefix + message("WARN_SEEKER_SPAWN_RESET"));
+ }
+ }
+ }
+ 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(@NotNull String parameter, @NotNull String typed) {
+ if(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/set/Lobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java
new file mode 100644
index 0000000..6690ae9
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Lobby.java
@@ -0,0 +1,41 @@
+package net.tylermurphy.hideAndSeek.command.map.set;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
+import net.tylermurphy.hideAndSeek.command.location.Locations;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.util.Location;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class Lobby implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
+ map.setLobby(Location.from(sender));
+ });
+ }
+
+ public String getLabel() {
+ return "lobby";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Sets the maps lobby location";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/set/SeekerLobby.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java
new file mode 100644
index 0000000..b6c5cf0
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/SeekerLobby.java
@@ -0,0 +1,58 @@
+package net.tylermurphy.hideAndSeek.command.map.set;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
+import net.tylermurphy.hideAndSeek.command.location.Locations;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.util.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.util.Vector;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.warningPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class SeekerLobby implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
+ if(map.getSpawn().isNotSetup()) {
+ throw new RuntimeException(message("GAME_SPAWN_NEEDED").toString());
+ }
+ if(!map.getSpawnName().equals(sender.getLocation().getWorld().getName())) {
+ throw new RuntimeException(message("SEEKER_LOBBY_INVALID").toString());
+ }
+ map.setSeekerLobby(Location.from(sender));
+ if(!map.isBoundsNotSetup()) {
+ Vector boundsMin = map.getBoundsMin();
+ Vector boundsMax = map.getBoundsMax();
+ if(map.getSeekerLobby().isNotInBounds(boundsMin.getBlockX(), boundsMax.getBlockX(), boundsMin.getBlockZ(), boundsMax.getBlockZ())) {
+ sender.sendMessage(warningPrefix + message("WARN_MAP_BOUNDS"));
+ }
+ }
+ });
+ }
+
+ public String getLabel() {
+ return "seekerlobby";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Sets the maps seeker lobby location";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/set/Spawn.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java
new file mode 100644
index 0000000..0baf55e
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/set/Spawn.java
@@ -0,0 +1,69 @@
+package net.tylermurphy.hideAndSeek.command.map.set;
+
+import net.tylermurphy.hideAndSeek.command.util.ICommand;
+import net.tylermurphy.hideAndSeek.command.location.LocationUtils;
+import net.tylermurphy.hideAndSeek.command.location.Locations;
+import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.util.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.util.Vector;
+import org.jetbrains.annotations.NotNull;
+
+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 Spawn implements ICommand {
+
+ public void execute(Player sender, String[] args) {
+ LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> {
+
+ if (map.isWorldBorderEnabled() &&
+ new Vector(sender.getLocation().getX(), 0, sender.getLocation().getZ()).distance(map.getWorldBorderPos()) > 100) {
+ sender.sendMessage(errorPrefix + message("WORLDBORDER_POSITION"));
+ throw new RuntimeException("World border not enabled or not in valid position!");
+ }
+
+ map.setSpawn(Location.from(sender));
+
+ if(!map.isBoundsNotSetup()) {
+ Vector boundsMin = map.getBoundsMin();
+ Vector boundsMax = map.getBoundsMax();
+ if(map.getSpawn().isNotInBounds(boundsMin.getBlockX(), boundsMax.getBlockX(), boundsMin.getBlockZ(), boundsMax.getBlockZ())) {
+ sender.sendMessage(warningPrefix + message("WARN_MAP_BOUNDS"));
+ }
+ }
+
+ if(map.getSeekerLobby().getWorld() != null && !map.getSeekerLobby().getWorld().equals(sender.getLocation().getWorld().getName())) {
+ sender.sendMessage(warningPrefix + message("SEEKER_LOBBY_SPAWN_RESET"));
+ map.setSeekerLobby(Location.getDefault());
+ }
+
+ if (!sender.getLocation().getWorld().getName().equals(map.getSpawnName()) && mapSaveEnabled) {
+ map.getWorldLoader().unloadMap();
+ }
+ });
+ }
+
+ public String getLabel() {
+ return "spawn";
+ }
+
+ public String getUsage() {
+ return "<map>";
+ }
+
+ public String getDescription() {
+ return "Sets the maps game spawn location";
+ }
+
+ public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) {
+ if(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/util/CommandGroup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java
new file mode 100644
index 0000000..0cb307b
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java
@@ -0,0 +1,188 @@
+package net.tylermurphy.hideAndSeek.command.util;
+
+import net.tylermurphy.hideAndSeek.command.map.Save;
+import net.tylermurphy.hideAndSeek.util.Pair;
+import net.tylermurphy.hideAndSeek.util.Tuple;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
+import static net.tylermurphy.hideAndSeek.configuration.Config.permissionsRequired;
+import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
+
+public class CommandGroup {
+
+ private final Map<String, Object> commandRegister;
+ private final String label;
+
+ public CommandGroup(String label, Object... data) {
+ this.label = label;
+ this.commandRegister = new LinkedHashMap<>();
+ for(Object o : data) {
+ registerCommand(o);
+ }
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ private void registerCommand(Object object) {
+ if (object instanceof ICommand) {
+ ICommand command = (ICommand) object;
+ if (!commandRegister.containsKey(command.getLabel())) {
+ commandRegister.put(command.getLabel().toLowerCase(), command);
+ }
+ } else if(object instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) object;
+ if (!commandRegister.containsKey(group.getLabel())) {
+ commandRegister.put(group.getLabel().toLowerCase(), group);
+ }
+ }
+ }
+
+ public void handleCommand(Player player, String[] args) {
+
+ Tuple<ICommand, String, String[]> data = getCommand(args, this.getLabel());
+
+ if (data == null) {
+ player.sendMessage(
+ String.format("%s%sKenshin's Hide and Seek %s(%s1.7.0%s)\n", ChatColor.AQUA, ChatColor.BOLD, ChatColor.GRAY, ChatColor.WHITE, ChatColor.GRAY) +
+ String.format("%sAuthor: %s[KenshinEto]\n", ChatColor.GRAY, ChatColor.WHITE) +
+ String.format("%sHelp Command: %s/hs %shelp", ChatColor.GRAY, ChatColor.AQUA, ChatColor.WHITE)
+ );
+ return;
+ }
+
+ ICommand command = data.getLeft();
+ String permission = data.getCenter();
+ String[] parameters = data.getRight();
+
+ if (Save.runningBackup) {
+ player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
+ return;
+ }
+
+ if (permissionsRequired && !player.hasPermission(permission)) {
+ player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
+ return;
+ }
+
+ int parameterCount = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count();
+ if(parameters.length < parameterCount) {
+ player.sendMessage(errorPrefix + message("ARGUMENT_COUNT"));
+ return;
+ }
+
+ try {
+ command.execute(player, parameters);
+ } catch (Exception e) {
+ player.sendMessage(errorPrefix + "An error has occurred.");
+ e.printStackTrace();
+ }
+ }
+
+ @Nullable
+ private Tuple<ICommand, String, String[]> getCommand(String[] args, String permission) {
+ if(args.length < 1) {
+ return null;
+ }
+ String invoke = args[0];
+ if(commandRegister.containsKey(invoke)) {
+ Object o = commandRegister.get(invoke);
+ if (o instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) o;
+ return group.getCommand(
+ Arrays.copyOfRange(args, 1, args.length),
+ permission + "." + group.getLabel()
+ );
+ } else if(o instanceof ICommand) {
+ ICommand command = (ICommand) o;
+ return new Tuple<>(command, permission + "." + command.getLabel(), Arrays.copyOfRange(args, 1, args.length));
+ }
+ }
+ return null;
+ }
+
+ public List<String> handleTabComplete(Player player, String[] args) {
+ return handleTabComplete(player, this.getLabel(), args);
+ }
+
+ private List<String> handleTabComplete(Player player, String permission, String[] args) {
+ String invoke = args[0].toLowerCase();
+ if (args.length == 1) {
+ return new ArrayList<>(commandRegister.keySet())
+ .stream()
+ .filter(handle -> handle.toLowerCase().startsWith(invoke))
+ .filter(handle -> {
+ Object object = commandRegister.get(handle);
+ if (object instanceof ICommand) {
+ ICommand command = (ICommand) object;
+ return !permissionsRequired || player.hasPermission(permission + "." + command.getLabel());
+ } else if (object instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) object;
+ return !permissionsRequired || group.hasPermission(player, permission + "." + group.getLabel());
+ }
+ return false;
+ })
+ .collect(Collectors.toList());
+ } else {
+ if (commandRegister.containsKey(invoke)) {
+ Object object = commandRegister.get(invoke);
+ if (object instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) object;
+ return group.handleTabComplete(player, permission + "." + group.getLabel(), Arrays.copyOfRange(args, 1, args.length));
+ } else if (object instanceof ICommand) {
+ ICommand command = (ICommand) object;
+ String[] usage = command.getUsage().split(" ");
+ if (args.length - 2 < usage.length) {
+ String parameter = usage[args.length - 2];
+ String name = parameter.replace("<", "").replace(">", "");
+ List<String> list = command.autoComplete(name, args[args.length - 1]);
+ if (list != null) {
+ return list;
+ }
+ }
+ }
+ }
+ return new ArrayList<>();
+ }
+ }
+
+ private boolean hasPermission(Player player, String permission) {
+ for(Object object : commandRegister.values()) {
+ if(object instanceof ICommand) {
+ ICommand command = (ICommand) object;
+ if(player.hasPermission(permission + command.getLabel())) return true;
+ } else if(object instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) object;
+ if (group.hasPermission(player, permission + this.label + ".")) return true;
+ }
+ }
+ return false;
+ }
+
+ public List<Pair<String, ICommand>> getCommands() {
+ return getCommands(this.getLabel());
+ }
+
+ private List<Pair<String, ICommand>> getCommands(String prefix) {
+ List<Pair<String, ICommand>> commands = new LinkedList<>();
+ for(Object object : commandRegister.values()) {
+ if(object instanceof ICommand) {
+ ICommand command = (ICommand) object;
+ commands.add(new Pair<>(prefix+" "+command.getLabel(), command));
+ } else if(object instanceof CommandGroup) {
+ CommandGroup group = (CommandGroup) object;
+ commands.addAll(group.getCommands(prefix+" "+group.getLabel()));
+ }
+ }
+ return commands;
+ }
+
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java
new file mode 100644
index 0000000..1be678c
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/ICommand.java
@@ -0,0 +1,20 @@
+package net.tylermurphy.hideAndSeek.command.util;
+
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+public interface ICommand {
+
+ void execute(Player sender, String[] args);
+
+ String getLabel();
+
+ String getUsage();
+
+ String getDescription();
+
+ List<String> autoComplete(@NotNull String parameter, @NotNull String typed);
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java
new file mode 100644
index 0000000..e399993
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Create.java
@@ -0,0 +1,82 @@
+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
new file mode 100644
index 0000000..985ccdc
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Delete.java
@@ -0,0 +1,76 @@
+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
new file mode 100644
index 0000000..bdb98e5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/world/List.java
@@ -0,0 +1,57 @@
+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
new file mode 100644
index 0000000..b166297
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/world/Tp.java
@@ -0,0 +1,49 @@
+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;
+ }
+}