Ejemplo n.º 1
0
  private static void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall) {
    final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());

    final NpcHtmlMessage html = new NpcHtmlMessage(0);
    html.setFile("data/html/admin/clanhall.htm");
    html.replace("%clanhallName%", clanhall.getName());
    html.replace("%clanhallId%", clanhall.getId());
    html.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
    activeChar.sendPacket(html);
  }
Ejemplo n.º 2
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    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());

    if (clanhall == null && (castle == null || castle.getCastleId() < 0)) {
      showCastleSelectPage(activeChar);
      return true;
    }

    L2Object target = activeChar.getTarget();
    L2PcInstance player = null;
    if (target instanceof L2PcInstance) player = (L2PcInstance) target;

    if (castle != null) {
      if (command.equalsIgnoreCase("admin_add_attacker")) {
        if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else castle.getSiege().registerAttacker(player);
      } else if (command.equalsIgnoreCase("admin_add_defender")) {
        if (player == null) activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else castle.getSiege().registerDefender(player);
      } else if (command.equalsIgnoreCase("admin_add_guard")) {
        try {
          int npcId = Integer.parseInt(st.nextToken());
          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(SystemMessageId.TARGET_IS_INCORRECT);
        else if (player.getClan().hasCastle())
          activeChar.sendMessage(player.getName() + "'s clan already owns a castle.");
        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 for this clan.");
      } else if (command.equalsIgnoreCase("admin_spawn_doors")) {
        castle.spawnDoors(false);
      } else if (command.equalsIgnoreCase("admin_startsiege")) {
        castle.getSiege().startSiege();
      }
      showSiegePage(activeChar, castle.getName());
    } else if (clanhall != null) {
      if (command.equalsIgnoreCase("admin_clanhallset")) {
        if (player == null || player.getClan() == null)
          activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
        else if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
          activeChar.sendMessage("This ClanHall isn't free!");
        else if (!player.getClan().hasHideout()) {
          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.getSpawnLoc(), 0);
      }
      showClanHallPage(activeChar, clanhall);
    }
    return true;
  }
Ejemplo n.º 3
0
  private static void showCastleSelectPage(L2PcInstance activeChar) {
    int i = 0;

    final NpcHtmlMessage html = new NpcHtmlMessage(0);
    html.setFile("data/html/admin/castles.htm");

    final StringBuilder sb = new StringBuilder();
    for (Castle castle : CastleManager.getInstance().getCastles()) {
      if (castle != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=90><a action=\"bypass -h admin_siege ",
            castle.getName(),
            "\">",
            castle.getName(),
            "</a></td>");
        i++;
      }

      if (i > 2) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%castles%", sb.toString());

    // Cleanup sb.
    sb.setLength(0);
    i = 0;

    for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values()) {
      if (clanhall != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=134><a action=\"bypass -h admin_clanhall ",
            clanhall.getId(),
            "\">",
            clanhall.getName(),
            "</a></td>");
        i++;
      }

      if (i > 1) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%clanhalls%", sb.toString());

    // Cleanup sb.
    sb.setLength(0);
    i = 0;

    for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values()) {
      if (clanhall != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=134><a action=\"bypass -h admin_clanhall ",
            clanhall.getId(),
            "\">",
            clanhall.getName(),
            "</a></td>");
        i++;
      }

      if (i > 1) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%freeclanhalls%", sb.toString());
    activeChar.sendPacket(html);
  }