Esempio n. 1
0
  public static PlayerDescriptor create(Player player, int[] tickets) {
    Direction firstDirection = player.getFirstDirection();
    Direction secondDirection = player.getSecondDirection();

    if (firstDirection == Direction.NONE) return new IdlePlayerDescriptor(player, tickets);
    else if (secondDirection == Direction.NONE) return new WalkPlayerDescriptor(player, tickets);
    else return new RunPlayerDescriptor(player, tickets);
  }
Esempio n. 2
0
  public void handle(Player player, int hash, int dyn, ExtendedOption option) {
    if (player.actionsBlocked()) {
      return;
    }
    int widgetId = Widget.getWidgetId(hash);
    int child = Widget.getComponentId(hash);
    System.out.println(
        "button - parent: "
            + widgetId
            + " "
            + ", child: "
            + child
            + ", dyn: "
            + dyn
            + ", option: "
            + option);

    // Check for correct interfaces open in the handler!
    WindowHandler wHandler = windowHandlers.get(widgetId);
    if (wHandler != null) {
      if (wHandler.handle(player, widgetId, child, option, dyn)) {
        return;
      }
    }
    // TODO convert all of these switched ones to the new WindowHandler
    switch (widgetId) {
      case 271:
        player.getPrayers().toggle(Prayer.forId(child));
        break;
      case 387:
        if (child == 55) {
          Equipment.showEquipmentInterface(player);
        }
        break;
      case 771:
        player.getAppearance().handle(child);
        break;
      default:

        /* Fetch the handler list for the specified hash */
        List<ButtonHandler> list = handlerLists.get(hash);

        /* Check if the list is valid */
        if (list == null) {
          return;
        }

        for (ButtonHandler handler : list) {

          /* If the handler option is equal to the option, handle it */
          if (handler.getOption() == option) {
            handler.handle(player, dyn);
          }
        }
        break;
    }
  }
 @Override
 public void itemsChanged(Inventory inventory) {
   if (inventory.isEmpty()) {
     // TODO: consider how this interacts with the 'type'?
     player.send(new InterfaceResetItemsMessage(id, child));
   } else {
     Item[] items = inventory.toArray();
     player.send(new InterfaceItemsMessage(id, child, type, items));
   }
 }
Esempio n. 4
0
 @Override
 public void handle(
     Player player,
     Inventory inventoryOne,
     Inventory inventoryTwo,
     SlottedItem itemOne,
     SlottedItem itemTwo) {
   if (inventoryOne != player.getInventory() || inventoryTwo != player.getInventory()) {
     return;
   }
   if (!recipe.getRequirements().hasRequirementsDisplayOne(player)) {
     return;
   }
   SlottedItem secondary = itemOne.getItem().getId() == PESTLE_AND_MORTAR ? itemTwo : itemOne;
   if (player.getInventory().getAmount(secondary.getItem().getId()) < 2) {
     player.startAction(new HerbloreAction(player, recipe, 1));
     return;
   }
   player.send(new InterfaceItemMessage(309, 2, 200, recipe.getProduct()));
   player.setInterfaceText(
       309, 6, "<br><br><br><br><br>" + ItemDefinitions.forId(recipe.getProduct()).getName());
   player.getInterfaceSet().openChatbox(309);
   player
       .getInterfaceSet()
       .getChatbox()
       .setListener(new HerbloreInterfaceListener(player, recipe));
 }
Esempio n. 5
0
 public AppearancePlayerBlock(Player player) {
   super(0x4);
   username = player.getUsername();
   hidden = player.isHidden();
   appearance = player.getAppearance();
   headIcon = player.getHeadIcon();
   equipment = new Inventory(player.getEquipment());
   stance = player.getStance();
   combat = player.getSkillSet().getCombatLevel();
   skill = player.getSkillSet().getTotalLevel();
   pnpc = player.getPNPC();
 }
Esempio n. 6
0
  public PlayerDescriptor(Player player, int[] tickets, boolean force) {
    if (player.isActive()) {
      /*
       * This active check is required for the RemovePlayerDescriptor. The player id would be
       * -1 in this case, which causes the following code to crash. Skipping this code doesn't
       * matter as no update blocks can be sent when removing a player.
       */
      int id = player.getId() - 1;
      int ticket = player.getAppearanceTicket();
      if (tickets[id] != ticket || force) {
        tickets[id] = ticket;
        addBlock(new AppearancePlayerBlock(player));
      }
    }

    if (player.isChatUpdated()) addBlock(new ChatPlayerBlock(player));

    if (player.isHitOneUpdated()) addBlock(new HitOnePlayerBlock(player));

    if (player.isHitTwoUpdated()) addBlock(new HitTwoPlayerBlock(player));

    if (player.isChatForced()) addBlock(new ForceChatPlayerBlock(player));

    if (player.isAnimationUpdated()) addBlock(new AnimationPlayerBlock(player));

    if (player.isSpotAnimationUpdated()) addBlock(new SpotAnimationPlayerBlock(player));

    if (player.isTurnToPositionUpdated()) addBlock(new TurnToPositionPlayerBlock(player));

    if (player.isTurnToTargetUpdated()) addBlock(new TurnToMobPlayerBlock(player));

    // addBlock(new ForceMovementPlayerBlock(player));

  }
Esempio n. 7
0
 @Override
 public void handle(Player player, Player selectedPlayer) {
   player.startAction(new TradeRequestAction(player, selectedPlayer));
 }
Esempio n. 8
0
 public TurnToMobPlayerBlock(Player player) {
   super(0x2);
   turnToTarget = player.getTurnToTargetId();
 }
 @Override
 public void itemChanged(Inventory inventory, int slot, Item item) {
   SlottedItem[] items = new SlottedItem[] {new SlottedItem(slot, item)};
   player.send(new InterfaceSlottedItemsMessage(id, child, type, items));
 }