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

View File

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

View File

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