ExShowCastleInfo.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.serverpackets;
  16. import java.util.List;
  17. import java.util.logging.Logger;
  18. import com.l2jserver.gameserver.datatables.ClanTable;
  19. import com.l2jserver.gameserver.instancemanager.CastleManager;
  20. import com.l2jserver.gameserver.model.entity.Castle;
  21. /**
  22. *
  23. * @author KenM
  24. */
  25. public class ExShowCastleInfo extends L2GameServerPacket
  26. {
  27. /**
  28. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
  29. */
  30. private static Logger _log = Logger.getLogger(ExShowCastleInfo.class.getName());
  31. @Override
  32. public String getType()
  33. {
  34. return "[S] FE:14 ExShowCastleInfo";
  35. }
  36. /**
  37. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
  38. */
  39. @Override
  40. protected void writeImpl()
  41. {
  42. writeC(0xfe);
  43. writeH(0x14);
  44. List<Castle> castles = CastleManager.getInstance().getCastles();
  45. writeD(castles.size());
  46. for (Castle castle : castles)
  47. {
  48. writeD(castle.getCastleId());
  49. if (castle.getOwnerId() > 0)
  50. {
  51. if (ClanTable.getInstance().getClan(castle.getOwnerId()) != null)
  52. writeS(ClanTable.getInstance().getClan(castle.getOwnerId()).getName());
  53. else
  54. {
  55. _log.warning("Castle owner with no name! Castle: " + castle.getName() + " has an OwnerId = " + castle.getOwnerId() + " who does not have a name!");
  56. writeS("");
  57. }
  58. }
  59. else
  60. writeS("");
  61. writeD(castle.getTaxPercent());
  62. writeD((int)(castle.getSiege().getSiegeDate().getTimeInMillis()/1000));
  63. }
  64. }
  65. }