Пример #1
0
  public void addOrUpdatePlayer(BBPlayerInfo pi) {
    // Update cache
    if (pi.getID() != -1)
      if (knownPlayers.containsKey(pi.getID())) {
        pi = knownPlayers.get(pi.getID());
        knownPlayers.remove(pi.getID());
      }

    do_addOrUpdatePlayer(pi);
    knownPlayers.put(pi.getID(), pi);
    knownNames.put(pi.getName(), pi.getID());
  }
Пример #2
0
  public void addOrUpdateUser(final Player p) {
    final String name = p.getName();

    BBPlayerInfo pi = null;
    // Check cache first.
    if (knownNames.containsKey(name)) {
      final int id = knownNames.get(name);
      pi = knownPlayers.get(id);
      knownPlayers.remove(id);
      knownNames.remove(name);
      pi.setNew(false); // If we're getting it from cache, it ain't new.
    } else {
      pi = new BBPlayerInfo(name);
    }

    do_addOrUpdatePlayer(pi);
    pi.refresh();
    knownPlayers.put(pi.getID(), pi);
    knownNames.put(name, pi.getID());
  }