ExReplyDominionInfo.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.Calendar;
  17. import java.util.List;
  18. import java.util.logging.Logger;
  19. import com.l2jserver.gameserver.datatables.ClanTable;
  20. import com.l2jserver.gameserver.instancemanager.CastleManager;
  21. import com.l2jserver.gameserver.model.entity.Castle;
  22. /**
  23. *
  24. * @author JIV
  25. */
  26. public class ExReplyDominionInfo extends L2GameServerPacket
  27. {
  28. /**
  29. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
  30. */
  31. private static Logger _log = Logger.getLogger(ExReplyDominionInfo.class.getName());
  32. private int _warTime = (int) (Calendar.getInstance().getTimeInMillis() / 1000);
  33. /**
  34. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
  35. */
  36. @Override
  37. protected void writeImpl()
  38. {
  39. writeC(0xfe);
  40. writeH(0x92);
  41. List<Castle> castles = CastleManager.getInstance().getCastles();
  42. writeD(castles.size());
  43. for (Castle castle : castles)
  44. {
  45. writeD(0x50 + castle.getCastleId()); // territory ID
  46. writeS(castle.getName().toLowerCase() + "_dominion"); // territory name
  47. if (castle.getOwnerId() > 0)
  48. {
  49. if (ClanTable.getInstance().getClan(castle.getOwnerId()) != null)
  50. writeS(ClanTable.getInstance().getClan(castle.getOwnerId()).getName());
  51. else
  52. {
  53. _log.warning("Castle owner with no name! Castle: " + castle.getName()
  54. + " has an OwnerId = " + castle.getOwnerId()
  55. + " who does not have a name!");
  56. writeS("");
  57. }
  58. }
  59. else
  60. writeS("");
  61. writeD(1); // wards count
  62. writeD(0x50 + castle.getCastleId()); // territory ID's
  63. writeD(_warTime);
  64. }
  65. }
  66. @Override
  67. public String getType()
  68. {
  69. return "[S] FE:92 ExReplyDominionInfo";
  70. }
  71. }