|
@@ -19,7 +19,11 @@
|
|
|
package de.butzlabben.missilewars.commands;
|
|
|
|
|
|
import co.aikar.commands.BaseCommand;
|
|
|
-import co.aikar.commands.annotation.*;
|
|
|
+import co.aikar.commands.annotation.CommandAlias;
|
|
|
+import co.aikar.commands.annotation.CommandCompletion;
|
|
|
+import co.aikar.commands.annotation.CommandPermission;
|
|
|
+import co.aikar.commands.annotation.Default;
|
|
|
+import co.aikar.commands.annotation.Subcommand;
|
|
|
import de.butzlabben.missilewars.configuration.Config;
|
|
|
import de.butzlabben.missilewars.configuration.Messages;
|
|
|
import de.butzlabben.missilewars.game.Game;
|
|
@@ -67,11 +71,28 @@ public class SetupCommands extends BaseCommand {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Subcommand("lobby")
|
|
|
- public class LobbySetupCommands extends BaseCommand {
|
|
|
+ /**
|
|
|
+ * This method checks if the command sender is a valid ingame player.
|
|
|
+ *
|
|
|
+ * @param sender = the command sender
|
|
|
+ *
|
|
|
+ * @return true, if it's an ingame player
|
|
|
+ */
|
|
|
+ private boolean senderIsPlayer(CommandSender sender) {
|
|
|
+ if (sender instanceof Player) {
|
|
|
+ player = (Player) sender;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- @Subcommand("spawnpoint")
|
|
|
- public class SpawnpointSetup extends BaseCommand {
|
|
|
+ sender.sendMessage(Messages.getPrefix() + "§cYou are not a player");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Subcommand("arena")
|
|
|
+ public class ArenaSetupCommands extends BaseCommand {
|
|
|
+
|
|
|
+ @Subcommand("spectatorspawn")
|
|
|
+ public class SpectatorspawnSetup extends BaseCommand {
|
|
|
|
|
|
@Subcommand("set")
|
|
|
@CommandCompletion("@games")
|
|
@@ -79,9 +100,9 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- game.getLobby().setSpawnPoint(player.getLocation());
|
|
|
- game.getLobby().updateConfig();
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fSet new 'spawnPoint' to " + player.getLocation() + ".");
|
|
|
+ game.getArena().setSpectatorSpawn(player.getLocation());
|
|
|
+ game.getArena().updateConfig();
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fSet new 'spectatorSpawn' to " + player.getLocation() + ".");
|
|
|
}
|
|
|
|
|
|
@Subcommand("teleport|tp")
|
|
@@ -90,14 +111,14 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- player.teleport(game.getLobby().getSpawnPoint());
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fTeleported to 'spawnPoint'.");
|
|
|
+ player.teleport(game.getArena().getSpectatorSpawn());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'spectatorSpawn'.");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Subcommand("aftergamespawn")
|
|
|
- public class AftergamespawnSetup extends BaseCommand {
|
|
|
+ @Subcommand("team1spawn")
|
|
|
+ public class Team1spawnSetup extends BaseCommand {
|
|
|
|
|
|
@Subcommand("set")
|
|
|
@CommandCompletion("@games")
|
|
@@ -105,9 +126,9 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- game.getLobby().setAfterGameSpawn(player.getLocation());
|
|
|
- game.getLobby().updateConfig();
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fSet new 'afterGameSpawn' to " + player.getLocation() + ".");
|
|
|
+ game.getArena().setTeam1Spawn(player.getLocation());
|
|
|
+ game.getArena().updateConfig();
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fSet new 'team1Spawn' to " + player.getLocation() + ".");
|
|
|
}
|
|
|
|
|
|
@Subcommand("teleport|tp")
|
|
@@ -116,8 +137,34 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- player.teleport(game.getLobby().getAfterGameSpawn());
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fTeleported to 'afterGameSpawn'.");
|
|
|
+ player.teleport(game.getArena().getTeam1Spawn());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'team1Spawn'.");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Subcommand("team2spawn")
|
|
|
+ public class Team2spawnSetup extends BaseCommand {
|
|
|
+
|
|
|
+ @Subcommand("set")
|
|
|
+ @CommandCompletion("@games")
|
|
|
+ public void set(CommandSender sender, String[] args) {
|
|
|
+ if (!senderIsPlayer(sender)) return;
|
|
|
+ if (!isValidGame(args)) return;
|
|
|
+
|
|
|
+ game.getArena().setTeam2Spawn(player.getLocation());
|
|
|
+ game.getArena().updateConfig();
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fSet new 'team2Spawn' 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().getTeam2Spawn());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'team2Spawn'.");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -134,10 +181,10 @@ public class SetupCommands extends BaseCommand {
|
|
|
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() + ".");
|
|
|
+ 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")
|
|
@@ -146,10 +193,10 @@ public class SetupCommands extends BaseCommand {
|
|
|
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());
|
|
|
+ player.teleport(game.getArena().getArea().getPosition1());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'arena area' (position 1): " + game.getArena().getArea().getPosition1().toString());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Subcommand("pos2")
|
|
@@ -161,10 +208,10 @@ public class SetupCommands extends BaseCommand {
|
|
|
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() + ".");
|
|
|
+ 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")
|
|
@@ -173,46 +220,20 @@ public class SetupCommands extends BaseCommand {
|
|
|
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());
|
|
|
+ player.teleport(game.getArena().getArea().getPosition2());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'arena area' (position 2): " + game.getArena().getArea().getPosition2().toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Subcommand("arena")
|
|
|
- public class ArenaSetupCommands extends BaseCommand {
|
|
|
-
|
|
|
- @Subcommand("spectatorspawn")
|
|
|
- public class SpectatorspawnSetup extends BaseCommand {
|
|
|
-
|
|
|
- @Subcommand("set")
|
|
|
- @CommandCompletion("@games")
|
|
|
- public void set(CommandSender sender, String[] args) {
|
|
|
- if (!senderIsPlayer(sender)) return;
|
|
|
- if (!isValidGame(args)) return;
|
|
|
-
|
|
|
- game.getArena().setSpectatorSpawn(player.getLocation());
|
|
|
- game.getArena().updateConfig();
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fSet new 'spectatorSpawn' 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().getSpectatorSpawn());
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fTeleported to 'spectatorSpawn'.");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ @Subcommand("lobby")
|
|
|
+ public class LobbySetupCommands extends BaseCommand {
|
|
|
|
|
|
- @Subcommand("team1spawn")
|
|
|
- public class Team1spawnSetup extends BaseCommand {
|
|
|
+ @Subcommand("spawnpoint")
|
|
|
+ public class SpawnpointSetup extends BaseCommand {
|
|
|
|
|
|
@Subcommand("set")
|
|
|
@CommandCompletion("@games")
|
|
@@ -220,9 +241,9 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- game.getArena().setTeam1Spawn(player.getLocation());
|
|
|
- game.getArena().updateConfig();
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fSet new 'team1Spawn' to " + player.getLocation() + ".");
|
|
|
+ game.getLobby().setSpawnPoint(player.getLocation());
|
|
|
+ game.getLobby().updateConfig();
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fSet new 'spawnPoint' to " + player.getLocation() + ".");
|
|
|
}
|
|
|
|
|
|
@Subcommand("teleport|tp")
|
|
@@ -231,14 +252,14 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- player.teleport(game.getArena().getTeam1Spawn());
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fTeleported to 'team1Spawn'.");
|
|
|
+ player.teleport(game.getLobby().getSpawnPoint());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'spawnPoint'.");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Subcommand("team2spawn")
|
|
|
- public class Team2spawnSetup extends BaseCommand {
|
|
|
+ @Subcommand("aftergamespawn")
|
|
|
+ public class AftergamespawnSetup extends BaseCommand {
|
|
|
|
|
|
@Subcommand("set")
|
|
|
@CommandCompletion("@games")
|
|
@@ -246,9 +267,9 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- game.getArena().setTeam2Spawn(player.getLocation());
|
|
|
- game.getArena().updateConfig();
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fSet new 'team2Spawn' to " + player.getLocation() + ".");
|
|
|
+ game.getLobby().setAfterGameSpawn(player.getLocation());
|
|
|
+ game.getLobby().updateConfig();
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fSet new 'afterGameSpawn' to " + player.getLocation() + ".");
|
|
|
}
|
|
|
|
|
|
@Subcommand("teleport|tp")
|
|
@@ -257,8 +278,8 @@ public class SetupCommands extends BaseCommand {
|
|
|
if (!senderIsPlayer(sender)) return;
|
|
|
if (!isValidGame(args)) return;
|
|
|
|
|
|
- player.teleport(game.getArena().getTeam2Spawn());
|
|
|
- player.sendMessage(Messages.getPrefix() + "§fTeleported to 'team2Spawn'.");
|
|
|
+ player.teleport(game.getLobby().getAfterGameSpawn());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'afterGameSpawn'.");
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -275,10 +296,10 @@ public class SetupCommands extends BaseCommand {
|
|
|
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() + ".");
|
|
|
+ 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")
|
|
@@ -287,8 +308,8 @@ public class SetupCommands extends BaseCommand {
|
|
|
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());
|
|
|
+ player.teleport(game.getLobby().getArea().getPosition1());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'lobby area' (position 1): " + game.getLobby().getArea().getPosition1().toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -302,10 +323,10 @@ public class SetupCommands extends BaseCommand {
|
|
|
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() + ".");
|
|
|
+ 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")
|
|
@@ -314,8 +335,8 @@ public class SetupCommands extends BaseCommand {
|
|
|
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());
|
|
|
+ player.teleport(game.getLobby().getArea().getPosition2());
|
|
|
+ player.sendMessage(Messages.getPrefix() + "§fTeleported to 'lobby area' (position 2): " + game.getLobby().getArea().getPosition2().toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -323,22 +344,6 @@ public class SetupCommands extends BaseCommand {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * This method checks if the command sender is a valid ingame player.
|
|
|
- *
|
|
|
- * @param sender = the command sender
|
|
|
- * @return true, if it's an ingame player
|
|
|
- */
|
|
|
- private boolean senderIsPlayer(CommandSender sender) {
|
|
|
- if (sender instanceof Player) {
|
|
|
- player = (Player) sender;
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- sender.sendMessage(Messages.getPrefix() + "§cYou are not a player");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* This method checks if the player execute the command on a valid
|
|
|
* game world (lobby or area).
|