Package lineage2.gameserver.model.entity.residence

Examples of lineage2.gameserver.model.entity.residence.Residence


   * @param id int
   * @return R
   */
  public <R extends Residence> R getResidence(Class<R> type, int id)
  {
    Residence r = getResidence(id);
    if ((r == null) || (r.getClass() != type))
    {
      return null;
    }
    return (R) r;
  }
View Full Code Here


   * @param offset int
   * @return R
   */
  public <R extends Residence> R findNearestResidence(Class<R> clazz, int x, int y, int z, Reflection ref, int offset)
  {
    Residence residence = getResidenceByCoord(clazz, x, y, z, ref);
    if (residence == null)
    {
      double closestDistance = offset;
      double distance;
      for (Residence r : getResidenceList(clazz))
View Full Code Here

    for (Iterator<Attribute> iterator = rootElement.attributeIterator(); iterator.hasNext();)
    {
      Attribute element = iterator.next();
      set.set(element.getName(), element.getValue());
    }
    Residence residence = null;
    try
    {
      clazz = Class.forName("lineage2.gameserver.model.entity.residence." + impl);
      Constructor<?> constructor = clazz.getConstructor(StatsSet.class);
      residence = (Residence) constructor.newInstance(set);
      getHolder().addResidence(residence);
    }
    catch (Exception e)
    {
      error("fail to init: " + getCurrentFileName(), e);
      return;
    }
    for (Iterator<Element> iterator = rootElement.elementIterator(); iterator.hasNext();)
    {
      Element element = iterator.next();
      String nodeName = element.getName();
      int level = element.attributeValue("level") == null ? 0 : Integer.valueOf(element.attributeValue("level"));
      int lease = (int) ((element.attributeValue("lease") == null ? 0 : Integer.valueOf(element.attributeValue("lease"))) * Config.RESIDENCE_LEASE_FUNC_MULTIPLIER);
      int npcId = element.attributeValue("npcId") == null ? 0 : Integer.valueOf(element.attributeValue("npcId"));
      int listId = element.attributeValue("listId") == null ? 0 : Integer.valueOf(element.attributeValue("listId"));
      ResidenceFunction function = null;
      if (nodeName.equalsIgnoreCase("teleport"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.TELEPORT);
        List<TeleportLocation> targets = new ArrayList<>();
        for (Iterator<Element> it2 = element.elementIterator(); it2.hasNext();)
        {
          Element teleportElement = it2.next();
          if ("target".equalsIgnoreCase(teleportElement.getName()))
          {
            int npcStringId = Integer.parseInt(teleportElement.attributeValue("name"));
            long price = Long.parseLong(teleportElement.attributeValue("price"));
            int itemId = teleportElement.attributeValue("item") == null ? ItemTemplate.ITEM_ID_ADENA : Integer.parseInt(teleportElement.attributeValue("item"));
            TeleportLocation loc = new TeleportLocation(itemId, price, npcStringId, 0);
            loc.set(Location.parseLoc(teleportElement.attributeValue("loc")));
            targets.add(loc);
          }
        }
        function.addTeleports(level, targets.toArray(new TeleportLocation[targets.size()]));
      }
      else if (nodeName.equalsIgnoreCase("support"))
      {
        if ((level > 9) && !Config.ALT_CH_ALLOW_1H_BUFFS)
        {
          continue;
        }
        function = checkAndGetFunction(residence, ResidenceFunction.SUPPORT);
        function.addBuffs(level);
      }
      else if (nodeName.equalsIgnoreCase("item_create"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.ITEM_CREATE);
        function.addBuylist(level, new int[]
        {
          npcId,
          listId
        });
      }
      else if (nodeName.equalsIgnoreCase("curtain"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.CURTAIN);
      }
      else if (nodeName.equalsIgnoreCase("platform"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.PLATFORM);
      }
      else if (nodeName.equalsIgnoreCase("restore_exp"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.RESTORE_EXP);
      }
      else if (nodeName.equalsIgnoreCase("restore_hp"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.RESTORE_HP);
      }
      else if (nodeName.equalsIgnoreCase("restore_mp"))
      {
        function = checkAndGetFunction(residence, ResidenceFunction.RESTORE_MP);
      }
      else if (nodeName.equalsIgnoreCase("skills"))
      {
        for (Iterator<Element> nextIterator = element.elementIterator(); nextIterator.hasNext();)
        {
          Element nextElement = nextIterator.next();
          int id2 = Integer.parseInt(nextElement.attributeValue("id"));
          int level2 = Integer.parseInt(nextElement.attributeValue("level"));
          Skill skill = SkillTable.getInstance().getInfo(id2, level2);
          if (skill != null)
          {
            residence.addSkill(skill);
          }
        }
      }
      else if (nodeName.equalsIgnoreCase("banish_points"))
      {
        for (Iterator<Element> banishPointsIterator = element.elementIterator(); banishPointsIterator.hasNext();)
        {
          Location loc = Location.parse(banishPointsIterator.next());
          residence.addBanishPoint(loc);
        }
      }
      else if (nodeName.equalsIgnoreCase("owner_restart_points"))
      {
        for (Iterator<Element> ownerRestartPointsIterator = element.elementIterator(); ownerRestartPointsIterator.hasNext();)
        {
          Location loc = Location.parse(ownerRestartPointsIterator.next());
          residence.addOwnerRestartPoint(loc);
        }
      }
      else if (nodeName.equalsIgnoreCase("other_restart_points"))
      {
        for (Iterator<Element> otherRestartPointsIterator = element.elementIterator(); otherRestartPointsIterator.hasNext();)
        {
          Location loc = Location.parse(otherRestartPointsIterator.next());
          residence.addOtherRestartPoint(loc);
        }
      }
      else if (nodeName.equalsIgnoreCase("chaos_restart_points"))
      {
        for (Iterator<Element> chaosRestartPointsIterator = element.elementIterator(); chaosRestartPointsIterator.hasNext();)
        {
          Location loc = Location.parse(chaosRestartPointsIterator.next());
          residence.addChaosRestartPoint(loc);
        }
      }
      else if (nodeName.equalsIgnoreCase("related_fortresses"))
      {
        for (Iterator<Element> subElementIterator = element.elementIterator(); subElementIterator.hasNext();)
View Full Code Here

  @Override
  protected int getCond(Player player)
  {
    if(player.isGM())
      return COND_OWNER;
    Residence castle = getCastle();
    if(castle != null && castle.getId() > 0)
      if(player.getClan() != null)
        if(castle.getSiegeEvent().isInProgress())
          return COND_SIEGE; // Busy because of siege
        else if(castle.getOwnerId() == player.getClanId())
        {
          if(player.isClanLeader()) // Leader of clan
            return COND_OWNER;
          if(isHaveRigths(player, Clan.CP_CS_ENTRY_EXIT) || // doors
          isHaveRigths(player, Clan.CP_CS_MANOR_ADMIN) || // manor
View Full Code Here

   * @param player Player
   * @return int
   */
  protected int getCond(Player player)
  {
    Residence residence = getResidence();
    Clan residenceOwner = residence.getOwner();
    if ((residenceOwner != null) && (player.getClan() == residenceOwner))
    {
      if (residence.getSiegeEvent().isInProgress())
      {
        return COND_SIEGE;
      }
      return COND_OWNER;
    }
View Full Code Here

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

   */
  @Override
  public void onEvtTwiceClick(final Player player)
  {
    final DoorInstance door = getActor();
    final Residence residence = ResidenceHolder.getInstance().getResidence(door.getTemplate().getAIParams().getInteger("residence_id"));
    if ((residence.getOwner() != null) && (player.getClan() != null) && (player.getClan().equals(residence.getOwner())) && ((player.getClanPrivileges() & Clan.CP_CS_ENTRY_EXIT) == Clan.CP_CS_ENTRY_EXIT))
    {
      final SystemMsg msg = door.isOpen() ? SystemMsg.WOULD_YOU_LIKE_TO_CLOSE_THE_GATE : SystemMsg.WOULD_YOU_LIKE_TO_OPEN_THE_GATE;
      player.ask(new ConfirmDlg(msg, 0), new OnAnswerListener()
      {
        @Override
View Full Code Here

   * @param player Player
   * @return boolean
   */
  private boolean validateCondition(Player player)
  {
    Residence residence = getCastle();
    if ((residence != null) && (residence.getId() > 0))
    {
      if (player.getClan() != null)
      {
        if ((residence.getOwnerId() == player.getClanId()) && player.isClanLeader())
        {
          return true;
        }
      }
    }
    residence = getFortress();
    if ((residence != null) && (residence.getId() > 0))
    {
      if (player.getClan() != null)
      {
        if ((residence.getOwnerId() == player.getClanId()) && player.isClanLeader())
        {
          return true;
        }
      }
    }
    residence = getClanHall();
    if ((residence != null) && (residence.getId() > 0))
    {
      if (player.getClan() != null)
      {
        if ((residence.getOwnerId() == player.getClanId()) && player.isClanLeader())
        {
          return true;
        }
      }
    }
View Full Code Here

    final Commands command = (Commands) comm;
    if (!activeChar.getPlayerAccess().CanEditNPC)
    {
      return false;
    }
    final Residence r;
    final SiegeEvent<?, ?> event;
    Calendar calendar;
    NpcHtmlMessage msg;
    switch (command)
    {
      case admin_residence_list:
        msg = new NpcHtmlMessage(5);
        msg.setFile("admin/residence/residence_list.htm");
        final StringBuilder replyMSG = new StringBuilder(200);
        for (Residence residence : ResidenceHolder.getInstance().getResidences())
        {
          if (residence != null)
          {
            replyMSG.append("<tr><td>");
            replyMSG.append("<a action=\"bypass -h admin_residence ").append(residence.getId()).append("\">").append(HtmlUtils.htmlResidenceName(residence.getId())).append("</a>");
            replyMSG.append("</td><td>");
            Clan owner = residence.getOwner();
            if (owner == null)
            {
              replyMSG.append("NPC");
            }
            else
            {
              replyMSG.append(owner.getName());
            }
            replyMSG.append("</td></tr>");
          }
        }
        msg.replace("%residence_list%", replyMSG.toString());
        activeChar.sendPacket(msg);
        break;
      case admin_residence:
        if (wordList.length != 2)
        {
          return false;
        }
        r = ResidenceHolder.getInstance().getResidence(Integer.parseInt(wordList[1]));
        if (r == null)
        {
          return false;
        }
        event = r.getSiegeEvent();
        msg = new NpcHtmlMessage(5);
        msg.setFile("admin/residence/siege_info.htm");
        msg.replace("%residence%", HtmlUtils.htmlResidenceName(r.getId()));
        msg.replace("%id%", String.valueOf(r.getId()));
        msg.replace("%owner%", (r.getOwner() == null) ? "NPC" : r.getOwner().getName());
        msg.replace("%cycle%", String.valueOf(r.getCycle()));
        msg.replace("%paid_cycle%", String.valueOf(r.getPaidCycle()));
        msg.replace("%reward_count%", String.valueOf(r.getRewardCount()));
        msg.replace("%left_time%", String.valueOf(r.getCycleDelay()));
        final StringBuilder clans = new StringBuilder(100);
        for (Map.Entry<String, List<Serializable>> entry : event.getObjects().entrySet())
        {
          for (Serializable o : entry.getValue())
          {
            if (o instanceof SiegeClanObject)
            {
              SiegeClanObject siegeClanObject = (SiegeClanObject) o;
              clans.append("<tr>").append("<td>").append(siegeClanObject.getClan().getName()).append("</td>").append("<td>").append(siegeClanObject.getClan().getLeaderName()).append("</td>").append("<td>").append(siegeClanObject.getType()).append("</td>").append("</tr>");
            }
          }
        }
        msg.replace("%clans%", clans.toString());
        msg.replace("%hour%", String.valueOf(r.getSiegeDate().get(Calendar.HOUR_OF_DAY)));
        msg.replace("%minute%", String.valueOf(r.getSiegeDate().get(Calendar.MINUTE)));
        msg.replace("%day%", String.valueOf(r.getSiegeDate().get(Calendar.DAY_OF_MONTH)));
        msg.replace("%month%", String.valueOf(r.getSiegeDate().get(Calendar.MONTH) + 1));
        msg.replace("%year%", String.valueOf(r.getSiegeDate().get(Calendar.YEAR)));
        activeChar.sendPacket(msg);
        break;
      case admin_set_owner:
        if (wordList.length != 3)
        {
          return false;
        }
        r = ResidenceHolder.getInstance().getResidence(Integer.parseInt(wordList[1]));
        if (r == null)
        {
          return false;
        }
        Clan clan = null;
        final String clanName = wordList[2];
        if (!clanName.equalsIgnoreCase("npc"))
        {
          clan = ClanTable.getInstance().getClanByName(clanName);
          if (clan == null)
          {
            activeChar.sendPacket(SystemMsg.INCORRECT_NAME);
            AdminCommandHandler.getInstance().useAdminCommandHandler(activeChar, "admin_residence " + r.getId());
            return false;
          }
        }
        event = r.getSiegeEvent();
        event.clearActions();
        r.getLastSiegeDate().setTimeInMillis((clan == null) ? 0 : System.currentTimeMillis());
        r.getOwnDate().setTimeInMillis((clan == null) ? 0 : System.currentTimeMillis());
        r.changeOwner(clan);
        event.reCalcNextTime(false);
        break;
      case admin_set_siege_time:
        r = ResidenceHolder.getInstance().getResidence(Integer.parseInt(wordList[1]));
        if (r == null)
        {
          return false;
        }
        calendar = (Calendar) r.getSiegeDate().clone();
        for (int i = 2; i < wordList.length; i++)
        {
          int type;
          int val = Integer.parseInt(wordList[i]);
          switch (i)
          {
            case 2:
              type = Calendar.HOUR_OF_DAY;
              break;
            case 3:
              type = Calendar.MINUTE;
              break;
            case 4:
              type = Calendar.DAY_OF_MONTH;
              break;
            case 5:
              type = Calendar.MONTH;
              val -= 1;
              break;
            case 6:
              type = Calendar.YEAR;
              break;
            default:
              continue;
          }
          calendar.set(type, val);
        }
        event = r.getSiegeEvent();
        event.clearActions();
        r.getSiegeDate().setTimeInMillis(calendar.getTimeInMillis());
        event.registerActions();
        r.setJdbcState(JdbcEntityState.UPDATED);
        r.update();
        AdminCommandHandler.getInstance().useAdminCommandHandler(activeChar, "admin_residence " + r.getId());
        break;
      case admin_quick_siege_start:
        r = ResidenceHolder.getInstance().getResidence(Integer.parseInt(wordList[1]));
        if (r == null)
        {
          return false;
        }
        calendar = Calendar.getInstance();
        if (wordList.length >= 3)
        {
          calendar.set(Calendar.SECOND, -Integer.parseInt(wordList[2]));
        }
        event = r.getSiegeEvent();
        event.clearActions();
        r.getSiegeDate().setTimeInMillis(calendar.getTimeInMillis());
        event.registerActions();
        r.setJdbcState(JdbcEntityState.UPDATED);
        r.update();
        AdminCommandHandler.getInstance().useAdminCommandHandler(activeChar, "admin_residence " + r.getId());
        break;
      case admin_quick_siege_stop:
        r = ResidenceHolder.getInstance().getResidence(Integer.parseInt(wordList[1]));
        if (r == null)
        {
          return false;
        }
        event = r.getSiegeEvent();
        event.clearActions();
        ThreadPoolManager.getInstance().execute(new RunnableImpl()
        {
          @Override
          public void runImpl()
          {
            event.stopEvent();
          }
        });
        AdminCommandHandler.getInstance().useAdminCommandHandler(activeChar, "admin_residence " + r.getId());
        break;
      case admin_backup_unit_info:
        final GameObject target = activeChar.getTarget();
        if (!(target instanceof PowerControlUnitInstance) && !(target instanceof BackupPowerUnitInstance))
        {
View Full Code Here

    if (!player.hasPrivilege(Privilege.CS_FS_SIEGE_WAR))
    {
      player.sendPacket(SystemMsg.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
      return;
    }
    Residence residence = ResidenceHolder.getInstance().getResidence(_id);
    if (residence.getType() == ResidenceType.Castle)
    {
      registerAtCastle(player, (Castle) residence, _isAttacker, _isJoining);
    }
    else if ((residence.getType() == ResidenceType.ClanHall) && _isAttacker)
    {
      registerAtClanHall(player, (ClanHall) residence, _isJoining);
    }
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.entity.residence.Residence

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.