diff --git a/war/src/main/java/bukkit/tommytony/war/War.java b/war/src/main/java/bukkit/tommytony/war/War.java index ace1453..563b324 100644 --- a/war/src/main/java/bukkit/tommytony/war/War.java +++ b/war/src/main/java/bukkit/tommytony/war/War.java @@ -177,9 +177,7 @@ public class War extends JavaPlugin { return this.commandHandler.handle(sender, cmd, commandLabel, args); if (sender instanceof Player) { - if (command.equals("leave")) { - this.performLeave(player); - } else if (command.equals("team")) { + if (command.equals("team")) { this.performTeam(player, arguments); } else if (command.equals("warhub")) { this.performWarhub(player); diff --git a/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java b/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java index 85c959a..c5f8418 100644 --- a/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java +++ b/war/src/main/java/bukkit/tommytony/war/WarCommandHandler.java @@ -45,6 +45,9 @@ public class WarCommandHandler { else if (command.equals("leave")) { commandObj = new LeaveCommand(this, sender, arguments); } + else if (command.equals("team")) { + commandObj = new TeamCommand(this, sender, arguments); + } else { // we are not responsible for this command return true; diff --git a/war/src/main/java/bukkit/tommytony/war/command/TeamCommand.java b/war/src/main/java/bukkit/tommytony/war/command/TeamCommand.java new file mode 100644 index 0000000..9e08e9c --- /dev/null +++ b/war/src/main/java/bukkit/tommytony/war/command/TeamCommand.java @@ -0,0 +1,35 @@ +package bukkit.tommytony.war.command; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import bukkit.tommytony.war.War; +import bukkit.tommytony.war.WarCommandHandler; + +import com.tommytony.war.Team; + +public class TeamCommand extends AbstractWarzoneCommand { + public TeamCommand(WarCommandHandler handler, CommandSender sender, String[] args) { + super(handler, sender, args); + } + + public boolean handle() { + if (!(this.sender instanceof Player)) return true; + + Player player = (Player) this.sender; + Team playerTeam = War.war.getPlayerTeam(player.getName()); + if (playerTeam == null) { + return false; + } + + ChatColor color = playerTeam.getKind().getColor(); + String teamMessage = color + player.getName() + ": " + ChatColor.WHITE; + for (String part : this.args) { + teamMessage += part + " "; + } + playerTeam.teamcast(teamMessage); + + return true; + } +}