Пример #1
0
  /**
   * Shows Question window and expands on positive response
   *
   * @param player
   * @param npc
   */
  public static void expandCube(final Player player, Npc npc) {
    final CubeExpandTemplate expandTemplate =
        DataManager.CUBEEXPANDER_DATA.getCubeExpandListTemplate(npc.getNpcId());

    if (expandTemplate == null) {
      log.error("Cube Expand Template could not be found for Npc ID: " + npc.getObjectId());
      return;
    }

    if (npcCanExpandLevel(expandTemplate, player.getCubeSize() + 1)
        && validateNewSize(player.getCubeSize() + 1)) {
      /** Check if our player can pay the cubic expand price */
      final int price = getPriceByLevel(expandTemplate, player.getCubeSize() + 1);

      RequestResponseHandler responseHandler =
          new RequestResponseHandler(npc) {
            @Override
            public void acceptRequest(StaticNpc requester, Player responder) {
              if (!ItemService.decreaseKinah(responder, price)) {
                PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.CUBEEXPAND_NOT_ENOUGH_KINAH);
                return;
              }
              expand(responder);
            }

            @Override
            public void denyRequest(StaticNpc requester, Player responder) {
              // nothing to do
            }
          };

      boolean result =
          player
              .getResponseRequester()
              .putRequest(SM_QUESTION_WINDOW.STR_WAREHOUSE_EXPAND_WARNING, responseHandler);
      if (result) {
        PacketSendUtility.sendPacket(
            player,
            new SM_QUESTION_WINDOW(
                SM_QUESTION_WINDOW.STR_WAREHOUSE_EXPAND_WARNING, 0, String.valueOf(price)));
      }
    } else PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300430));
  }
  /** {@inheritDoc} */
  @Override
  protected void runImpl() {
    AionConnection client = getConnection();
    Account account = client.getAccount();
    PlayerAccountData playerAccData = client.getAccount().getPlayerAccountData(objectId);

    if (playerAccData == null) {
      // Somebody wanted to login on character that is not at his account
      return;
    }

    Player player = PlayerService.getPlayer(objectId, account);

    if (player != null && client.setActivePlayer(player)) {
      player.setClientConnection(client);
      /*
       * Store player into World.
       */
      World.getInstance().storeObject(player);

      sendPacket(new SM_SKILL_LIST(player));
      StigmaService.onPlayerLogin(player);

      if (player.getSkillCoolDowns() != null)
        sendPacket(new SM_SKILL_COOLDOWN(player.getSkillCoolDowns()));

      if (player.getItemCoolDowns() != null)
        sendPacket(new SM_ITEM_COOLDOWN(player.getItemCoolDowns()));

      sendPacket(new SM_QUEST_LIST(player));
      sendPacket(new SM_RECIPE_LIST(player.getRecipeList().getRecipeList()));

      /*
       * Needed
       */
      sendPacket(new SM_ENTER_WORLD_CHECK());

      byte[] uiSettings = player.getPlayerSettings().getUiSettings();
      byte[] shortcuts = player.getPlayerSettings().getShortcuts();

      if (uiSettings != null) sendPacket(new SM_UI_SETTINGS(uiSettings, 0));

      if (shortcuts != null) sendPacket(new SM_UI_SETTINGS(shortcuts, 1));

      // Cubesize limit set in inventory.
      int cubeSize = player.getCubeSize();
      player.getInventory().setLimit(27 + cubeSize * 9);

      // items
      Storage inventory = player.getInventory();
      List<Item> equipedItems = player.getEquipment().getEquippedItems();
      if (equipedItems.size() != 0) {
        sendPacket(new SM_INVENTORY_INFO(player.getEquipment().getEquippedItems(), cubeSize));
      }

      List<Item> unequipedItems = inventory.getAllItems();
      int itemsSize = unequipedItems.size();

      if (itemsSize != 0) {
        int index = 0;
        while (index + 10 < itemsSize) {
          sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, index + 10), cubeSize));
          index += 10;
        }
        sendPacket(new SM_INVENTORY_INFO(unequipedItems.subList(index, itemsSize), cubeSize));
      }

      sendPacket(new SM_INVENTORY_INFO());

      PlayerService.playerLoggedIn(player);

      sendPacket(new SM_STATS_INFO(player));
      sendPacket(new SM_CUBE_UPDATE(player, 6));

      KiskService.onLogin(player);
      TeleportService.sendSetBindPoint(player);

      sendPacket(new SM_MACRO_LIST(player));
      sendPacket(new SM_GAME_TIME());
      player.getController().updateNearbyQuests();

      sendPacket(new SM_TITLE_LIST(player));
      sendPacket(new SM_CHANNEL_INFO(player.getPosition()));
      sendPacket(new SM_PLAYER_SPAWN(player));
      sendPacket(new SM_EMOTION_LIST());
      sendPacket(new SM_INFLUENCE_RATIO());
      sendPacket(new SM_PRICES(player.getPrices()));
      sendPacket(new SM_PLAYER_ID(player));
      sendPacket(new SM_ABYSS_RANK(player.getAbyssRank()));

      sendPacket(
          new SM_MESSAGE(
              0,
              null,
              "Welcome to "
                  + GSConfig.SERVER_NAME
                  + " server\nPowered by aion-unique software\ndeveloped by www.aion-unique.org team.\nCopyright 2010",
              ChatType.ANNOUNCEMENTS));

      if (player.isInPrison()) PunishmentService.updatePrisonStatus(player);

      if (player.isLegionMember()) LegionService.getInstance().onLogin(player);

      if (player.isInGroup()) GroupService.getInstance().onLogin(player);

      player.setRates(Rates.getRatesFor(client.getAccount().getMembership()));

      ClassChangeService.showClassChangeDialog(player);

      /** Notify mail service to load all mails */
      MailService.getInstance().onPlayerLogin(player);
      /** Schedule periodic saving of this player */
      PeriodicSaveService.getInstance().onPlayerLogin(player);
      /** Notify player if have broker settled items */
      BrokerService.getInstance().onPlayerLogin(player);
      /** Start initializing chat connection(/1, /2, /3, /4 channels) */
      if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogin(player);
    } else {
      // TODO this is an client error - inform client.
    }
  }
Пример #3
0
 /**
  * Expands the cubes
  *
  * @param player
  */
 public static void expand(Player player) {
   if (!validateNewSize(player.getCubeSize() + 1)) return;
   PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300431, "9")); // 9 Slots added
   player.setCubesize(player.getCubeSize() + 1);
   PacketSendUtility.sendPacket(player, new SM_CUBE_UPDATE(player, 0));
 }