/**
  * Used for spawning objects that cannot be inserted into the file
  *
  * @param player the player
  */
 private void loadCustomObjects(Player player) {
   player.getFarming().updateObjects();
   if (HolidayController.CHRISTMAS.isActive()) {
     player.getPA().checkObjectSpawn(0, 3083, 3500, 0, 10);
     player.getPA().checkObjectSpawn(10676, 2950, 3824, 0, 10);
     player.getPA().checkObjectSpawn(10676, 2952, 3822, 1, 10);
     player.getPA().checkObjectSpawn(10676, 2949, 3822, 1, 10);
     player.getPA().checkObjectSpawn(10676, 2959, 3704, 0, 10);
     player.getPA().checkObjectSpawn(10676, 2960, 3701, 2, 10);
     player.getPA().checkObjectSpawn(10660, 3083, 3499, 0, 10);
     player.getPA().checkObjectSpawn(2147, 2957, 3704, 0, 10);
     player.getPA().checkObjectSpawn(2147, 2952, 3821, 0, 10);
     player.getPA().checkObjectSpawn(473, 2953, 3821, 0, 10);
     player.getPA().checkObjectSpawn(-1, 2977, 3634, 0, 10);
     player.getPA().checkObjectSpawn(-1, 2979, 3642, 0, 10);
   }
   if (HolidayController.HALLOWEEN.isActive()) {
     player.getPA().checkObjectSpawn(10084, 3088, 3497, 0, 10);
     player.getPA().checkObjectSpawn(10084, 3085, 3496, 1, 10);
     player.getPA().checkObjectSpawn(10084, 3085, 3493, 1, 10);
     player.getPA().checkObjectSpawn(2715, 3088, 3494, 1, 10);
     player.getPA().checkObjectSpawn(0, 3088, 3496, 0, 10);
     player.getPA().checkObjectSpawn(0, 3089, 3496, 0, 10);
     player.getPA().checkObjectSpawn(0, 3088, 3495, 0, 10);
     player.getPA().checkObjectSpawn(0, 3089, 3495, 0, 10);
   }
 }
 public static void resetPrayers(Player c) {
   for (int i = 0; i < c.prayerActive.length; i++) {
     c.prayerActive[i] = false;
     c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
   }
   c.headIcon = -1;
   c.getPA().requestUpdates();
 }
  @Override
  public void processPacket(final Player c, int packetType, int packetSize) {
    c.walkingToItem = false;
    c.pItemY = c.getInStream().readSignedWordBigEndian();
    c.pItemId = c.getInStream().readUnsignedWord();
    c.pItemX = c.getInStream().readSignedWordBigEndian();
    if (Math.abs(c.getX() - c.pItemX) > 25 || Math.abs(c.getY() - c.pItemY) > 25) {
      c.resetWalkingQueue();
      return;
    }
    DuelSession duelSession =
        (DuelSession)
            Server.getMultiplayerSessionListener()
                .getMultiplayerSession(c, MultiplayerSessionType.DUEL);
    if (Objects.nonNull(duelSession)
        && duelSession.getStage().getStage() > MultiplayerSessionStage.REQUEST
        && duelSession.getStage().getStage() < MultiplayerSessionStage.FURTHER_INTERACTION) {
      c.sendMessage("Your actions have declined the duel.");
      duelSession.getOther(c).sendMessage("The challenger has declined the duel.");
      duelSession.finish(MultiplayerSessionFinalizeType.WITHDRAW_ITEMS);
      return;
    }
    if (c.getInterfaceEvent().isActive()) {
      c.sendMessage("Please finish what you're doing.");
      return;
    }
    if (c.getPA().viewingOtherBank) {
      c.getPA().resetOtherBank();
    }
    c.getCombat().resetPlayerAttack();
    if (c.getX() == c.pItemX && c.getY() == c.pItemY) {
      Server.itemHandler.removeGroundItem(c, c.pItemId, c.pItemX, c.pItemY, c.heightLevel, true);
    } else {
      c.walkingToItem = true;
      CycleEventHandler.getSingleton()
          .addEvent(
              c,
              new CycleEvent() {
                @Override
                public void execute(CycleEventContainer container) {
                  if (!c.walkingToItem) container.stop();
                  if (c.getX() == c.pItemX && c.getY() == c.pItemY) {
                    Server.itemHandler.removeGroundItem(
                        c, c.pItemId, c.pItemX, c.pItemY, c.heightLevel, true);
                    container.stop();
                  }
                }

                @Override
                public void stop() {
                  c.walkingToItem = false;
                }
              },
              1);
    }
  }
 @Override
 public void execute(Player c, String input) {
   if (c.inTrade || c.inDuel || c.inWild()) {
     return;
   }
   c.getPA().startTeleport(3366, 9640, 0, "modern");
 }
 public static void reducePrayerLevel(Player c) {
   if (c.playerLevel[5] - 1 > 0) {
     c.playerLevel[5] -= 1;
   } else {
     c.sendMessage("You have run out of prayer points!");
     c.playerLevel[5] = 0;
     resetPrayers(c);
     c.prayerId = -1;
   }
   c.getPA().refreshSkill(5);
 }
 /**
  * Updates all region objects for a specific player
  *
  * @param player the player were updating all objects for
  */
 public void updateRegionObjects(Player player) {
   objects
       .stream()
       .filter(Objects::nonNull)
       .filter(
           object ->
               player.distanceToPoint(object.getX(), object.getY()) <= 60
                   && object.getHeight() == player.heightLevel)
       .forEach(
           object ->
               player
                   .getPA()
                   .object(
                       object.getObjectId(),
                       object.getX(),
                       object.getY(),
                       object.getFace(),
                       object.getType()));
   loadCustomObjects(player);
 }
  public static void activatePrayer(Player c, int i) {
    if (Server.getMultiplayerSessionListener().inSession(c, MultiplayerSessionType.TRADE)) {
      c.sendMessage("You cannot activate prayers whilst trading!");
      return;
    }
    if (Boundary.isIn(c, Boundary.DUEL_ARENAS)) {
      DuelSession session =
          (DuelSession)
              Server.getMultiplayerSessionListener()
                  .getMultiplayerSession(c, MultiplayerSessionType.DUEL);
      if (Objects.nonNull(session)) {
        if (session.getRules().contains(Rule.NO_PRAYER)) {
          c.sendMessage("Prayer has been disabled for this duel.");
          resetPrayers(c);
          return;
        }
      }
    }
    DuelSession duelSession =
        (DuelSession)
            Server.getMultiplayerSessionListener()
                .getMultiplayerSession(c, MultiplayerSessionType.DUEL);
    if (Objects.nonNull(duelSession)
        && duelSession.getStage().getStage() > MultiplayerSessionStage.REQUEST
        && duelSession.getStage().getStage() < MultiplayerSessionStage.FURTHER_INTERACTION) {
      c.sendMessage("You have declined the duel.");
      duelSession.getOther(c).sendMessage("The challenger has declined the duel.");
      duelSession.finish(MultiplayerSessionFinalizeType.WITHDRAW_ITEMS);
      return;
    }
    if (c.isDead || c.playerLevel[3] <= 0) {
      return;
    }
    if (c.clanWarRule[3]) {
      c.sendMessage("You are not allowed to use prayer during this war!");
      resetPrayers(c);
      return;
    }
    int[] defPray = {0, 5, 13, 24, 25};
    int[] strPray = {1, 6, 14, 24, 25};
    int[] atkPray = {2, 7, 15, 24, 25};
    int[] rangePray = {3, 11, 19};
    int[] magePray = {4, 12, 20};

    if (c.playerLevel[5] > 0 || !Config.PRAYER_POINTS_REQUIRED) {
      if (c.getPA().getLevelForXP(c.playerXP[5]) >= c.PRAYER_LEVEL_REQUIRED[i]
          || !Config.PRAYER_LEVEL_REQUIRED) {
        boolean headIcon = false;
        switch (i) {
          case 0:
          case 5:
          case 13:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < defPray.length; j++) {
                if (defPray[j] != i) {
                  c.prayerActive[defPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[defPray[j]], 0);
                }
              }
            }
            break;
          case 1:
          case 6:
          case 14:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < strPray.length; j++) {
                if (strPray[j] != i) {
                  c.prayerActive[strPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[strPray[j]], 0);
                }
              }
              for (int j = 0; j < rangePray.length; j++) {
                if (rangePray[j] != i) {
                  c.prayerActive[rangePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[rangePray[j]], 0);
                }
              }
              for (int j = 0; j < magePray.length; j++) {
                if (magePray[j] != i) {
                  c.prayerActive[magePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[magePray[j]], 0);
                }
              }
            }
            break;

          case 2:
          case 7:
          case 15:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < atkPray.length; j++) {
                if (atkPray[j] != i) {
                  c.prayerActive[atkPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[atkPray[j]], 0);
                }
              }
              for (int j = 0; j < rangePray.length; j++) {
                if (rangePray[j] != i) {
                  c.prayerActive[rangePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[rangePray[j]], 0);
                }
              }
              for (int j = 0; j < magePray.length; j++) {
                if (magePray[j] != i) {
                  c.prayerActive[magePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[magePray[j]], 0);
                }
              }
            }
            break;

          case 3: // range prays
          case 11:
          case 19:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < atkPray.length; j++) {
                if (atkPray[j] != i) {
                  c.prayerActive[atkPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[atkPray[j]], 0);
                }
              }
              for (int j = 0; j < strPray.length; j++) {
                if (strPray[j] != i) {
                  c.prayerActive[strPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[strPray[j]], 0);
                }
              }
              for (int j = 0; j < rangePray.length; j++) {
                if (rangePray[j] != i) {
                  c.prayerActive[rangePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[rangePray[j]], 0);
                }
              }
              for (int j = 0; j < magePray.length; j++) {
                if (magePray[j] != i) {
                  c.prayerActive[magePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[magePray[j]], 0);
                }
              }
            }
            break;
          case 4:
          case 12:
          case 20:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < atkPray.length; j++) {
                if (atkPray[j] != i) {
                  c.prayerActive[atkPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[atkPray[j]], 0);
                }
              }
              for (int j = 0; j < strPray.length; j++) {
                if (strPray[j] != i) {
                  c.prayerActive[strPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[strPray[j]], 0);
                }
              }
              for (int j = 0; j < rangePray.length; j++) {
                if (rangePray[j] != i) {
                  c.prayerActive[rangePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[rangePray[j]], 0);
                }
              }
              for (int j = 0; j < magePray.length; j++) {
                if (magePray[j] != i) {
                  c.prayerActive[magePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[magePray[j]], 0);
                }
              }
            }
            break;
          case 10:
            c.lastProtItem.reset();
            c.protectItem = !c.protectItem;
            break;

          case 16:
          case 17:
          case 18:
            if (System.currentTimeMillis() - c.stopPrayerDelay < 5000) {
              c.sendMessage("You have been injured and can't use this prayer!");
              c.getPA().sendFrame36(c.PRAYER_GLOW[16], 0);
              c.getPA().sendFrame36(c.PRAYER_GLOW[17], 0);
              c.getPA().sendFrame36(c.PRAYER_GLOW[18], 0);
              return;
            }
            if (i == 16) c.protMageDelay = System.currentTimeMillis();
            else if (i == 17) c.protRangeDelay = System.currentTimeMillis();
            else if (i == 18) c.protMeleeDelay = System.currentTimeMillis();
          case 21:
          case 22:
          case 23:
            headIcon = true;
            for (int p = 16; p < 24; p++) {
              if (i != p && p != 19 && p != 20) {
                c.prayerActive[p] = false;
                c.getPA().sendFrame36(c.PRAYER_GLOW[p], 0);
              }
            }
            break;
          case 24:
          case 25:
            if (c.prayerActive[i] == false) {
              for (int j = 0; j < atkPray.length; j++) {
                if (atkPray[j] != i) {
                  c.prayerActive[atkPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[atkPray[j]], 0);
                }
              }
              for (int j = 0; j < strPray.length; j++) {
                if (strPray[j] != i) {
                  c.prayerActive[strPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[strPray[j]], 0);
                }
              }
              for (int j = 0; j < rangePray.length; j++) {
                if (rangePray[j] != i) {
                  c.prayerActive[rangePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[rangePray[j]], 0);
                }
              }
              for (int j = 0; j < magePray.length; j++) {
                if (magePray[j] != i) {
                  c.prayerActive[magePray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[magePray[j]], 0);
                }
              }
              for (int j = 0; j < defPray.length; j++) {
                if (defPray[j] != i) {
                  c.prayerActive[defPray[j]] = false;
                  c.getPA().sendFrame36(c.PRAYER_GLOW[defPray[j]], 0);
                }
              }
            }
            break;
        }

        if (!headIcon) {
          if (c.prayerActive[i] == false) {
            c.prayerActive[i] = true;
            c.getPA().sendFrame36(c.PRAYER_GLOW[i], 1);
          } else {
            c.prayerActive[i] = false;
            c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
          }
        } else {
          if (c.prayerActive[i] == false) {
            c.prayerActive[i] = true;
            c.getPA().sendFrame36(c.PRAYER_GLOW[i], 1);
            c.headIcon = c.PRAYER_HEAD_ICONS[i];
            c.getPA().requestUpdates();
          } else {
            c.prayerActive[i] = false;
            c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
            c.headIcon = -1;
            c.getPA().requestUpdates();
          }
        }
      } else {
        c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
        c.getPA()
            .sendFrame126(
                "You need a @blu@Prayer level of "
                    + c.PRAYER_LEVEL_REQUIRED[i]
                    + " to use "
                    + c.PRAYER_NAME[i]
                    + ".",
                357);
        c.getPA().sendFrame126("Click here to continue", 358);
        c.getPA().sendFrame164(356);
      }
    } else {
      c.getPA().sendFrame36(c.PRAYER_GLOW[i], 0);
      c.sendMessage("You have run out of prayer points!");
    }
  }