コード例 #1
0
 @Override
 protected void runImpl() {
   Castle castle = CastleManager.getInstance().getCastleById(_castleId);
   if (castle == null) return;
   SiegeAttackerList sal = new SiegeAttackerList(castle);
   sendPacket(sal);
 }
コード例 #2
0
 @Override
 protected void runImpl() {
   Castle castle = CastleManager.getInstance().getCastleById(_castleId);
   if (castle == null) {
     return;
   }
   SiegeDefenderList sdl = new SiegeDefenderList(castle);
   sendPacket(sdl);
 }
コード例 #3
0
  private static final void dissolveClan(L2PcInstance player, int clanId) {
    if (!player.isClanLeader()) {
      player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
      return;
    }

    final L2Clan clan = player.getClan();
    if (clan.getAllyId() != 0) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISPERSE_THE_CLANS_IN_ALLY));
      return;
    }
    if (clan.isAtWar()) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_WAR));
      return;
    }
    if (clan.getHasCastle() != 0 || clan.getHasHideout() != 0 || clan.getHasFort() != 0) {
      player.sendPacket(
          new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_OWNING_CLAN_HALL_OR_CASTLE));
      return;
    }

    for (Castle castle : CastleManager.getInstance().getCastles()) {
      if (SiegeManager.getInstance().checkIsRegistered(clan, castle.getCastleId())) {
        player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_SIEGE));
        return;
      }
    }
    for (Fort fort : FortManager.getInstance().getForts()) {
      if (FortSiegeManager.getInstance().checkIsRegistered(clan, fort.getFortId())) {
        player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_SIEGE));
        return;
      }
    }

    if (player.isInsideZone(L2PcInstance.ZONE_SIEGE)) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISSOLVE_WHILE_IN_SIEGE));
      return;
    }
    if (clan.getDissolvingExpiryTime() > System.currentTimeMillis()) {
      player.sendPacket(new SystemMessage(SystemMessageId.DISSOLUTION_IN_PROGRESS));
      return;
    }

    clan.setDissolvingExpiryTime(
        System.currentTimeMillis()
            + Config.ALT_CLAN_DISSOLVE_DAYS * 86400000L); // 24*60*60*1000 = 86400000
    clan.updateClanInDB();

    ClanTable.getInstance().scheduleRemoveClan(clan.getClanId());

    // The clan leader should take the XP penalty of a full death.
    player.deathPenalty(false, false, false);
  }
コード例 #4
0
ファイル: Hero.java プロジェクト: LucusAngel/L2J_Server_BETA
  public void loadDiary(int charId) {
    final List<StatsSet> _diary = new FastList<>();
    int diaryentries = 0;
    try (Connection con = L2DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement =
            con.prepareStatement("SELECT * FROM  heroes_diary WHERE charId=? ORDER BY time ASC")) {
      statement.setInt(1, charId);
      try (ResultSet rset = statement.executeQuery()) {
        while (rset.next()) {
          StatsSet _diaryentry = new StatsSet();

          long time = rset.getLong("time");
          int action = rset.getInt("action");
          int param = rset.getInt("param");

          String date = (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(time));
          _diaryentry.set("date", date);

          if (action == ACTION_RAID_KILLED) {
            L2NpcTemplate template = NpcData.getInstance().getTemplate(param);
            if (template != null) {
              _diaryentry.set("action", template.getName() + " was defeated");
            }
          } else if (action == ACTION_HERO_GAINED) {
            _diaryentry.set("action", "Gained Hero status");
          } else if (action == ACTION_CASTLE_TAKEN) {
            Castle castle = CastleManager.getInstance().getCastleById(param);
            if (castle != null) {
              _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
            }
          }
          _diary.add(_diaryentry);
          diaryentries++;
        }
      }
      _herodiary.put(charId, _diary);

      _log.info(
          "Hero System: Loaded "
              + diaryentries
              + " diary entries for Hero: "
              + CharNameTable.getInstance().getNameById(charId));
    } catch (SQLException e) {
      _log.log(Level.WARNING, "Hero System: Couldnt load Hero Diary for CharId: " + charId, e);
    }
  }
コード例 #5
0
  @Override
  public void onSpawn() {
    super.onSpawn();

    _fort = FortManager.getInstance().getFort(getX(), getY(), getZ());
    _castle = CastleManager.getInstance().getCastle(getX(), getY(), getZ());
    _hall = getConquerableHall();
    if ((_fort == null) && (_castle == null) && (_hall == null)) {
      _log.warning(
          "L2DefenderInstance spawned outside of Fortress, Castle or Siegable hall Zone! NpcId: "
              + getId()
              + " x="
              + getX()
              + " y="
              + getY()
              + " z="
              + getZ());
    }
  }
コード例 #6
0
ファイル: Hero.java プロジェクト: LucusAngel/L2J_Server_BETA
  public void setCastleTaken(int charId, int castleId) {
    setDiaryData(charId, ACTION_CASTLE_TAKEN, castleId);

    Castle castle = CastleManager.getInstance().getCastleById(castleId);
    if ((castle != null) && _herodiary.containsKey(charId)) {
      // Get Data
      List<StatsSet> _list = _herodiary.get(charId);
      // Clear old data
      _herodiary.remove(charId);
      // Prepare new data
      StatsSet _diaryentry = new StatsSet();
      String date =
          (new SimpleDateFormat("yyyy-MM-dd HH")).format(new Date(System.currentTimeMillis()));
      _diaryentry.set("date", date);
      _diaryentry.set("action", castle.getName() + " Castle was successfuly taken");
      // Add to old list
      _list.add(_diaryentry);
      // Put new list into diary
      _herodiary.put(charId, _list);
    }
  }
  @Override
  public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item) {
    if ((effector == null) || !effector.isPlayer()) {
      return !_val;
    }

    final L2PcInstance player = effector.getActingPlayer();
    boolean canSummonSiegeGolem = true;
    if (player.isAlikeDead() || player.isCursedWeaponEquipped() || (player.getClan() == null)) {
      canSummonSiegeGolem = false;
    }

    final Castle castle = CastleManager.getInstance().getCastle(player);
    final Fort fort = FortManager.getInstance().getFort(player);
    if ((castle == null) && (fort == null)) {
      canSummonSiegeGolem = false;
    }

    if (((fort != null) && (fort.getResidenceId() == 0))
        || ((castle != null) && (castle.getResidenceId() == 0))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if (((castle != null) && !castle.getSiege().isInProgress())
        || ((fort != null) && !fort.getSiege().isInProgress())) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((player.getClanId() != 0)
        && (((castle != null) && (castle.getSiege().getAttackerClan(player.getClanId()) == null))
            || ((fort != null) && (fort.getSiege().getAttackerClan(player.getClanId()) == null)))) {
      player.sendPacket(SystemMessageId.INCORRECT_TARGET);
      canSummonSiegeGolem = false;
    } else if ((SevenSigns.getInstance().checkSummonConditions(player))) {
      canSummonSiegeGolem = false;
    }
    return (_val == canSummonSiegeGolem);
  }
コード例 #8
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 /**
  * @return the castle contracted with this fortress ({@code null} if no contract with any castle)
  */
 public final Castle getContractedCastle() {
   return CastleManager.getInstance().getCastleById(getContractedCastleId());
 }
コード例 #9
0
ファイル: Fort.java プロジェクト: 3mRe/L2Java
 /**
  * @param npcId the Id of the ambassador NPC
  * @return the castle this ambassador represents
  */
 public final Castle getCastleByAmbassador(int npcId) {
   return CastleManager.getInstance().getCastleById(getCastleIdByAmbassador(npcId));
 }
コード例 #10
0
ファイル: Die.java プロジェクト: 54k/L2J_Server
  @Override
  protected final void writeImpl() {
    writeC(0x00);
    writeD(_charObjId);
    writeD(_canTeleport ? 0x01 : 0);
    if (_canTeleport && (_clan != null) && !_isJailed) {
      boolean isInCastleDefense = false;
      boolean isInFortDefense = false;

      L2SiegeClan siegeClan = null;
      Castle castle = CastleManager.getInstance().getCastle(_activeChar);
      Fort fort = FortManager.getInstance().getFort(_activeChar);
      SiegableHall hall = CHSiegeManager.getInstance().getNearbyClanHall(_activeChar);
      if ((castle != null) && castle.getSiege().getIsInProgress()) {
        // siege in progress
        siegeClan = castle.getSiege().getAttackerClan(_clan);
        if ((siegeClan == null) && castle.getSiege().checkIsDefender(_clan)) {
          isInCastleDefense = true;
        }
      } else if ((fort != null) && fort.getSiege().getIsInProgress()) {
        // siege in progress
        siegeClan = fort.getSiege().getAttackerClan(_clan);
        if ((siegeClan == null) && fort.getSiege().checkIsDefender(_clan)) {
          isInFortDefense = true;
        }
      }

      writeD(_clan.getHideoutId() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away
      writeD(
          (_clan.getCastleId() > 0) || isInCastleDefense
              ? 0x01
              : 0x00); // 6d 02 00 00 00 - to castle
      writeD(
          (TerritoryWarManager.getInstance().getFlagForClan(_clan) != null)
                  || ((siegeClan != null)
                      && !isInCastleDefense
                      && !isInFortDefense
                      && !siegeClan.getFlag().isEmpty())
                  || ((hall != null) && hall.getSiege().checkIsAttacker(_clan))
              ? 0x01
              : 0x00); // 6d 03 00 00 00 - to siege HQ
      writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow)
      writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED
      writeD(
          (_clan.getFortId() > 0) || isInFortDefense ? 0x01 : 0x00); // 6d 05 00 00 00 - to fortress
    } else {
      writeD(0x00); // 6d 01 00 00 00 - to hide away
      writeD(0x00); // 6d 02 00 00 00 - to castle
      writeD(0x00); // 6d 03 00 00 00 - to siege HQ
      writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow)
      writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED
      writeD(0x00); // 6d 05 00 00 00 - to fortress
    }
    // TODO: protocol 152
    // @formatter:off
    /*
     * writeC(0); //show die animation
     * writeD(0); //agathion ress button
     * writeD(0); //additional free space
     */
    // @formatter:on
  }
コード例 #11
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    final L2Npc manager = activeChar.getLastFolkNPC();
    if (!((manager instanceof L2ManorManagerInstance))) {
      return false;
    }

    if (!activeChar.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, true, false)) {
      return false;
    }

    try {
      final Castle castle = manager.getCastle();
      if (CastleManorManager.getInstance().isUnderMaintenance()) {
        activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        activeChar.sendPacket(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE);
        return true;
      }

      final StringTokenizer st = new StringTokenizer(command, "&");
      final int ask = Integer.parseInt(st.nextToken().split("=")[1]);
      final int state = Integer.parseInt(st.nextToken().split("=")[1]);
      final int time = Integer.parseInt(st.nextToken().split("=")[1]);

      final int castleId;
      if (state < 0) {
        castleId = castle.getResidenceId(); // info for current manor
      } else {
        castleId = state; // info for requested manor
      }

      switch (ask) {
        case 1: // Seed purchase
          if (castleId != castle.getResidenceId()) {
            SystemMessage sm =
                SystemMessage.getSystemMessage(
                    SystemMessageId.HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR);
            sm.addString(manager.getCastle().getName());
            activeChar.sendPacket(sm);
          } else {
            activeChar.sendPacket(
                new BuyListSeed(
                    activeChar.getAdena(),
                    castleId,
                    castle.getSeedProduction(CastleManorManager.PERIOD_CURRENT)));
          }
          break;
        case 2: // Crop sales
          activeChar.sendPacket(
              new ExShowSellCropList(
                  activeChar, castleId, castle.getCropProcure(CastleManorManager.PERIOD_CURRENT)));
          break;
        case 3: // Current seeds (Manor info)
          if ((time == 1)
              && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved()) {
            activeChar.sendPacket(new ExShowSeedInfo(castleId, null));
          } else {
            activeChar.sendPacket(
                new ExShowSeedInfo(
                    castleId,
                    CastleManager.getInstance().getCastleById(castleId).getSeedProduction(time)));
          }
          break;
        case 4: // Current crops (Manor info)
          if ((time == 1)
              && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved()) {
            activeChar.sendPacket(new ExShowCropInfo(castleId, null));
          } else {
            activeChar.sendPacket(
                new ExShowCropInfo(
                    castleId,
                    CastleManager.getInstance().getCastleById(castleId).getCropProcure(time)));
          }
          break;
        case 5: // Basic info (Manor info)
          activeChar.sendPacket(new ExShowManorDefaultInfo());
          break;
        case 6: // Buy harvester
          ((L2MerchantInstance) manager).showBuyWindow(activeChar, 300000 + manager.getId());
          break;
        case 9: // Edit sales (Crop sales)
          activeChar.sendPacket(new ExShowProcureCropDetail(state));
          break;
        default:
          return false;
      }
      return true;
    } catch (Exception e) {
      _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
    }
    return false;
  }