I have sinned a great sin.

Forgot to switch IntelliJ to use tabs.
This commit is contained in:
cmastudios 2013-11-19 15:53:30 -06:00
parent 66158ae44b
commit 0f35c4dc4c
3 changed files with 67 additions and 67 deletions

View File

@ -44,7 +44,7 @@ import com.tommytony.war.volume.Volume;
*/ */
public class Team { public class Team {
private List<Player> players = new ArrayList<Player>(); private List<Player> players = new ArrayList<Player>();
private List<Player> teamChatPlayers = new ArrayList<Player>(); private List<Player> teamChatPlayers = new ArrayList<Player>();
private List<Location> teamSpawns; private List<Location> teamSpawns;
private Location teamFlag = null; private Location teamFlag = null;
private String name; private String name;
@ -452,9 +452,9 @@ public class Team {
public void removePlayer(Player thePlayer) { public void removePlayer(Player thePlayer) {
this.players.remove(thePlayer); this.players.remove(thePlayer);
synchronized (teamChatPlayers) { synchronized (teamChatPlayers) {
this.teamChatPlayers.remove(thePlayer); this.teamChatPlayers.remove(thePlayer);
} }
this.warzone.dropAllStolenObjects(thePlayer, false); this.warzone.dropAllStolenObjects(thePlayer, false);
if (War.war.isTagServer()) { if (War.war.isTagServer()) {
TagAPI.refreshPlayer(thePlayer); TagAPI.refreshPlayer(thePlayer);
@ -763,51 +763,51 @@ public class Team {
return false; return false;
} }
/** /**
* Send a team chat message with proper formatting. * Send a team chat message with proper formatting.
* *
* @param sender Player sending the message * @param sender Player sending the message
* @param message Message to send * @param message Message to send
*/ */
public void sendTeamChatMessage(OfflinePlayer sender, String message) { public void sendTeamChatMessage(OfflinePlayer sender, String message) {
String player = this.getKind().getColor() + ChatColor.stripColor(sender.getName()) + ChatColor.WHITE; String player = this.getKind().getColor() + ChatColor.stripColor(sender.getName()) + ChatColor.WHITE;
String output = String.format("%s: %s", player, message); String output = String.format("%s: %s", player, message);
teamcast(output, false); teamcast(output, false);
War.war.getLogger().info("[TeamChat] " + output); War.war.getLogger().info("[TeamChat] " + output);
} }
/** /**
* Check if a player on this team has toggled on team chat. Thread safe. * Check if a player on this team has toggled on team chat. Thread safe.
* *
* @param player Player to check * @param player Player to check
* @return true if the player has toggled on team chat * @return true if the player has toggled on team chat
*/ */
public boolean isInTeamChat(Player player) { public boolean isInTeamChat(Player player) {
synchronized (teamChatPlayers) { synchronized (teamChatPlayers) {
return this.teamChatPlayers.contains(player); return this.teamChatPlayers.contains(player);
} }
} }
/** /**
* Add a player to team chat. Thread safe. * Add a player to team chat. Thread safe.
* @param player Player to add * @param player Player to add
* @throws IllegalArgumentException Player is already in team chat * @throws IllegalArgumentException Player is already in team chat
*/ */
public void addTeamChatPlayer(Player player) { public void addTeamChatPlayer(Player player) {
Validate.isTrue(!isInTeamChat(player), "Player is already in team chat"); Validate.isTrue(!isInTeamChat(player), "Player is already in team chat");
synchronized (teamChatPlayers) { synchronized (teamChatPlayers) {
this.teamChatPlayers.add(player); this.teamChatPlayers.add(player);
} }
} }
/** /**
* Remove a player from team chat. Thread safe. * Remove a player from team chat. Thread safe.
* *
* @param player Player to remove * @param player Player to remove
*/ */
public void removeTeamChatPlayer(Player player) { public void removeTeamChatPlayer(Player player) {
synchronized (teamChatPlayers) { synchronized (teamChatPlayers) {
this.teamChatPlayers.remove(player); this.teamChatPlayers.remove(player);
} }
} }
} }

View File

@ -30,22 +30,22 @@ public class TeamCommand extends AbstractWarCommand {
return false; return false;
} }
if (this.args.length < 1) { if (this.args.length < 1) {
if (playerTeam.isInTeamChat(player)) { if (playerTeam.isInTeamChat(player)) {
playerTeam.removeTeamChatPlayer(player); playerTeam.removeTeamChatPlayer(player);
this.msg("team.chat.disable"); this.msg("team.chat.disable");
} else { } else {
playerTeam.addTeamChatPlayer(player); playerTeam.addTeamChatPlayer(player);
this.msg("team.chat.enable"); this.msg("team.chat.enable");
} }
return true; return true;
} }
StringBuilder teamMessage = new StringBuilder(); StringBuilder teamMessage = new StringBuilder();
for (String part : this.args) { for (String part : this.args) {
teamMessage.append(part).append(' '); teamMessage.append(part).append(' ');
} }
playerTeam.sendTeamChatMessage(player, teamMessage.toString()); playerTeam.sendTeamChatMessage(player, teamMessage.toString());
return true; return true;
} }
} }

View File

@ -873,14 +873,14 @@ public class WarPlayerListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onPlayerChat(final AsyncPlayerChatEvent event) { public void onPlayerChat(final AsyncPlayerChatEvent event) {
Team team = Team.getTeamByPlayerName(event.getPlayer().getName()); Team team = Team.getTeamByPlayerName(event.getPlayer().getName());
if (team != null && team.isInTeamChat(event.getPlayer())) { if (team != null && team.isInTeamChat(event.getPlayer())) {
event.setCancelled(true); event.setCancelled(true);
team.sendTeamChatMessage(event.getPlayer(), event.getMessage()); team.sendTeamChatMessage(event.getPlayer(), event.getMessage());
} }
} }
public void purgeLatestPositions() { public void purgeLatestPositions() {
this.latestLocations.clear(); this.latestLocations.clear();