public void copy() { while (type.queue.get(ch).size() > 0 && ChannelServer.getInstance(ch).getMapleSquad(type) == null) { int index = 0; long lowest = 0; for (int i = 0; i < type.queue.get(ch).size(); i++) { if (lowest == 0 || type.queue.get(ch).get(i).right < lowest) { index = i; lowest = type.queue.get(ch).get(i).right; } } final String nextPlayerId = type.queue.get(ch).remove(index).left; final int theirCh = World.Find.findChannel(nextPlayerId); if (theirCh > 0) { final MapleCharacter lead = ChannelServer.getInstance(theirCh).getPlayerStorage().getCharacterByName(nextPlayerId); if (lead != null && lead.getMapId() == beginMapId && lead.getClient().getChannel() == ch) { final MapleSquad squad = new MapleSquad(ch, type.name(), lead, expiration, toSay); if (ChannelServer.getInstance(ch).addMapleSquad(squad, type.name())) { getBeginMap().broadcastMessage(CField.getClock(expiration / 1000)); getBeginMap().broadcastMessage(CWvsContext.serverNotice(6, nextPlayerId + toSay)); type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Success")); } else { squad.clear(); type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Skipped")); } break; } else { if (lead != null) { lead.dropMessage( 6, "Your squad has been skipped due to you not being in the right channel and map."); } getBeginMap() .broadcastMessage( CWvsContext.serverNotice( 6, nextPlayerId + "'s squad has been skipped due to the player not being in the right channel and map.")); type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not in map")); } } else { getBeginMap() .broadcastMessage( CWvsContext.serverNotice( 6, nextPlayerId + "'s squad has been skipped due to the player not being online.")); type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not online")); } } }
public MapleSquad( final int ch, final String type, final MapleCharacter leader, final int expiration, final String toSay) { this.leader = new WeakReference<MapleCharacter>(leader); this.members.put(leader.getName(), MapleCarnivalChallenge.getJobBasicNameById(leader.getJob())); this.leaderName = leader.getName(); this.ch = ch; this.toSay = toSay; this.type = MapleSquadType.valueOf(type.toLowerCase()); this.status = 1; this.beginMapId = leader.getMapId(); leader.getMap().setSquad(this.type); if (this.type.queue.get(ch) == null) { this.type.queue.put(ch, new ArrayList<Pair<String, Long>>()); this.type.queuedPlayers.put(ch, new ArrayList<Pair<String, String>>()); } this.startTime = System.currentTimeMillis(); this.expiration = expiration; }