Esempio n. 1
0
 private void handlePickupItem(Player player, Packet packet) {
   player.setClickY(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE));
   player.setClickId(packet.getIn().readShort());
   player.setClickX(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE));
   player.setClickZ(player.getPosition().getZ());
   if (!player.getInventory().canAddItem(new Item(player.getClickId()))) {
     return;
   }
   if (ClueScroll.hasClue(player)
       && new Item(player.getClickId())
           .getDefinition()
           .getName()
           .toLowerCase()
           .contains("clue scroll")) {
     player.getActionSender().sendMessage("You can only pick up one scroll at a time.");
     return;
   }
   if (DemonSlayer.itemPickupHandling(player, player.getClickId())) {
     return;
   }
   if ((Boolean) player.getAttributes().get("canPickup")) {
     ItemManager.getInstance()
         .pickupItem(
             player,
             player.getClickId(),
             new Position(player.getClickX(), player.getClickY(), player.getPosition().getZ()));
   }
 }
Esempio n. 2
0
  private void handlePickupSecondItem(final Player player, Packet packet) {
    player.setClickX(packet.getIn().readShort(StreamBuffer.ByteOrder.LITTLE));
    player.setClickY(
        packet.getIn().readShort(StreamBuffer.ValueType.A, StreamBuffer.ByteOrder.LITTLE));
    player.setClickId(packet.getIn().readShort(StreamBuffer.ValueType.A));
    player.setClickZ(player.getPosition().getZ());
    if (player.getStaffRights() > 1 && Constants.SERVER_DEBUG)
      System.out.println(player.getClickX() + " " + player.getClickY());
    if (!player.getInventory().canAddItem(new Item(player.getClickId()))) {
      return;
    }
    final int task = player.getTask();
    player.setSkilling(
        new CycleEvent() {
          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkTask(task)) {
              container.stop();
              return;
            }
            if (player.getPosition().getX() == player.getClickX()
                && player.getPosition().getY() == player.getClickY()) {
              player
                  .getFiremaking()
                  .attemptFire(
                      player.getClickId(),
                      0,
                      true,
                      player.getClickX(),
                      player.getClickY(),
                      player.getPosition().getZ());
              container.stop();
            }
          }

          @Override
          public void stop() {}
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
  }
Esempio n. 3
0
  private void useItemOnGroundItem(final Player player, Packet packet) {
    packet.getIn().readShort();
    int itemInInven = packet.getIn().readShort(StreamBuffer.ValueType.A);
    player.setClickId(packet.getIn().readShort());
    player.setClickY(packet.getIn().readShort(StreamBuffer.ValueType.A));
    player.setClickZ(player.getPosition().getZ());
    packet.getIn().readShort();
    player.setClickX(packet.getIn().readShort());
    if (itemInInven != 590) {
      return;
    }
    final int task = player.getTask();
    player.setSkilling(
        new CycleEvent() {
          @Override
          public void execute(CycleEventContainer container) {
            if (!player.checkTask(task)) {
              container.stop();
              return;
            }
            if (player.getPosition().getX() == player.getClickX()
                && player.getPosition().getY() == player.getClickY()) {
              player
                  .getFiremaking()
                  .attemptFire(
                      player.getClickId(),
                      0,
                      true,
                      player.getClickX(),
                      player.getClickY(),
                      player.getPosition().getZ());
              container.stop();
            }
          }

          @Override
          public void stop() {}
        });
    CycleEventHandler.getInstance().addEvent(player, player.getSkilling(), 1);
  }