예제 #1
0
 @Override
 public void execute(Player c, String input) {
   if (c.inTrade || c.inDuel || c.inWild()) {
     return;
   }
   c.getPA().startTeleport(3366, 9640, 0, "modern");
 }
예제 #2
0
 /**
  * Spawns a randomized rare item based solely upon the active holiday event.
  *
  * @param player
  */
 public static void spawnRare(Player player) {
   if (!Server.getHolidayController().HALLOWEEN.isActive()
       && !HolidayController.CHRISTMAS.isActive()) {
     player.sendMessage("You may only spawn a rare whilst a holiday event is active!");
     return;
   }
   if (!player.lastRare.elapsed(60000)) {
     player.sendMessage(
         "You must wait "
             + (60 - (player.lastRare.elapsedTime()) / 1000)
             + " seconds before spawning another rare!");
     return;
   }
   itemName =
       (HolidayController.HALLOWEEN.isActive()
           ? HALLOWEEN_ITEMS[Misc.random(HALLOWEEN_ITEMS.length - 1)]
           : CHRISTMAS_ITEMS[Misc.random(CHRISTMAS_ITEMS.length - 1)]);
   randomItem = player.getItems().getItemId(itemName);
   Server.itemHandler.createGroundItem(
       player,
       randomItem,
       player.absX + Misc.random(2),
       player.absY + Misc.random(2),
       player.heightLevel,
       1,
       player.getId());
   player.lastRare.reset();
 }
예제 #3
0
 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();
 }
예제 #4
0
 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);
 }
예제 #5
0
 public static void handlePrayerDrain(Player c) {
   c.usingPrayer = false;
   double toRemove = 0.0;
   if (c.isDead || c.playerLevel[3] <= 0) return;
   for (int j = 0; j < prayerData.length; j++) {
     if (c.prayerActive[j]) {
       toRemove += prayerData[j] / 20;
       c.usingPrayer = true;
     }
   }
   if (toRemove > 0) {
     toRemove /= (1 + (0.035 * c.playerBonus[11]));
   }
   c.prayerPoint -= toRemove;
   if (c.prayerPoint <= 0) {
     c.prayerPoint = 1.0 + c.prayerPoint;
     reducePrayerLevel(c);
   }
 }
예제 #6
0
 /**
  * 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);
 }
예제 #7
0
  @Override
  public void execute(Player c, String input) {
    try {
      String[] args = input.split("-");
      if (args.length != 3) {
        throw new IllegalArgumentException();
      }
      String name = args[0];
      int duration = Integer.parseInt(args[1]);
      long jailEnd = 0;
      if (duration == 0) {
        jailEnd = Long.MAX_VALUE;
      } else {
        jailEnd = System.currentTimeMillis() + duration * 1000 * 60;
      }
      String reason = args[2];

      Optional<Player> optionalPlayer = PlayerHandler.getOptionalPlayer(name);
      if (optionalPlayer.isPresent()) {
        Player c2 = optionalPlayer.get();
        if (Server.getMultiplayerSessionListener().inAnySession(c)) {
          c.sendMessage("The player is in a trade, or duel. You cannot do this at this time.");
          return;
        }
        c2.teleportToX = 2095;
        c2.teleportToY = 4428;
        c2.jailEnd = jailEnd;
        if (duration == 0) {
          c2.sendMessage("@red@You have been permanently jailed by " + c.playerName + " .");
          c.sendMessage("Permanently jailed " + c2.playerName + ".");
          new PunishmentHandler().punishOnlinePlayer(c2, c, "Jail (Permanent)", reason);

        } else {
          c2.sendMessage(
              "@red@You have been jailed by " + c.playerName + " for " + duration + " minutes.");
          c2.sendMessage("@red@Type ::unjail after having served your time to be unjailed.");
          c.sendMessage("Successfully jailed " + c2.playerName + " for " + duration + " minutes.");
          new PunishmentHandler().punishOnlinePlayer(c2, c, "Jail (" + duration + ")", reason);
        }
      } else {
        c.sendMessage(name + " is not online. You can only jail online players.");
      }
    } catch (Exception e) {
      c.sendMessage("Error. Correct syntax: ::jail-player-duration-reason");
    }
  }
예제 #8
0
  @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);
    }
  }
예제 #9
0
  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!");
    }
  }
예제 #10
0
 /**
  * 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);
   }
 }