Beispiel #1
0
 /** Adds players awaiting login to the world. */
 public void dequeueLogins() {
   for (int amount = 0; amount < EntityConstants.LOGIN_THRESHOLD; amount++) {
     Player player = logins.poll();
     if (player == null) {
       break;
     }
     playerList.add(player);
   }
 }
Beispiel #2
0
 /** Removes players awaiting logout from the world. */
 public void dequeueLogouts() {
   for (int amount = 0; amount < EntityConstants.LOGOUT_THRESHOLD; amount++) {
     Player player = logouts.poll();
     if (player == null) {
       break;
     }
     /* TODO: Anti x-logging. */
     playerList.remove(player);
   }
 }
Beispiel #3
0
 /** Retrieves a player by their username. */
 public Optional<Player> getPlayer(String username) {
   return playerList.findFirst(player -> player.getUsername().equals(username));
 }
Beispiel #4
0
 /** Retrieves a player by their username hash. Faster than {@code getPlayer(String)}. */
 public Optional<Player> getPlayer(long username) {
   return playerList.findFirst(player -> player.getUsernameHash() == username);
 }