/**
  * Retrieves an open height level by sifting through the mapping and attempting to retrieve the
  * lowest height level.
  *
  * @return the next lowest, open height level will be returned otherwise -1 will be returned. When
  *     -1 is returned it signifies that there are no heights open from 0 to {@link
  *     MAXIMUM_HEIGHT}.
  */
 public int getNextOpenHeight(Boundary boundary) {
   for (int height = 0; height < MAXIMUM_HEIGHT; height += 4) {
     if (active.containsKey(height)) {
       continue;
     }
     final int heightLevel = height;
     if (PlayerHandler.getPlayers()
         .stream()
         .anyMatch(p -> Boundary.isIn(p, boundary) && p.heightLevel == heightLevel)) {
       continue;
     }
     return height;
   }
   return -1;
 }
示例#2
0
 /**
  * Updates a single global object with a new object id in the game world for every player within a
  * region.
  *
  * @param object the new global object
  * @param objectId the new object id
  */
 public void updateObject(final GlobalObject object, final int objectId) {
   List<Player> players =
       PlayerHandler.getPlayers()
           .stream()
           .filter(Objects::nonNull)
           .filter(
               player ->
                   player.distanceToPoint(object.getX(), object.getY()) <= 60
                       && player.heightLevel == object.getHeight())
           .collect(Collectors.toList());
   players.forEach(
       player ->
           player
               .getPA()
               .object(
                   objectId, object.getX(), object.getY(), object.getFace(), object.getType()));
 }