Ejemplo n.º 1
0
  @Override
  protected void handleDespawned() {
    KiskService.getInstance().removeKisk(getOwner());
    if (!isAlreadyDead()) {
      getOwner().broadcastPacket(SM_SYSTEM_MESSAGE.STR_BINDSTONE_IS_REMOVED);
    }

    super.handleDespawned();
  }
  /** {@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.
    }
  }