Explorar o código

Adding commands to change the areas for lobby and arena.

RedstoneFuture %!s(int64=2) %!d(string=hai) anos
pai
achega
bf3e7223a7

+ 1 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/MWCommands.java

@@ -66,7 +66,7 @@ public class MWCommands extends BaseCommand {
         sendHelpMessage(sender, "mw.debug", "/mw debug", "Show debug info.");
         sendHelpMessage(sender, "mw.restartall", "/mw restartall", "Restart all games.");
 
-        sendHelpMessage(sender, "mw.setup", "/mw setup <main|lobby|arena> <value> <set|teleport> [lobby]", "Setup the MW locations or the lobby/arena locations.");
+        sendHelpMessage(sender, "mw.setup", "/mw setup <main|lobby|arena> ...", "Setup the MW locations or the lobby/arena locations.");
     }
     
     @Subcommand("listgames|list|games")

+ 119 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/SetupCommands.java

@@ -37,7 +37,7 @@ public class SetupCommands extends BaseCommand {
     @Default
     @CommandPermission("mw.setup")
     public void setupCommands(CommandSender sender, String[] args) {
-        sender.sendMessage(Messages.getPrefix() + "§fSetup usage: §7/mw setup <main|lobby|arena> <value> <set|teleport> [lobby]");
+        sender.sendMessage(Messages.getPrefix() + "§fSetup usage: §7/mw setup <main|lobby|arena> ...");
     }
 
     @Subcommand("main")
@@ -121,6 +121,65 @@ public class SetupCommands extends BaseCommand {
             }
 
         }
+
+        @Subcommand("area")
+        public class areaSetup extends BaseCommand {
+
+            @Subcommand("pos1")
+            public class pos1Setup extends BaseCommand {
+
+                @Subcommand("set")
+                @CommandCompletion("@games")
+                public void set(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    game.getLobby().getArea().setPosition1(player.getLocation());
+                    game.getLobby().setAreaConfig(game.getLobby().getArea().getAreaConfiguration());
+                    game.getLobby().updateConfig();
+                    player.sendMessage(Messages.getPrefix() + "§fSet new 'lobby area' (position 1) to " + player.getLocation() + ".");
+                }
+
+                @Subcommand("teleport|tp")
+                @CommandCompletion("@games")
+                public void teleport(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    player.teleport(game.getLobby().getArea().getPosition1());
+                    player.sendMessage(Messages.getPrefix() + "§fTeleported to 'lobby area' (position 1): " + game.getLobby().getArea().getPosition1().toString());
+                }
+                
+            }
+
+            @Subcommand("pos2")
+            public class pos2Setup extends BaseCommand {
+
+                @Subcommand("set")
+                @CommandCompletion("@games")
+                public void set(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    game.getLobby().getArea().setPosition2(player.getLocation());
+                    game.getLobby().setAreaConfig(game.getLobby().getArea().getAreaConfiguration());
+                    game.getLobby().updateConfig();
+                    player.sendMessage(Messages.getPrefix() + "§fSet new 'lobby area' (position 2) to " + player.getLocation() + ".");
+                }
+
+                @Subcommand("teleport|tp")
+                @CommandCompletion("@games")
+                public void teleport(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    player.teleport(game.getLobby().getArea().getPosition2());
+                    player.sendMessage(Messages.getPrefix() + "§fTeleported to 'lobby area' (position 2): " + game.getLobby().getArea().getPosition2().toString());
+                }
+
+            }
+            
+        }
     }
 
     @Subcommand("arena")
@@ -203,6 +262,65 @@ public class SetupCommands extends BaseCommand {
             }
 
         }
+
+        @Subcommand("area")
+        public class areaSetup extends BaseCommand {
+
+            @Subcommand("pos1")
+            public class pos1Setup extends BaseCommand {
+
+                @Subcommand("set")
+                @CommandCompletion("@games")
+                public void set(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    game.getArena().getArea().setPosition1(player.getLocation());
+                    game.getArena().setAreaConfig(game.getArena().getArea().getAreaConfiguration());
+                    game.getArena().updateConfig();
+                    player.sendMessage(Messages.getPrefix() + "§fSet new 'arena area' (position 1) to " + player.getLocation() + ".");
+                }
+
+                @Subcommand("teleport|tp")
+                @CommandCompletion("@games")
+                public void teleport(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    player.teleport(game.getArena().getArea().getPosition1());
+                    player.sendMessage(Messages.getPrefix() + "§fTeleported to 'arena area' (position 1): " + game.getArena().getArea().getPosition1().toString());
+                }
+
+            }
+
+            @Subcommand("pos2")
+            public class pos2Setup extends BaseCommand {
+
+                @Subcommand("set")
+                @CommandCompletion("@games")
+                public void set(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    game.getArena().getArea().setPosition2(player.getLocation());
+                    game.getArena().setAreaConfig(game.getArena().getArea().getAreaConfiguration());
+                    game.getArena().updateConfig();
+                    player.sendMessage(Messages.getPrefix() + "§fSet new 'arena area' (position 2) to " + player.getLocation() + ".");
+                }
+
+                @Subcommand("teleport|tp")
+                @CommandCompletion("@games")
+                public void teleport(CommandSender sender, String[] args) {
+                    if (!senderIsPlayer(sender)) return;
+                    if (!isValidGame(args)) return;
+
+                    player.teleport(game.getArena().getArea().getPosition2());
+                    player.sendMessage(Messages.getPrefix() + "§fTeleported to 'arena area' (position 2): " + game.getArena().getArea().getPosition2().toString());
+                }
+
+            }
+
+        }
     }
 
     /**