Exemple #1
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;
    }
  }
 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();
 }