Added Domain.contains(String playerName).

This commit is contained in:
TomyLobo 2012-03-23 14:40:20 +01:00
parent f2fead1444
commit 690da2332b
5 changed files with 59 additions and 25 deletions

View File

@ -70,8 +70,9 @@ public Set<String> getPlayers() {
return players; return players;
} }
@Override
public boolean contains(LocalPlayer player) { public boolean contains(LocalPlayer player) {
if (players.contains(player.getName().toLowerCase())) { if (contains(player.getName())) {
return true; return true;
} }
@ -84,6 +85,11 @@ public boolean contains(LocalPlayer player) {
return false; return false;
} }
@Override
public boolean contains(String playerName) {
return players.contains(playerName.toLowerCase());
}
public int size() { public int size() {
return groups.size() + players.size(); return groups.size() + players.size();
} }

View File

@ -9,5 +9,14 @@ public interface Domain {
* @param player The player to check * @param player The player to check
* @return whether this domain contains {@code player} * @return whether this domain contains {@code player}
*/ */
public boolean contains(LocalPlayer player); boolean contains(LocalPlayer player);
/**
* Returns true if a domain contains a player.<br />
* This method doesn't check for groups!
*
* @param playerName The name of the player to check
* @return whether this domain contains a player by that name
*/
boolean contains(String playerName);
} }

View File

@ -43,6 +43,7 @@ public int size() {
return domains.size(); return domains.size();
} }
@Override
public boolean contains(LocalPlayer player) { public boolean contains(LocalPlayer player) {
for (Domain domain : domains) { for (Domain domain : domains) {
if (domain.contains(player)) { if (domain.contains(player)) {
@ -53,4 +54,14 @@ public boolean contains(LocalPlayer player) {
return false; return false;
} }
@Override
public boolean contains(String playerName) {
for (Domain domain : domains) {
if (domain.contains(playerName)) {
return true;
}
}
return false;
}
} }

View File

@ -50,8 +50,12 @@ public boolean contains(LocalPlayer player) {
return false; return false;
} }
@Override
public boolean contains(String playerName) {
return false; // GroupDomains can't contain player names.
}
public int size() { public int size() {
return groups.size(); return groups.size();
} }
} }

View File

@ -44,11 +44,15 @@ public void addPlayer(String name) {
} }
public boolean contains(LocalPlayer player) { public boolean contains(LocalPlayer player) {
return players.contains(player.getName().toLowerCase()); return contains(player.getName());
}
@Override
public boolean contains(String playerName) {
return players.contains(playerName.toLowerCase());
} }
public int size() { public int size() {
return players.size(); return players.size();
} }
} }