ExShowDominionRegistry.java 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 com.l2jserver.gameserver.datatables.ClanTable;
  19. import com.l2jserver.gameserver.instancemanager.CastleManager;
  20. import com.l2jserver.gameserver.model.L2Clan;
  21. import com.l2jserver.gameserver.model.entity.Castle;
  22. /**
  23. * format: dSSSdddddddd (dd(d))
  24. * @author GodKratos
  25. */
  26. public class ExShowDominionRegistry extends L2GameServerPacket
  27. {
  28. private int _territoryId;
  29. private int _clanReq = 0x00;
  30. private int _mercReq = 0x00;
  31. private String _clanName = "";
  32. private String _clanLeader = "";
  33. private String _allyName = "";
  34. private int _warTime = (int) (Calendar.getInstance().getTimeInMillis() / 1000);
  35. private int _currentTime = (int) (Calendar.getInstance().getTimeInMillis() / 1000);
  36. public ExShowDominionRegistry(int castleId)
  37. {
  38. _territoryId = 0x50 + castleId;
  39. int owner = CastleManager.getInstance().getCastleById(castleId).getOwnerId();
  40. if (owner != 0)
  41. {
  42. try
  43. {
  44. L2Clan clan = ClanTable.getInstance().getClan(owner);
  45. _clanName = clan.getName();
  46. _clanLeader = clan.getLeaderName();
  47. _allyName = clan.getAllyName();
  48. }
  49. catch (Exception e)
  50. {
  51. e.printStackTrace();
  52. }
  53. }
  54. }
  55. /**
  56. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
  57. */
  58. @Override
  59. public String getType()
  60. {
  61. return "[S] FE:90 ExShowDominionRegistry";
  62. }
  63. /**
  64. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
  65. */
  66. @Override
  67. protected void writeImpl()
  68. {
  69. writeC(0xfe);
  70. writeH(0x90);
  71. writeD(_territoryId); // Current Territory Id
  72. writeS(_clanName); // Owners Clan
  73. writeS(_clanLeader); // Owner Clan Leader
  74. writeS(_allyName); // Owner Alliance
  75. writeD(_clanReq); // Clan Request
  76. writeD(_mercReq); // Merc Request
  77. writeD(_warTime); // War Time
  78. writeD(_currentTime); // Current Time
  79. writeD(0x00); // unknown
  80. writeD(0x00); // unknown
  81. writeD(0x01); // unknown
  82. List<Castle> castles = CastleManager.getInstance().getCastles();
  83. writeD(castles.size());
  84. for (Castle castle : castles)
  85. {
  86. writeD(0x50 + castle.getCastleId()); // Territory Id
  87. writeD(0x01); // Emblem Count
  88. writeD(0x50 + castle.getCastleId()); // Emblem ID - should be in for loop for emblem
  89. // count
  90. }
  91. }
  92. }