Package com.l2jfrozen.gameserver.model.entity.siege

Examples of com.l2jfrozen.gameserver.model.entity.siege.Castle


    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 if(SiegeManager.getInstance().checkIsRegistered(player.getClan(), castle.getCastleId()))
        {
          activeChar.sendMessage("Clan is already registered!");
        }
        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)
        {
          if(Config.ENABLE_ALL_EXCEPTIONS)
            e.printStackTrace();
         
          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");
        }

        clan = null;
      }
      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);
        }

        zone = null;
      }
      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());
      }

      player = null;
      target = null;
    }
View Full Code Here


  }
 
  @Override
  public void showChatWindow(L2PcInstance player)
  {
    Castle castle = null;
    switch (getNpcId())
        {
                case GLUDIO_MESSENGER:
                        castle = CastleManager.getInstance().getCastleById(1);
                        break;
View Full Code Here

    int index = getCastleIndex(obj);
    if(index < 0)
    {
      double closestDistance = 99999999;
      double distance;
      Castle castle;
      for(int i = 0; i < getCastles().size(); i++)
      {
        castle = getCastles().get(i);

        if(castle == null)
        {
          continue;
        }

        distance = castle.getDistance(obj);

        if(closestDistance > distance)
        {
          closestDistance = distance;
          index = i;
View Full Code Here

      PreparedStatement statement = con.prepareStatement("Select id from castle order by id");
      ResultSet rs = statement.executeQuery();

      while(rs.next())
      {
        getCastles().add(new Castle(rs.getInt("id")));
      }

      rs.close();
      statement.close();
View Full Code Here

    return getCastle(activeObject.getX(), activeObject.getY(), activeObject.getZ());
  }

  public final int getCastleIndex(int castleId)
  {
    Castle castle;
    for(int i = 0; i < getCastles().size(); i++)
    {
      castle = getCastles().get(i);
      if(castle != null && castle.getCastleId() == castleId)
      {
        castle = null;
        return i;
      }
    }
View Full Code Here

    return getCastleIndex(activeObject.getX(), activeObject.getY(), activeObject.getZ());
  }

  public final int getCastleIndex(int x, int y, int z)
  {
    Castle castle;
    for(int i = 0; i < getCastles().size(); i++)
    {
      castle = getCastles().get(i);
      if(castle != null && castle.checkIfInZone(x, y, z))
      {
        castle = null;
        return i;
      }
    }
View Full Code Here

  {}

  public ExShowSeedSetting(int manorId)
  {
    _manorId = manorId;
    Castle c = CastleManager.getInstance().getCastleById(_manorId);
    FastList<Integer> seeds = L2Manor.getInstance().getSeedsForCastle(_manorId);
    _count = seeds.size();
    _seedData = new int[_count * 12];
    int i = 0;
    for(int s : seeds)
    {
      _seedData[i * 12 + 0] = s;
      _seedData[i * 12 + 1] = L2Manor.getInstance().getSeedLevel(s);
      _seedData[i * 12 + 2] = L2Manor.getInstance().getRewardItemBySeed(s, 1);
      _seedData[i * 12 + 3] = L2Manor.getInstance().getRewardItemBySeed(s, 2);
      _seedData[i * 12 + 4] = L2Manor.getInstance().getSeedSaleLimit(s);
      _seedData[i * 12 + 5] = L2Manor.getInstance().getSeedBuyPrice(s);
      _seedData[i * 12 + 6] = L2Manor.getInstance().getSeedBasicPrice(s) * 60 / 100;
      _seedData[i * 12 + 7] = L2Manor.getInstance().getSeedBasicPrice(s) * 10;
      SeedProduction seedPr = c.getSeed(s, CastleManorManager.PERIOD_CURRENT);
      if(seedPr != null)
      {
        _seedData[i * 12 + 8] = seedPr.getStartProduce();
        _seedData[i * 12 + 9] = seedPr.getPrice();
      }
      else
      {
        _seedData[i * 12 + 8] = 0;
        _seedData[i * 12 + 9] = 0;
      }
      seedPr = c.getSeed(s, CastleManorManager.PERIOD_NEXT);
      if(seedPr != null)
      {
        _seedData[i * 12 + 10] = seedPr.getStartProduce();
        _seedData[i * 12 + 11] = seedPr.getPrice();
      }
View Full Code Here

    if(activeChar == null || !(activeChar instanceof L2PcInstance))
      return false;

    SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
    L2PcInstance player = (L2PcInstance) activeChar;
    Castle castle = CastleManager.getInstance().getCastle(player);

    if(castle == null || castle.getCastleId() <= 0)
    {
      sm.addString("You must be on castle ground to summon this");
    }
    else if(!castle.getSiege().getIsInProgress())
    {
      sm.addString("You can only summon this during a siege.");
    }
    else if(player.getClanId() != 0 && castle.getSiege().getAttackerClan(player.getClanId()) == null)
    {
      sm.addString("You can only summon this as a registered attacker.");
    }
    else
      return true;
View Full Code Here

      activeCharClanLeader = null;
    }

    if(activeCharClan != null)
    {
      Castle activeCharCastle = CastleManager.getInstance().getCastleByOwner(activeCharClan);

      if(activeCharCastle != null)
      {
        crownId = CrownTable.getCrownId(activeCharCastle.getCastleId());
      }

      activeCharCastle = null;

      if(activeCharClanLeader != null && activeCharClanLeader.getObjectId() == activeChar.getObjectId())
View Full Code Here

  {}

  public ExShowCropSetting(int manorId)
  {
    _manorId = manorId;
    Castle c = CastleManager.getInstance().getCastleById(_manorId);
    FastList<Integer> crops = L2Manor.getInstance().getCropsForCastle(_manorId);
    _count = crops.size();
    _cropData = new int[_count * 14];
    int i = 0;
    for(int cr : crops)
    {
      _cropData[i * 14 + 0] = cr;
      _cropData[i * 14 + 1] = L2Manor.getInstance().getSeedLevelByCrop(cr);
      _cropData[i * 14 + 2] = L2Manor.getInstance().getRewardItem(cr, 1);
      _cropData[i * 14 + 3] = L2Manor.getInstance().getRewardItem(cr, 2);
      _cropData[i * 14 + 4] = L2Manor.getInstance().getCropPuchaseLimit(cr);
      _cropData[i * 14 + 5] = 0; // Looks like not used
      _cropData[i * 14 + 6] = L2Manor.getInstance().getCropBasicPrice(cr) * 60 / 100;
      _cropData[i * 14 + 7] = L2Manor.getInstance().getCropBasicPrice(cr) * 10;
      CropProcure cropPr = c.getCrop(cr, CastleManorManager.PERIOD_CURRENT);
      if(cropPr != null)
      {
        _cropData[i * 14 + 8] = cropPr.getStartAmount();
        _cropData[i * 14 + 9] = cropPr.getPrice();
        _cropData[i * 14 + 10] = cropPr.getReward();
      }
      else
      {
        _cropData[i * 14 + 8] = 0;
        _cropData[i * 14 + 9] = 0;
        _cropData[i * 14 + 10] = 0;
      }
      cropPr = c.getCrop(cr, CastleManorManager.PERIOD_NEXT);
      if(cropPr != null)
      {
        _cropData[i * 14 + 11] = cropPr.getStartAmount();
        _cropData[i * 14 + 12] = cropPr.getPrice();
        _cropData[i * 14 + 13] = cropPr.getReward();
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.entity.siege.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.