Added TeamCommand

This commit is contained in:
Tim Düsterhus 2011-07-17 18:51:17 +02:00
parent 135d1856cc
commit 7b838272ae
3 changed files with 39 additions and 3 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}
}