Package lineage2.gameserver.model.pledge

Examples of lineage2.gameserver.model.pledge.Clan$ClanReputationComparator


   */
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets)
  {
    Player player = (Player) activeChar;
    Clan clan = player.getClan();
    if ((clan == null) || !player.isClanLeader())
    {
      return;
    }
    SiegeEvent<?, ?> siegeEvent = activeChar.getEvent(SiegeEvent.class);
View Full Code Here


    {
      if (c.getOwnerId() <= 0)
      {
        continue;
      }
      Clan clan = ClanTable.getInstance().getClan(c.getOwnerId());
      if (clan == null)
      {
        continue;
      }
      Warehouse cwh = clan.getWarehouse();
      for (CropProcure crop : c.getCropProcure(PERIOD_CURRENT))
      {
        if (crop.getStartAmount() == 0)
        {
          continue;
        }
        if (crop.getStartAmount() > crop.getAmount())
        {
          _log.info("Manor System [" + c.getName() + "]: Start Amount of Crop " + crop.getStartAmount() + " > Amount of current " + crop.getAmount());
          long count = crop.getStartAmount() - crop.getAmount();
          count = (count * 90) / 100;
          if ((count < 1) && (Rnd.get(99) < 90))
          {
            count = 1;
          }
          if (count >= 1)
          {
            int id = Manor.getInstance().getMatureCrop(crop.getId());
            cwh.addItem(id, count);
          }
        }
        if (crop.getAmount() > 0)
        {
          c.addToTreasuryNoTax(crop.getAmount() * crop.getPrice(), false, false);
          Log.add(c.getName() + "|" + (crop.getAmount() * crop.getPrice()) + "|ManorManager|" + crop.getAmount() + "*" + crop.getPrice(), "treasury");
        }
        c.setCollectedShops(0);
        c.setCollectedSeed(0);
      }
      c.setSeedProduction(c.getSeedProduction(PERIOD_NEXT), PERIOD_CURRENT);
      c.setCropProcure(c.getCropProcure(PERIOD_NEXT), PERIOD_CURRENT);
      long manor_cost = c.getManorCost(PERIOD_CURRENT);
      if (c.getTreasury() < manor_cost)
      {
        c.setSeedProduction(getNewSeedsList(c.getId()), PERIOD_NEXT);
        c.setCropProcure(getNewCropsList(c.getId()), PERIOD_NEXT);
        Log.add(c.getName() + "|" + manor_cost + "|ManorManager Error@setNextPeriod", "treasury");
      }
      else
      {
        List<SeedProduction> production = new ArrayList<>();
        List<CropProcure> procure = new ArrayList<>();
        for (SeedProduction s : c.getSeedProduction(PERIOD_CURRENT))
        {
          s.setCanProduce(s.getStartProduce());
          production.add(s);
        }
        for (CropProcure cr : c.getCropProcure(PERIOD_CURRENT))
        {
          cr.setAmount(cr.getStartAmount());
          procure.add(cr);
        }
        c.setSeedProduction(production, PERIOD_NEXT);
        c.setCropProcure(procure, PERIOD_NEXT);
      }
      c.saveCropData();
      c.saveSeedData();
      PlayerMessageStack.getInstance().mailto(clan.getLeaderId(), Msg.THE_MANOR_INFORMATION_HAS_BEEN_UPDATED);
      c.setNextPeriodApproved(false);
    }
  }
View Full Code Here

        manor_cost = c.getManorCost(PERIOD_NEXT);
        if (manor_cost > 0)
        {
          Log.add(c.getName() + "|" + -manor_cost + "|ManorManager Error@approveNextPeriod", "treasury");
        }
        Clan clan = c.getOwner();
        PlayerMessageStack.getInstance().mailto(clan.getLeaderId(), Msg.THE_AMOUNT_IS_NOT_SUFFICIENT_AND_SO_THE_MANOR_IS_NOT_IN_OPERATION);
      }
      else
      {
        c.addToTreasuryNoTax(-manor_cost, false, false);
        Log.add(c.getName() + "|" + -manor_cost + "|ManorManager", "treasury");
View Full Code Here

   */
  @Override
  protected int getCond(Player player)
  {
    Castle residence = getCastle();
    Clan residenceOwner = residence.getOwner();
    if ((residenceOwner != null) && (player.getClan() == residenceOwner) && ((player.getClanPrivileges() & getOpenPriv()) == getOpenPriv()))
    {
      if (residence.getSiegeEvent().isInProgress())
      {
        return COND_SIEGE;
View Full Code Here

    }
  }
 
  public QuestState getLeader(QuestState st)
  {
    Clan clan = st.getPlayer().getClan();
    QuestState leader = null;
    if ((clan != null) && (clan.getLeader() != null) && (clan.getLeader().getPlayer() != null))
    {
      leader = clan.getLeader().getPlayer().getQuestState(getName());
    }
    return leader;
  }
View Full Code Here

  {
    List<Fortress> forts = ResidenceHolder.getInstance().getResidenceList(Fortress.class);
    _infos = new ArrayList<FortressInfo>(forts.size());
    for (Fortress fortress : forts)
    {
      Clan owner = fortress.getOwner();
      _infos.add(new FortressInfo(owner == null ? StringUtils.EMPTY : owner.getName(), fortress.getId(), fortress.getSiegeEvent().isInProgress(), owner == null ? 0 : (int) ((System
              .currentTimeMillis() - fortress.getOwnDate().getTimeInMillis()) / 1000L)));
    }
  }
View Full Code Here

      else if (clanHall.getSiegeEvent().getClass() == ClanHallMiniGameEvent.class)
        getType = 2;
      else
        getType = 1;

      Clan clan = ClanTable.getInstance().getClan(clanHall.getOwnerId());
      String clan_name = clanHall.getOwnerId() == 0 || clan == null ? StringUtils.EMPTY : clan.getName();
      String leader_name = clanHall.getOwnerId() == 0 || clan == null ? StringUtils.EMPTY : clan.getLeaderName();
      _clanHalls.add(new AgitInfo(clan_name, leader_name, ch_id, getType));
    }
  }
View Full Code Here

    Fortress fortress = getFortress();
    FortressSiegeEvent siegeEvent = fortress.getSiegeEvent();
   
    if (command.equalsIgnoreCase("register"))
    {
      Clan clan = player.getClan();
      if (clan == null)
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery002.htm");
        return;
      }
     
      if (clan.getHasFortress() == fortress.getId())
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery014.htm", "%clan_name%", clan.getName());
        return;
      }
     
      if (!player.hasPrivilege(Privilege.CS_FS_SIEGE_WAR))
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery012.htm");
        return;
      }
     
      if (clan.getCastle() > 0)
      {
        Castle relatedCastle = null;
        for (Castle castle : fortress.getRelatedCastles())
        {
          if (castle.getId() == clan.getCastle())
          {
            relatedCastle = castle;
          }
        }
       
        if (relatedCastle != null)
        {
          if (fortress.getContractState() == Fortress.CONTRACT_WITH_CASTLE)
          {
            showChatWindow(player, "residence2/fortress/fortress_ordery022.htm");
            return;
          }
         
          if (relatedCastle.getSiegeEvent().isRegistrationOver())
          {
            showChatWindow(player, "residence2/fortress/fortress_ordery022.htm");
            return;
          }
        }
        else
        {
          showChatWindow(player, "residence2/fortress/fortress_ordery021.htm");
          return;
        }
      }
     
      int attackersSize = siegeEvent.getObjects(SiegeEvent.ATTACKERS).size();
     
      if (attackersSize == 0)
      {
        if (!player.consumeItem(ItemTemplate.ITEM_ID_ADENA, 250000L))
        {
          showChatWindow(player, "residence2/fortress/fortress_ordery003.htm");
          return;
        }
      }
     
      SiegeClanObject siegeClan = siegeEvent.getSiegeClan(SiegeEvent.ATTACKERS, clan);
      if (siegeClan != null)
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery007.htm");
        return;
      }
     
      for (Fortress $ : ResidenceHolder.getInstance().getResidenceList(Fortress.class))
      {
        if ($.getSiegeEvent().getSiegeClan(SiegeEvent.ATTACKERS, clan) != null)
        {
          showChatWindow(player, "residence2/fortress/fortress_ordery006.htm");
          return;
        }
      }
     
      if ((clan.getHasFortress() > 0) && (fortress.getSiegeDate().getTimeInMillis() > 0))
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery006.htm");
        return;
      }
     
      siegeClan = new SiegeClanObject(SiegeEvent.ATTACKERS, clan, 0);
      siegeEvent.addObject(SiegeEvent.ATTACKERS, siegeClan);
      SiegeClanDAO.getInstance().insert(fortress, siegeClan);
     
      siegeEvent.reCalcNextTime(false);
     
      player.sendPacket(new SystemMessage2(SystemMsg.YOUR_CLAN_HAS_BEEN_REGISTERED_TO_S1S_FORTRESS_BATTLE).addResidenceName(fortress));
      showChatWindow(player, "residence2/fortress/fortress_ordery005.htm");
    }
    else if (command.equalsIgnoreCase("cancel"))
    {
      Clan clan = player.getClan();
      if ((clan == null) || !player.hasPrivilege(Privilege.CS_FS_SIEGE_WAR))
      {
        showChatWindow(player, "residence2/fortress/fortress_ordery010.htm");
        return;
      }
View Full Code Here

    StringTokenizer st = new StringTokenizer(bypass, "_");
    String cmd = st.nextToken();
    player.setSessionVar("add_fav", null);
    if ("bbsclan".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan != null) && (clan.getLevel() > 1))
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      onBypassCommand(player, "_clbbslist_1_0_");
    }
    else if ("clbbslist".equals(cmd))
    {
      int page = Integer.parseInt(st.nextToken());
      int byCL = Integer.parseInt(st.nextToken());
      String search = st.hasMoreTokens() ? st.nextToken() : "";
      HashMap<Integer, String> tpls = Util.parseTemplate(HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_clanlist.htm", player));
      String html = tpls.get(0);
      Clan playerClan = player.getClan();
      if (playerClan != null)
      {
        String my_clan = tpls.get(1);
        my_clan = my_clan.replace("%PLEDGE_ID%", String.valueOf(playerClan.getClanId()));
        my_clan = my_clan.replace("%MY_PLEDGE_NAME%", playerClan.getLevel() > 1 ? playerClan.getName() : "");
        html = html.replace("<?my_clan_link?>", my_clan);
      }
      else
      {
        html = html.replace("<?my_clan_link?>", "");
      }
      List<Clan> clanList = getClanList(search, byCL == 1);
      int start = (page - 1) * CLANS_PER_PAGE;
      int end = Math.min(page * CLANS_PER_PAGE, clanList.size());
      if (page == 1)
      {
        html = html.replace("%ACTION_GO_LEFT%", "");
        html = html.replace("%GO_LIST%", "");
        html = html.replace("%NPAGE%", "1");
      }
      else
      {
        html = html.replace("%ACTION_GO_LEFT%", "bypass _clbbslist_" + (page - 1) + "_" + byCL + "_" + search);
        html = html.replace("%NPAGE%", String.valueOf(page));
        StringBuilder goList = new StringBuilder("");
        for (int i = page > 10 ? page - 10 : 1; i < page; i++)
        {
          goList.append("<td><a action=\"bypass _clbbslist_").append(i).append('_').append(byCL).append('_').append(search).append("\"> ").append(i).append(" </a> </td>\n\n");
        }
        html = html.replace("%GO_LIST%", goList.toString());
      }
      int pages = Math.max(clanList.size() / CLANS_PER_PAGE, 1);
      if (clanList.size() > (pages * CLANS_PER_PAGE))
      {
        pages++;
      }
      if (pages > page)
      {
        html = html.replace("%ACTION_GO_RIGHT%", "bypass _clbbslist_" + (page + 1) + "_" + byCL + "_" + search);
        int ep = Math.min(page + 10, pages);
        StringBuilder goList = new StringBuilder("");
        for (int i = page + 1; i <= ep; i++)
        {
          goList.append("<td><a action=\"bypass _clbbslist_").append(i).append('_').append(byCL).append('_').append(search).append("\"> ").append(i).append(" </a> </td>\n\n");
        }
        html = html.replace("%GO_LIST2%", goList.toString());
      }
      else
      {
        html = html.replace("%ACTION_GO_RIGHT%", "");
        html = html.replace("%GO_LIST2%", "");
      }
      StringBuilder cl = new StringBuilder("");
      String tpl = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_clantpl.htm", player);
      for (int i = start; i < end; i++)
      {
        Clan clan = clanList.get(i);
        String clantpl = tpl;
        clantpl = clantpl.replace("%action_clanhome%", "bypass _clbbsclan_" + clan.getClanId());
        clantpl = clantpl.replace("%clan_name%", clan.getName());
        clantpl = clantpl.replace("%clan_owner%", clan.getLeaderName());
        clantpl = clantpl.replace("%skill_level%", String.valueOf(clan.getLevel()));
        clantpl = clantpl.replace("%member_count%", String.valueOf(clan.getAllSize()));
        cl.append(clantpl);
      }
      html = html.replace("%CLAN_LIST%", cl.toString());
      ShowBoard.separateAndSend(html, player);
    }
    else if ("clbbsclan".equals(cmd))
    {
      int clanId = Integer.parseInt(st.nextToken());
      if (clanId == 0)
      {
        player.sendPacket(new SystemMessage(SystemMessage.NOT_JOINED_IN_ANY_CLAN));
        onBypassCommand(player, "_clbbslist_1_0");
        return;
      }
      Clan clan = ClanTable.getInstance().getClan(clanId);
      if (clan == null)
      {
        onBypassCommand(player, "_clbbslist_1_0");
        return;
      }
      if (clan.getLevel() < 2)
      {
        player.sendPacket(new SystemMessage(SystemMessage.THERE_ARE_NO_COMMUNITIES_IN_MY_CLAN_CLAN_COMMUNITIES_ARE_ALLOWED_FOR_CLANS_WITH_SKILL_LEVELS_OF_2_AND_HIGHER));
        onBypassCommand(player, "_clbbslist_1_0");
        return;
      }
      Connection con = null;
      PreparedStatement statement = null;
      ResultSet rset = null;
      String intro = "";
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("SELECT * FROM `bbs_clannotice` WHERE `clan_id` = ? and type = 2");
        statement.setInt(1, clanId);
        rset = statement.executeQuery();
        if (rset.next())
        {
          intro = rset.getString("notice");
        }
      }
      catch (Exception e)
      {
      }
      finally
      {
        DbUtils.closeQuietly(con, statement, rset);
      }
      HashMap<Integer, String> tpls = Util.parseTemplate(HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_clan.htm", player));
      String html = tpls.get(0);
      html = html.replace("%PLEDGE_ID%", String.valueOf(clanId));
      html = html.replace("%ACTION_ANN%", "");
      html = html.replace("%ACTION_FREE%", "");
      if ((player.getClanId() == clanId) && player.isClanLeader())
      {
        html = html.replace("<?menu?>", tpls.get(1));
      }
      else
      {
        html = html.replace("<?menu?>", "");
      }
      html = html.replace("%CLAN_INTRO%", intro.replace("\n", "<br1>"));
      html = html.replace("%CLAN_NAME%", clan.getName());
      html = html.replace("%SKILL_LEVEL%", String.valueOf(clan.getLevel()));
      html = html.replace("%CLAN_MEMBERS%", String.valueOf(clan.getAllSize()));
      html = html.replace("%OWNER_NAME%", clan.getLeaderName());
      html = html.replace("%ALLIANCE_NAME%", clan.getAlliance() != null ? clan.getAlliance().getAllyName() : "");
      html = html.replace("%ANN_LIST%", "");
      html = html.replace("%THREAD_LIST%", "");
      ShowBoard.separateAndSend(html, player);
    }
    else if ("clbbsadmi".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      String html = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_clanadmin.htm", player);
      html = html.replace("%PLEDGE_ID%", String.valueOf(clan.getClanId()));
      html = html.replace("%ACTION_ANN%", "");
      html = html.replace("%ACTION_FREE%", "");
      html = html.replace("%CLAN_NAME%", clan.getName());
      html = html.replace("%per_list%", "");
      Connection con = null;
      PreparedStatement statement = null;
      ResultSet rset = null;
      String intro = "";
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("SELECT * FROM `bbs_clannotice` WHERE `clan_id` = ? and type = 2");
        statement.setInt(1, clan.getClanId());
        rset = statement.executeQuery();
        if (rset.next())
        {
          intro = rset.getString("notice");
        }
      }
      catch (Exception e)
      {
      }
      finally
      {
        DbUtils.closeQuietly(con, statement, rset);
      }
      List<String> args = new ArrayList<>();
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("");
      args.add("0");
      args.add("");
      args.add("0");
      args.add("");
      args.add("");
      args.add(intro);
      args.add("");
      args.add("");
      args.add("0");
      args.add("0");
      args.add("");
      player.sendPacket(new ShowBoard(html, "1001", player));
      player.sendPacket(new ShowBoard(args));
    }
    else if ("mailwritepledgeform".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      String html = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_pledge_mail_write.htm", player);
      html = html.replace("%PLEDGE_ID%", String.valueOf(clan.getClanId()));
      html = html.replace("%pledge_id%", String.valueOf(clan.getClanId()));
      html = html.replace("%pledge_name%", clan.getName());
      ShowBoard.separateAndSend(html, player);
    }
    else if ("announcepledgewriteform".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      HashMap<Integer, String> tpls = Util.parseTemplate(HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "bbs_clanannounce.htm", player));
      String html = tpls.get(0);
      html = html.replace("%PLEDGE_ID%", String.valueOf(clan.getClanId()));
      html = html.replace("%ACTION_ANN%", "");
      html = html.replace("%ACTION_FREE%", "");
      Connection con = null;
      PreparedStatement statement = null;
      ResultSet rset = null;
      String notice = "";
      int type = 0;
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("SELECT * FROM `bbs_clannotice` WHERE `clan_id` = ? and type != 2");
        statement.setInt(1, clan.getClanId());
        rset = statement.executeQuery();
        if (rset.next())
        {
          notice = rset.getString("notice");
          type = rset.getInt("type");
        }
      }
      catch (Exception e)
      {
      }
      finally
      {
        DbUtils.closeQuietly(con, statement, rset);
      }
      if (type == 0)
      {
        html = html.replace("<?usage?>", tpls.get(1));
      }
      else
      {
        html = html.replace("<?usage?>", tpls.get(2));
      }
      html = html.replace("%flag%", String.valueOf(type));
      List<String> args = new ArrayList<>();
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("0");
      args.add("");
      args.add("0");
      args.add("");
      args.add("0");
      args.add("");
      args.add("");
      args.add(notice);
      args.add("");
      args.add("");
      args.add("0");
      args.add("0");
      args.add("");
      player.sendPacket(new ShowBoard(html, "1001", player));
      player.sendPacket(new ShowBoard(args));
    }
    else if ("announcepledgeswitchshowflag".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      int type = Integer.parseInt(st.nextToken());
      Connection con = null;
      PreparedStatement statement = null;
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("UPDATE `bbs_clannotice` SET type = ? WHERE `clan_id` = ? and type = ?");
        statement.setInt(1, type);
        statement.setInt(2, clan.getClanId());
        statement.setInt(3, type == 1 ? 0 : 1);
        statement.execute();
      }
      catch (Exception e)
      {
      }
      finally
      {
        DbUtils.closeQuietly(con, statement);
      }
      clan.setNotice(type == 0 ? "" : null);
      onBypassCommand(player, "_announcepledgewriteform");
    }
  }
View Full Code Here

      }
      onBypassCommand(player, "_clbbslist_1_" + ("Ruler".equals(arg4) ? "1" : "0") + "_" + arg3);
    }
    else if ("clwriteintro".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader() || (arg3 == null) || arg3.isEmpty())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      arg3 = arg3.replace("<", "");
      arg3 = arg3.replace(">", "");
      arg3 = arg3.replace("&", "");
      arg3 = arg3.replace("$", "");
      if (arg3.length() > 3000)
      {
        arg3 = arg3.substring(0, 3000);
      }
      Connection con = null;
      PreparedStatement statement = null;
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("REPLACE INTO `bbs_clannotice`(clan_id, type, notice) VALUES(?, ?, ?)");
        statement.setInt(1, clan.getClanId());
        statement.setInt(2, 2);
        statement.setString(3, arg3);
        statement.execute();
      }
      catch (Exception e)
      {
      }
      finally
      {
        DbUtils.closeQuietly(con, statement);
      }
      onBypassCommand(player, "_clbbsclan_" + player.getClanId());
    }
    else if ("clwritemail".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      if ((arg3 == null) || (arg4 == null))
      {
        player.sendPacket(Msg.THE_MESSAGE_WAS_NOT_SENT);
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      arg3 = arg3.replace("<", "");
      arg3 = arg3.replace(">", "");
      arg3 = arg3.replace("&", "");
      arg3 = arg3.replace("$", "");
      arg5 = arg5.replace("<", "");
      arg5 = arg5.replace(">", "");
      arg5 = arg5.replace("&", "");
      arg5 = arg5.replace("$", "");
      if (arg3.isEmpty() || arg4.isEmpty())
      {
        player.sendPacket(Msg.THE_MESSAGE_WAS_NOT_SENT);
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      if (arg3.length() > 128)
      {
        arg3 = arg3.substring(0, 128);
      }
      if (arg4.length() > 3000)
      {
        arg5 = arg5.substring(0, 3000);
      }
      Connection con = null;
      PreparedStatement statement = null;
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("INSERT INTO `bbs_mail`(to_name, to_object_id, from_name, from_object_id, title, message, post_date, box_type) VALUES(?, ?, ?, ?, ?, ?, ?, 0)");
        for (UnitMember clm : clan)
        {
          statement.setString(1, clan.getName());
          statement.setInt(2, clm.getObjectId());
          statement.setString(3, player.getName());
          statement.setInt(4, player.getObjectId());
          statement.setString(5, arg3);
          statement.setString(6, arg5);
          statement.setInt(7, (int) (System.currentTimeMillis() / 1000));
          statement.execute();
        }
        statement.close();
        statement = con.prepareStatement("INSERT INTO `bbs_mail`(to_name, to_object_id, from_name, from_object_id, title, message, post_date, box_type) VALUES(?, ?, ?, ?, ?, ?, ?, 1)");
        statement.setString(1, clan.getName());
        statement.setInt(2, player.getObjectId());
        statement.setString(3, player.getName());
        statement.setInt(4, player.getObjectId());
        statement.setString(5, arg3);
        statement.setString(6, arg5);
        statement.setInt(7, (int) (System.currentTimeMillis() / 1000));
        statement.execute();
      }
      catch (Exception e)
      {
        player.sendPacket(Msg.THE_MESSAGE_WAS_NOT_SENT);
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      finally
      {
        DbUtils.closeQuietly(con, statement);
      }
      player.sendPacket(Msg.YOUVE_SENT_MAIL);
      for (Player member : clan.getOnlineMembers(0))
      {
        member.sendPacket(Msg.YOUVE_GOT_MAIL);
        member.sendPacket(ExMailArrived.STATIC);
      }
      onBypassCommand(player, "_clbbsclan_" + player.getClanId());
    }
    else if ("announcepledgewrite".equals(cmd))
    {
      Clan clan = player.getClan();
      if ((clan == null) || (clan.getLevel() < 2) || !player.isClanLeader())
      {
        onBypassCommand(player, "_clbbsclan_" + player.getClanId());
        return;
      }
      if ((arg3 == null) || arg3.isEmpty())
      {
        onBypassCommand(player, "_announcepledgewriteform");
        return;
      }
      arg3 = arg3.replace("<", "");
      arg3 = arg3.replace(">", "");
      arg3 = arg3.replace("&", "");
      arg3 = arg3.replace("$", "");
      if (arg3.isEmpty())
      {
        onBypassCommand(player, "_announcepledgewriteform");
        return;
      }
      if (arg3.length() > 3000)
      {
        arg3 = arg3.substring(0, 3000);
      }
      int type = Integer.parseInt(st.nextToken());
      Connection con = null;
      PreparedStatement statement = null;
      try
      {
        con = DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement("REPLACE INTO `bbs_clannotice`(clan_id, type, notice) VALUES(?, ?, ?)");
        statement.setInt(1, clan.getClanId());
        statement.setInt(2, type);
        statement.setString(3, arg3);
        statement.execute();
      }
      catch (Exception e)
      {
        e.printStackTrace();
        onBypassCommand(player, "_announcepledgewriteform");
        return;
      }
      finally
      {
        DbUtils.closeQuietly(con, statement);
      }
      if (type == 1)
      {
        clan.setNotice(arg3.replace("\n", "<br1>"));
      }
      else
      {
        clan.setNotice("");
      }
      player.sendPacket(Msg.NOTICE_HAS_BEEN_SAVED);
      onBypassCommand(player, "_announcepledgewriteform");
    }
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.pledge.Clan$ClanReputationComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.