Package net.sf.l2j.gameserver.model.entity

Examples of net.sf.l2j.gameserver.model.entity.Castle


    {
      _log.warning("Living player ["+activeChar.getName()+"] called RestartPointPacket! Ban this player!");
      return;
    }

    Castle castle = CastleManager.getInstance().getCastle(activeChar.getX(), activeChar.getY(), activeChar.getZ());
    if (castle != null && castle.getSiege().getIsInProgress())
    {
      //DeathFinalizer df = new DeathFinalizer(10000);
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
      if (activeChar.getClan() != null && castle.getSiege().checkIsAttacker(activeChar.getClan()))
      {
        // Schedule respawn delay for attacker
        ThreadPoolManager.getInstance().scheduleGeneral(new DeathTask(activeChar), castle.getSiege().getAttackerRespawnDelay());
        sm.addString("You will be re-spawned in " + castle.getSiege().getAttackerRespawnDelay()/1000 + " seconds");
        activeChar.sendPacket(sm);
      }
      else
      {
        // Schedule respawn delay for defender with penalty for CT lose
        ThreadPoolManager.getInstance().scheduleGeneral(new DeathTask(activeChar), castle.getSiege().getDefenderRespawnDelay());
        sm.addString("You will be re-spawned in " + castle.getSiege().getDefenderRespawnDelay()/1000 + " seconds");
        activeChar.sendPacket(sm);
      }
      sm = null;
      return;
    }
View Full Code Here


    public void run()
    {
      try
      {
        Location loc = null;
        Castle castle=null;

        if (activeChar.isInJail()) _requestedPointType = 27;
        else if (activeChar.isFestivalParticipant()) _requestedPointType = 4;

        switch (_requestedPointType)
        {
          case 1: // to clanhall
            if (activeChar.getClan().getHasHideout() == 0)
            {
              //cheater
              activeChar.sendMessage("You may not use this respawn point!");
              Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " used respawn cheat.", IllegalPlayerAction.PUNISH_KICK);
              return;
            }
            loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClanHall);

            if (ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan())!= null &&
                ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP) != null)
            {
              activeChar.restoreExp(ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP).getLvl());
            }
            break;

          case 2: // to castle
            Boolean isInDefense = false;
            castle = CastleManager.getInstance().getCastle(activeChar);
            if (castle != null && castle.getSiege().getIsInProgress())
            {
              //siege in progress
              if (castle.getSiege().checkIsDefender(activeChar.getClan()))
                isInDefense = true;
            }
            if (activeChar.getClan().getHasCastle() == 0 && !isInDefense)
            {
              //cheater
              activeChar.sendMessage("You may not use this respawn point!");
              Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " used respawn cheat.", IllegalPlayerAction.PUNISH_KICK);
              return;
            }
            loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Castle);
            break;

          case 3: // to siege HQ
            L2SiegeClan siegeClan = null;
            castle = CastleManager.getInstance().getCastle(activeChar);

            if (castle != null && castle.getSiege().getIsInProgress())
              siegeClan = castle.getSiege().getAttackerClan(activeChar.getClan());

            if (siegeClan == null || siegeClan.getFlag().size() == 0)
            {
              //cheater
              activeChar.sendMessage("You may not use this respawn point!");
View Full Code Here

      try {
        castleId = Integer.parseInt(st.nextToken());
      } catch (Exception e) {}

      if (castleId>0) {
        Castle castle = CastleManager.getInstance().getCastleById(castleId);
        castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
        castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
        castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
        castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);
        if (Config.ALT_MANOR_SAVE_ALL_ACTIONS) {
          castle.saveCropData();
          castle.saveSeedData();
        }
        activeChar.sendMessage("Manor data for " + castle.getName() + " was nulled");
      } else {
        for (Castle castle : CastleManager.getInstance().getCastles()) {
          castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
          castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
          castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
          castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);
          if (Config.ALT_MANOR_SAVE_ALL_ACTIONS) {
            castle.saveCropData();
            castle.saveSeedData();
          }
        }
        activeChar.sendMessage("Manor data was nulled");
      }
      showMainPage(activeChar);
View Full Code Here

    StringTokenizer st = new StringTokenizer(command, " ");
    command = st.nextToken(); // Get actual command

    // Get castle
    Castle castle = null;
    ClanHall clanhall = null;
    if (command.startsWith("admin_clanhall"))
      clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(st.nextToken()));
    else if (st.hasMoreTokens())
      castle = CastleManager.getInstance().getCastle(st.nextToken());
    // Get castle
    String val = "";
    if (st.hasMoreTokens())
      val = st.nextToken();
    if ((castle == null  || castle.getCastleId() < 0) && clanhall == null)
      // No castle specified
      showCastleSelectPage(activeChar);
    else
    {
      L2Object target = activeChar.getTarget();
      L2PcInstance player = null;
      if (target instanceof L2PcInstance)
        player = (L2PcInstance)target;

      if (command.equalsIgnoreCase("admin_add_attacker"))
      {
        if (player == null)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
        else
          castle.getSiege().registerAttacker(player,true);
      }
      else if (command.equalsIgnoreCase("admin_add_defender"))
      {
        if (player == null)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
        else
          castle.getSiege().registerDefender(player,true);
      }
      else if (command.equalsIgnoreCase("admin_add_guard"))
      {
        try
        {
          int npcId = Integer.parseInt(val);
          castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, npcId);
        }
        catch (Exception e)
        {
          activeChar.sendMessage("Usage: //add_guard npcId");
        }
      }
      else if (command.equalsIgnoreCase("admin_clear_siege_list"))
      {
        castle.getSiege().clearSiegeClan();
      }
      else if (command.equalsIgnoreCase("admin_endsiege"))
      {
        castle.getSiege().endSiege();
      }
      else if (command.equalsIgnoreCase("admin_list_siege_clans"))
      {
        castle.getSiege().listRegisterClan(activeChar);
        return true;
      }
      else if (command.equalsIgnoreCase("admin_move_defenders"))
      {
        activeChar.sendPacket(SystemMessage.sendString("Not implemented yet."));
      }
      else if (command.equalsIgnoreCase("admin_setcastle"))
      {
        if (player == null || player.getClan() == null)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
        else
          castle.setOwner(player.getClan());
      }
      else if (command.equalsIgnoreCase("admin_removecastle"))
      {
        L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
        if (clan != null)
          castle.removeOwner(clan);
        else
          activeChar.sendMessage("Unable to remove castle");
      }
      else if (command.equalsIgnoreCase("admin_clanhallset"))
      {
        if (player == null || player.getClan() == null)
          activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
        else if(!ClanHallManager.getInstance().isFree(clanhall.getId()))
          activeChar.sendMessage("This ClanHall isn't free!");
        else if(player.getClan().getHasHideout() == 0)
        {
          ClanHallManager.getInstance().setOwner(clanhall.getId(), player.getClan());
          if(AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
            AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
        }
        else
          activeChar.sendMessage("You have already a ClanHall!");
      }
      else if (command.equalsIgnoreCase("admin_clanhalldel"))
      {
        if(!ClanHallManager.getInstance().isFree(clanhall.getId())){
          ClanHallManager.getInstance().setFree(clanhall.getId());
          AuctionManager.getInstance().initNPC(clanhall.getId());
        }else
          activeChar.sendMessage("This ClanHall is already Free!");
      }
      else if (command.equalsIgnoreCase("admin_clanhallopendoors"))
      {
        clanhall.openCloseDoors(true);
      }
      else if (command.equalsIgnoreCase("admin_clanhallclosedoors"))
      {
        clanhall.openCloseDoors(false);
      }
      else if (command.equalsIgnoreCase("admin_clanhallteleportself"))
      {
        L2ClanHallZone zone = clanhall.getZone();
        if (zone != null)
        {
          activeChar.teleToLocation(zone.getSpawn(), true);
        }
      }
      else if (command.equalsIgnoreCase("admin_spawn_doors"))
      {
        castle.spawnDoor();
      }
      else if (command.equalsIgnoreCase("admin_startsiege"))
      {
        castle.getSiege().startSiege();
      }
      if (clanhall != null)
        showClanHallPage(activeChar, clanhall);
      else
        showSiegePage(activeChar, castle.getName());
    }
    return true;
  }
View Full Code Here

    }

    @Override
  protected void runImpl()
    {
        Castle castle = CastleManager.getInstance().getCastleById(_castleId);
        if (castle == null) return;
        SiegeAttackerList sal = new SiegeAttackerList(castle);
        sendPacket(sal);
    }
View Full Code Here

        L2PcInstance player = (L2PcInstance)activeChar;

        if (player.getClan() == null || player.getClan().getLeaderId() != player.getObjectId()) return;

        Castle castle = CastleManager.getInstance().getCastle(player);

        if (castle == null || !checkIfOkToPlaceFlag(player, castle, true)) return;

        try
        {
            // Spawn a new flag
            L2SiegeFlagInstance flag = new L2SiegeFlagInstance(player, IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(35062));
            flag.setTitle(player.getClan().getName());
            flag.setCurrentHpMp(flag.getMaxHp(), flag.getMaxMp());
            flag.setHeading(player.getHeading());
            flag.spawnMe(player.getX(), player.getY(), player.getZ() + 50);
            castle.getSiege().getFlag(player.getClan()).add(flag);
        }
        catch (Exception e)
        {
            player.sendMessage("Error placing flag:" + e);
        }
View Full Code Here

      target = player.getLastFolkNPC();

    if (!(target instanceof L2ManorManagerInstance))
      return;

    Castle castle = CastleManager.getInstance().getCastleById(_manorId);

    for (int i = 0; i < _count; i++)
    {
      int seedId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];
      int price = 0;
      int residual = 0;

      SeedProduction seed = castle.getSeed(seedId,CastleManorManager.PERIOD_CURRENT);
      price = seed.getPrice();
      residual = seed.getCanProduce();

      if (price <= 0)
        return;

      if (residual < count)
        return;

      totalPrice += count * price;

      L2Item template = ItemTable.getInstance().getTemplate(seedId);
      totalWeight += count * template.getWeight();
      if (!template.isStackable())
        slots += count;
      else if (player.getInventory().getItemByItemId(seedId) == null)
        slots++;
    }

    if (totalPrice > Integer.MAX_VALUE)
    {
      Util.handleIllegalPlayerAction(player, "Warning!! Character "
          + player.getName() + " of account "
          + player.getAccountName() + " tried to purchase over "
          + Integer.MAX_VALUE + " adena worth of goods.",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (!player.getInventory().validateWeight(totalWeight))
    {
      sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
      return;
    }

    if (!player.getInventory().validateCapacity(slots))
    {
      sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
      return;
    }

    // Charge buyer
    if ((totalPrice < 0) || !player.reduceAdena("Buy", (int) totalPrice, target, false))
    {
      sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
      return;
    }

    // Adding to treasury for Manor Castle
    castle.addToTreasuryNoTax((int) totalPrice);

    // Proceed the purchase
    InventoryUpdate playerIU = new InventoryUpdate();
    for (int i = 0; i < _count; i++)
    {
      int seedId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];
      if (count < 0)
        count = 0;

      // Update Castle Seeds Amount
      SeedProduction seed = castle.getSeed(seedId,
          CastleManorManager.PERIOD_CURRENT);
      seed.setCanProduce(seed.getCanProduce() - count);
      if (Config.ALT_MANOR_SAVE_ALL_ACTIONS)
        CastleManager.getInstance().getCastleById(_manorId).updateSeed(
            seed.getId(), seed.getCanProduce(),
View Full Code Here

        if(activeChar == null) return;

        // Check if the player has a clan
        if (activeChar.getClan() == null) return;

        Castle castle = CastleManager.getInstance().getCastleById(_castleId);
        if (castle == null) return;

        // Check if leader of the clan who owns the castle?
        if ((castle.getOwnerId() != activeChar.getClanId()) || (!activeChar.isClanLeader())) return;

        L2Clan clan = ClanTable.getInstance().getClan(_clanId);
        if (clan == null) return;

        if (!castle.getSiege().getIsRegistrationOver())
        {
            if (_approved == 1)
            {
                if (castle.getSiege().checkIsDefenderWaiting(clan))
                    castle.getSiege().approveSiegeDefenderClan(_clanId);
                else
                    return;
            }
            else
            {
                if ((castle.getSiege().checkIsDefenderWaiting(clan)) || (castle.getSiege().checkIsDefender(clan)))
                    castle.getSiege().removeSiegeClan(_clanId);
            }
        }

        //Update the defender list
        activeChar.sendPacket(new SiegeDefenderList(castle));
View Full Code Here

    {
        L2PcInstance activeChar = getClient().getActiveChar();
        if(activeChar == null) return;
        if (!activeChar.isClanLeader()) return;

        Castle castle = CastleManager.getInstance().getCastleById(_castleId);
        if (castle == null) return;

        if (_isJoining == 1)
        {
          if (System.currentTimeMillis() < activeChar.getClan().getDissolvingExpiryTime())
          {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.CANT_PARTICIPATE_IN_SIEGE_WHILE_DISSOLUTION_IN_PROGRESS));
            return;
          }
            if (_isAttacker == 1)
                castle.getSiege().registerAttacker(activeChar);
            else
                castle.getSiege().registerDefender(activeChar);
        }
        else
            castle.getSiege().removeSiegeClan(activeChar);

        castle.getSiege().listRegisterClan(activeChar);
    }
View Full Code Here

        L2PcInstance player = (L2PcInstance)activeChar;

        if (player.getClan() == null || player.getClan().getLeaderId() != player.getObjectId()) return;

        Castle castle = CastleManager.getInstance().getCastle(player);
        if (castle == null || !checkIfOkToCastSealOfRule(player, castle, true)) return;

        try
        {
          if(targets[0] instanceof L2ArtefactInstance)
            castle.Engrave(player.getClan(), targets[0].getObjectId());
        }
        catch(Exception e)
        {}
    }
View Full Code Here

TOP

Related Classes of net.sf.l2j.gameserver.model.entity.Castle

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.