summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/command')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/About.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Help.java17
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Join.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Start.java4
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java4
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Top.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java3
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java6
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java8
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java6
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java6
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/AddMap.java)8
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/ListMaps.java)7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/RemoveMap.java)7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java)7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java)15
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java)7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/SetMap.java)7
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java)22
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/util/Command.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java)22
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java170
24 files changed, 262 insertions, 82 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
index 54e0de7..119888b 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/About.java
@@ -19,12 +19,13 @@
package net.tylermurphy.hideAndSeek.command;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.List;
-public class About implements ICommand {
+public class About extends Command {
public void execute(Player sender, String[] args) {
sender.sendMessage(
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
index e877659..2eb0eb9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Debug.java
@@ -2,6 +2,7 @@ package net.tylermurphy.hideAndSeek.command;
import com.cryptomorin.xseries.XMaterial;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.PlayerLoader;
import net.tylermurphy.hideAndSeek.game.util.Status;
@@ -21,7 +22,7 @@ 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 {
+public class Debug extends Command {
private static final Map<Player, Map<Integer, Consumer<Player>>> debugMenuFunctions = new HashMap<>();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
index 5de7210..4297f3d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Help.java
@@ -20,20 +20,21 @@
package net.tylermurphy.hideAndSeek.command;
import net.md_5.bungee.api.ChatColor;
-import net.tylermurphy.hideAndSeek.util.CommandHandler;
+import net.tylermurphy.hideAndSeek.command.util.Command;
+import net.tylermurphy.hideAndSeek.command.util.CommandGroup;
import org.bukkit.entity.Player;
import java.util.List;
-public class Help implements ICommand {
+public class Help extends Command {
public void execute(Player sender, String[] args) {
- 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 = new StringBuilder(message.substring(0, message.length() - 1));
- sender.sendMessage(message.toString());
+// StringBuilder message = new StringBuilder();
+// for(Command command : CommandGroup.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 = new StringBuilder(message.substring(0, message.length() - 1));
+// sender.sendMessage(message.toString());
}
public String getLabel() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
index c57b953..ca2a77f 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Join.java
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -28,7 +29,7 @@ import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Join implements ICommand {
+public class Join extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
index 0e860cb..d22aad9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Leave.java
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -28,7 +29,7 @@ import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Leave implements ICommand {
+public class Leave extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
index 4a4efbe..51bc509 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Reload.java
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Items;
import net.tylermurphy.hideAndSeek.configuration.Localization;
@@ -33,7 +34,7 @@ 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 Reload implements ICommand {
+public class Reload extends Command {
public void execute(Player sender, String[] args) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
index 085aeab..54ad4af 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Start.java
@@ -20,7 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
-import net.tylermurphy.hideAndSeek.configuration.Maps;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -34,7 +34,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.minPlayers;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Start implements ICommand {
+public class Start extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
index 4567bb1..1582be9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Stop.java
@@ -20,17 +20,17 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
import java.util.List;
-import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.abortPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Stop implements ICommand {
+public class Stop extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().checkCurrentMap()) {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
index c57f246..8116eaf 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Top.java
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -30,7 +31,7 @@ import java.util.List;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Top implements ICommand {
+public class Top extends Command {
public void execute(Player sender, String[] args) {
int page;
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
index 9ed7345..c5917c2 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/Wins.java
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.command;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -31,7 +32,7 @@ import java.util.UUID;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Wins implements ICommand {
+public class Wins extends Command {
public void execute(Player sender, String[] args) {
Main.getInstance().getServer().getScheduler().runTaskAsynchronously(Main.getInstance(), () -> {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
index 1bb1d6f..01e1512 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetExitLocation.java
@@ -19,18 +19,16 @@
package net.tylermurphy.hideAndSeek.command.location;
-import net.tylermurphy.hideAndSeek.command.ICommand;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
-import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
import java.util.List;
-import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-public class SetExitLocation implements ICommand {
+public class SetExitLocation extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.EXIT, null, map -> {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
index 84e1109..da41d91 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetLobbyLocation.java
@@ -19,7 +19,7 @@
package net.tylermurphy.hideAndSeek.command.location;
-import net.tylermurphy.hideAndSeek.command.ICommand;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
@@ -28,9 +28,7 @@ import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
-import static net.tylermurphy.hideAndSeek.configuration.Config.*;
-
-public class SetLobbyLocation implements ICommand {
+public class SetLobbyLocation extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.LOBBY, args[0], map -> {
@@ -39,7 +37,7 @@ public class SetLobbyLocation implements ICommand {
}
public String getLabel() {
- return "setlobby";
+ return "lobby";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
index c6d9f93..8a5ebd1 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSeekerLobbyLocation.java
@@ -1,6 +1,6 @@
package net.tylermurphy.hideAndSeek.command.location;
-import net.tylermurphy.hideAndSeek.command.ICommand;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
@@ -11,7 +11,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class SetSeekerLobbyLocation implements ICommand {
+public class SetSeekerLobbyLocation extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.SEEKER, args[0], map -> {
@@ -26,7 +26,7 @@ public class SetSeekerLobbyLocation implements ICommand {
}
public String getLabel() {
- return "setseekerlobby";
+ return "seekerlobby";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
index 50932d6..82f71d1 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/location/SetSpawnLocation.java
@@ -19,7 +19,7 @@
package net.tylermurphy.hideAndSeek.command.location;
-import net.tylermurphy.hideAndSeek.command.ICommand;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.command.location.util.LocationUtils;
import net.tylermurphy.hideAndSeek.command.location.util.Locations;
import net.tylermurphy.hideAndSeek.configuration.Maps;
@@ -33,7 +33,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class SetSpawnLocation implements ICommand {
+public class SetSpawnLocation extends Command {
public void execute(Player sender, String[] args) {
LocationUtils.setLocation(sender, Locations.GAME, args[0], map -> {
@@ -58,7 +58,7 @@ public class SetSpawnLocation implements ICommand {
}
public String getLabel() {
- return "setspawn";
+ return "spawn";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/AddMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java
index 086280e..55b4267 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/AddMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/AddMap.java
@@ -1,12 +1,12 @@
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -14,7 +14,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class AddMap implements ICommand {
+public class AddMap extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
@@ -33,7 +33,7 @@ public class AddMap implements ICommand {
}
public String getLabel() {
- return "addmap";
+ return "add";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/ListMaps.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java
index 0025de5..79490a7 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/ListMaps.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/ListMaps.java
@@ -1,5 +1,6 @@
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.ChatColor;
@@ -12,7 +13,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class ListMaps implements ICommand {
+public class ListMaps extends Command {
public void execute(Player sender, String[] args) {
Collection<Map> maps = Maps.getAllMaps();
@@ -28,7 +29,7 @@ public class ListMaps implements ICommand {
}
public String getLabel() {
- return "listmaps";
+ return "list";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/RemoveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java
index b5727c8..216cca9 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/RemoveMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/RemoveMap.java
@@ -1,6 +1,7 @@
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
@@ -13,7 +14,7 @@ import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Config.messagePrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class RemoveMap implements ICommand {
+public class RemoveMap extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
@@ -31,7 +32,7 @@ public class RemoveMap implements ICommand {
}
public String getLabel() {
- return "removemap";
+ return "remove";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java
index ca2532c..f3eb4d7 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SaveMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SaveMap.java
@@ -17,9 +17,10 @@
*
*/
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
@@ -33,7 +34,7 @@ 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 SaveMap extends Command {
public static boolean runningBackup = false;
@@ -75,7 +76,7 @@ public class SaveMap implements ICommand {
}
public String getLabel() {
- return "saveMap";
+ return "save";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java
index 9768030..8362e02 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBorder.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBorder.java
@@ -17,16 +17,15 @@
*
*/
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -34,7 +33,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class SetBorder implements ICommand {
+public class SetBorder extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
@@ -59,15 +58,15 @@ public class SetBorder implements ICommand {
return;
}
int num,delay,change;
- try { num = Integer.parseInt(args[0]); } catch (Exception e) {
+ 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[1]); } catch (Exception e) {
+ 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[2]); } catch (Exception e) {
+ try { change = Integer.parseInt(args[3]); } catch (Exception e) {
sender.sendMessage(errorPrefix + message("WORLDBORDER_INVALID_INPUT").addAmount(args[2]));
return;
}
@@ -92,7 +91,7 @@ public class SetBorder implements ICommand {
}
public String getLabel() {
- return "setBorder";
+ return "border";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java
index 563116d..92bf5a4 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetBounds.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetBounds.java
@@ -17,9 +17,10 @@
*
*/
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
@@ -31,7 +32,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class SetBounds implements ICommand {
+public class SetBounds extends Command {
public void execute(Player sender, String[] args) {
if (Main.getInstance().getGame().getStatus() != Status.STANDBY) {
@@ -90,7 +91,7 @@ public class SetBounds implements ICommand {
}
public String getLabel() {
- return "setBounds";
+ return "bounds";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/SetMap.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java
index c2c6a6e..2df5824 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/SetMap.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/SetMap.java
@@ -1,6 +1,7 @@
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import net.tylermurphy.hideAndSeek.game.util.Status;
@@ -12,7 +13,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.errorPrefix;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class SetMap implements ICommand {
+public class SetMap extends Command {
public void execute(Player sender, String[] args) {
@@ -45,7 +46,7 @@ public class SetMap implements ICommand {
}
public String getLabel() {
- return "setmap";
+ return "goto";
}
public String getUsage() {
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java
index b222c61..46b41f7 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/Setup.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/map/Setup.java
@@ -17,9 +17,10 @@
*
*/
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.map;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.command.util.Command;
import net.tylermurphy.hideAndSeek.configuration.Map;
import net.tylermurphy.hideAndSeek.configuration.Maps;
import org.bukkit.entity.Player;
@@ -31,7 +32,7 @@ import java.util.stream.Collectors;
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
import static net.tylermurphy.hideAndSeek.configuration.Localization.message;
-public class Setup implements ICommand {
+public class Setup extends Command {
public void execute(Player sender, String[] args) {
@@ -42,19 +43,19 @@ public class Setup implements ICommand {
sender.sendMessage(errorPrefix + message("INVALID_MAP"));
return;
}
- if (map.getSpawn().getWorld() == null || map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0) {
+ if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
msg = msg + "\n" + message("SETUP_GAME");
count++;
}
- if (map.getLobby().getWorld() == null || map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0) {
+ if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !Map.worldExists(map.getLobbyName())) {
msg = msg + "\n" + message("SETUP_LOBBY");
count++;
}
- if (map.getSeekerLobby().getWorld() == null || map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0) {
+ if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !Map.worldExists(map.getSeekerLobbyName())) {
msg = msg + "\n" + message("SETUP_SEEKER_LOBBY");
count++;
}
- if (exitWorld == null || exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0) {
+ if (exitPosition.getBlockX() == 0 && exitPosition.getBlockY() == 0 && exitPosition.getBlockZ() == 0 || !Map.worldExists(exitWorld)) {
msg = msg + "\n" + message("SETUP_EXIT");
count++;
}
@@ -63,12 +64,9 @@ public class Setup implements ICommand {
msg = msg + "\n" + message("SETUP_BOUNDS");
count++;
}
- if (mapSaveEnabled) {
- File destenation = new File(Main.getInstance().getWorldContainer() + File.separator + map.getGameSpawnName());
- if (!destenation.exists()) {
- msg = msg + "\n" + message("SETUP_SAVEMAP");
- count++;
- }
+ if (mapSaveEnabled && !Map.worldExists(map.getGameSpawnName())) {
+ msg = msg + "\n" + message("SETUP_SAVEMAP");
+ count++;
}
if (count < 1) {
sender.sendMessage(messagePrefix + message("SETUP_COMPLETE"));
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java b/src/main/java/net/tylermurphy/hideAndSeek/command/util/Command.java
index 91fd8f9..d03274d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/command/ICommand.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/Command.java
@@ -17,23 +17,27 @@
*
*/
-package net.tylermurphy.hideAndSeek.command;
+package net.tylermurphy.hideAndSeek.command.util;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.List;
-public interface ICommand {
+public abstract class Command {
- void execute(Player sender, String[] args);
-
- String getLabel();
+ public abstract void execute(Player sender, String[] args);
- String getUsage();
-
- String getDescription();
+ public abstract String getLabel();
+
+ public abstract String getUsage();
+
+ public abstract String getDescription();
+
+ public abstract List<String> autoComplete(@Nullable String parameter);
- List<String> autoComplete(@Nullable String parameter);
+ public boolean hasPermission(Player sender, String permission) {
+ return sender.hasPermission(permission+"."+getLabel());
+ }
}
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..9079ccc
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/command/util/CommandGroup.java
@@ -0,0 +1,170 @@
+/*
+ * 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.util;
+
+import net.tylermurphy.hideAndSeek.command.*;
+import net.tylermurphy.hideAndSeek.command.map.SaveMap;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+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 HashMap<>();
+ for(Object o : data) registerCommand(o);
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ private void registerCommand(Object object) {
+ if(object instanceof Command) {
+ Command command = (Command) 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 boolean handleCommand(Player player, String permission, String[] args) {
+ if (args.length < 1 && permission.equals("hs") || !commandRegister.containsKey(args[0].toLowerCase()) ) {
+ if (permissionsRequired && !player.hasPermission("hs.about")) {
+ player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
+ } else {
+ new About().execute(player, null);
+ }
+ } else {
+ String invoke = args[0].toLowerCase();
+ if (!invoke.equals("about") && !invoke.equals("help") && SaveMap.runningBackup) {
+ player.sendMessage(errorPrefix + message("MAPSAVE_INPROGRESS"));
+ } else if (permissionsRequired && !player.hasPermission(permission+"."+invoke)) {
+ player.sendMessage(errorPrefix + message("COMMAND_NOT_ALLOWED"));
+ } else {
+ try {
+ Object object = commandRegister.get(invoke);
+ if(object instanceof CommandGroup) return ((CommandGroup) object).handleCommand(player, permission+"."+this.label, Arrays.copyOfRange(args, 1, args.length));
+ Command command = (Command) object;
+
+ int parameters = (int) Arrays.stream(command.getUsage().split(" ")).filter(p -> p.startsWith("<") && !p.startsWith("<*")).count();
+ if(args.length - 1 < parameters) {
+ player.sendMessage(errorPrefix + message("ARGUMENT_COUNT"));
+ return true;
+ }
+ command.execute(player,Arrays.copyOfRange(args, 1, args.length));
+ } catch (Exception e) {
+ player.sendMessage(errorPrefix + "An error has occurred.");
+ e.printStackTrace();
+ }
+ }
+ }
+ return true;
+ }
+
+ public List<String> handleTabComplete(CommandSender sender, String[] args) {
+ String invoke = args[0].toLowerCase();
+ if (args.length == 1) {
+ if(sender instanceof Player) {
+ Player player = (Player) sender;
+ return new ArrayList<>(commandRegister.keySet())
+ .stream()
+ .filter(handle -> handle.toLowerCase().startsWith(invoke))
+ .filter(handle -> {
+ Object object = commandRegister.get(handle);
+ if (object instanceof Command) return ((Command) object).hasPermission(player, this.label);
+ if (object instanceof CommandGroup)
+ return ((CommandGroup) object).hasPermission(player, this.label);
+ return false;
+ })
+ .collect(Collectors.toList());
+ }
+ return commandRegister.keySet().stream().filter(handle -> handle.toLowerCase().startsWith(invoke)).collect(Collectors.toList());
+ } else {
+ if (!commandRegister.containsKey(invoke)) {
+ return new ArrayList<>();
+ } else {
+ Object object = commandRegister.get(invoke);
+ if(object instanceof CommandGroup) return ((CommandGroup) object).handleTabComplete(sender, Arrays.copyOfRange(args, 1, args.length));
+ Command command = (Command) object;
+ String[] usage = command.getUsage().split(" ");
+ List<String> complete;
+ if (args.length - 2 < usage.length) {
+ String parameter = usage[args.length-2];
+ String name = parameter.replace("<", "").replace(">", "");
+ complete = command.autoComplete(name);
+ } else {
+ complete = command.autoComplete(null);
+ }
+ if(complete == null) return new ArrayList<>();
+ else return complete;
+ }
+ }
+ }
+
+ private boolean hasPermission(Player player, String permission) {
+ for(Object object : commandRegister.values()) {
+ if(object instanceof Command) if(((Command) object).hasPermission(player, this.label)) return true;
+ if(object instanceof CommandGroup) if (((CommandGroup) object).hasPermission(player, permission+"."+this.label)) return true;
+ }
+ return false;
+ }
+
+ // public static void registerCommands() {
+// registerCommand(new About());
+// registerCommand(new Help());
+// registerCommand(new Setup());
+// registerCommand(new Start());
+// registerCommand(new Stop());
+// registerCommand(new SetSpawnLocation());
+// registerCommand(new SetLobbyLocation());
+// registerCommand(new SetSeekerLobbyLocation());
+// registerCommand(new SetExitLocation());
+// registerCommand(new SetBorder());
+// registerCommand(new Reload());
+// registerCommand(new SaveMap());
+// registerCommand(new SetBounds());
+// registerCommand(new Join());
+// registerCommand(new Leave());
+// registerCommand(new Top());
+// registerCommand(new Wins());
+// registerCommand(new Debug());
+// registerCommand(new AddMap());
+// registerCommand(new RemoveMap());
+// registerCommand(new ListMaps());
+// registerCommand(new SetMap());
+// }
+
+}