@Override public synchronized boolean add(QueueObject to) { if (to == null) return false; playerSize += to.getNumPlayers(); teamSize += to.getTeams().size(); return super.add(to); }
public synchronized Collection<ArenaTeam> getTeams() { List<ArenaTeam> teams = new ArrayList<ArenaTeam>(); for (QueueObject team : this) { teams.addAll(team.getTeams()); } return teams; }
public synchronized int indexOf(ArenaPlayer p) { int i = 0; for (QueueObject t : this) { if (t.hasMember(p)) return i; i++; } return -1; }
@Override public int compare(QueueObject arg0, QueueObject arg1) { Integer p1 = arg0.getPriority(); Integer p2 = arg1.getPriority(); int c = p1.compareTo(p2); if (c != 0) return c; return new Long(arg0.getJoinTime()).compareTo(arg1.getJoinTime()); }
public synchronized Collection<ArenaPlayer> getArenaPlayers() { List<ArenaPlayer> players = new ArrayList<ArenaPlayer>(); for (QueueObject qo : this) { for (ArenaTeam t : qo.getTeams()) { players.addAll(t.getPlayers()); } } return players; }
public synchronized JoinResult getPos(ArenaPlayer p) { int i = 0; for (QueueObject t : this) { if (t.hasMember(p)) return new JoinResult(null, getMatchParams(), i, playerSize(), t.getTeam(p), this.size()); i++; } return null; }
@Override public boolean remove(QueueObject queueObject) { if (super.remove(queueObject)) { playerSize -= queueObject.getNumPlayers(); teamSize -= queueObject.getTeams().size(); return true; } return false; }
public synchronized ArenaTeam remove(ArenaTeam team) { Iterator<QueueObject> iter = this.iterator(); while (iter.hasNext()) { QueueObject qo = iter.next(); if (qo.hasTeam(team)) { iter.remove(); playerSize -= qo.getNumPlayers(); teamSize -= qo.getTeams().size(); return team; } } return null; }
public synchronized ArenaTeam remove(ArenaPlayer p) { Iterator<QueueObject> iter = this.iterator(); while (iter.hasNext()) { QueueObject qo = iter.next(); if (qo.hasMember(p)) { iter.remove(); playerSize--; teamSize -= qo.getTeams().size(); return qo.getTeam(p); } } return null; }
public synchronized boolean contains(ArenaPlayer p) { for (QueueObject t : this) { if (t.hasMember(p)) return true; } return false; }
public synchronized boolean contains(ArenaTeam team) { for (QueueObject qo : this) { if (qo.hasTeam(team)) return true; } return false; }