コード例 #1
0
  /**
   * Loads account data and returns.
   *
   * @param accountId
   * @param accountName
   * @return
   */
  private static Account loadAccount(int accountId) {
    Account account = new Account(accountId);

    PlayerDAO playerDAO = DAOManager.getDAO(PlayerDAO.class);
    PlayerAppearanceDAO appereanceDAO = DAOManager.getDAO(PlayerAppearanceDAO.class);

    List<Integer> playerOids = playerDAO.getPlayerOidsOnAccount(accountId);

    for (int playerOid : playerOids) {
      PlayerCommonData playerCommonData = playerDAO.loadPlayerCommonData(playerOid);
      PlayerAppearance appereance = appereanceDAO.load(playerOid);

      LegionMember legionMember =
          DAOManager.getDAO(LegionMemberDAO.class).loadLegionMember(playerOid);

      /** Load only equipment and its stones to display on character selection screen */
      List<Item> equipment = DAOManager.getDAO(InventoryDAO.class).loadEquipment(playerOid);

      PlayerAccountData acData =
          new PlayerAccountData(playerCommonData, appereance, equipment, legionMember);
      playerDAO.setCreationDeletionTime(acData);

      account.addPlayerAccountData(acData);

      /** load account warehouse only once */
      if (account.getAccountWarehouse() == null) {
        // TODO memory lake.....
        Player player = new Player(new PlayerController(), playerCommonData, appereance, account);
        Storage accWarehouse =
            DAOManager.getDAO(InventoryDAO.class)
                .loadStorage(player, StorageType.ACCOUNT_WAREHOUSE);
        ItemService.loadItemStones(accWarehouse.getStorageItems());
        account.setAccountWarehouse(accWarehouse);
      }
    }

    /** For new accounts - create empty account warehouse */
    if (account.getAccountWarehouse() == null)
      account.setAccountWarehouse(new Storage(StorageType.ACCOUNT_WAREHOUSE));

    return account;
  }
コード例 #2
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_APPLY_PRESET) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    if (params.length == 0 || params.length > 1) {
      PacketSendUtility.sendMessage(admin, "syntax //preset <name>");
      return;
    }

    VisibleObject target = admin.getTarget();
    Player player = null;

    if (target == null) player = admin;
    else if (!(target instanceof Player)) {
      PacketSendUtility.sendMessage(admin, "Presets can be applied only on players!");
      return;
    } else {
      player = (Player) target;
    }

    String presetName = params[0];

    PresetTemplate template = DataManager.CUSTOM_PRESET_DATA.getPresetTemplate(presetName);
    if (template == null) {
      PacketSendUtility.sendMessage(admin, "No such preset!");
      return;
    }
    if (template.getGender().ordinal() != player.getCommonData().getGender().ordinal()
        || template.getRace().ordinal() != player.getCommonData().getRace().ordinal()) {
      PacketSendUtility.sendMessage(admin, "Preset can not be applied on current gender or race!");
      return;
    }

    PlayerAppearance.loadDetails(player.getPlayerAppearance(), template.getDetail());
    if (template.getFaceType() > 0) player.getPlayerAppearance().setFace(template.getFaceType());
    if (template.getHairType() > 0) player.getPlayerAppearance().setHair(template.getHairType());
    if (template.getHairRGB() != null)
      player.getPlayerAppearance().setHairRGB(getDyeColor(template.getHairRGB()));
    if (template.getLipsRGB() != null)
      player.getPlayerAppearance().setLipRGB(getDyeColor(template.getLipsRGB()));
    if (template.getSkinRGB() != null)
      player.getPlayerAppearance().setSkinRGB(getDyeColor(template.getSkinRGB()));
    if (template.getHeight() > 0) player.getPlayerAppearance().setHeight(template.getHeight());

    DAOManager.getDAO(PlayerAppearanceDAO.class).store(player);

    player.clearKnownlist();
    PacketSendUtility.sendPacket(player, new SM_PLAYER_INFO(player, false));
    player.updateKnownlist();
  }
コード例 #3
0
 /**
  * Load characters count on account from database
  *
  * @param accountId
  * @return
  */
 public static int getCharacterCountFor(int accountId) {
   PlayerDAO playerDAO = DAOManager.getDAO(PlayerDAO.class);
   return playerDAO.getCharacterCountOnAccount(accountId);
 }