RequestExSetPledgeCrestLarge.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import com.l2jserver.gameserver.data.sql.impl.CrestTable;
  21. import com.l2jserver.gameserver.model.ClanPrivilege;
  22. import com.l2jserver.gameserver.model.L2Clan;
  23. import com.l2jserver.gameserver.model.L2Crest;
  24. import com.l2jserver.gameserver.model.L2Crest.CrestType;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. /**
  28. * Format : chdb c (id) 0xD0 h (subid) 0x11 d data size b raw data (picture i think ;) )
  29. * @author -Wooden-
  30. */
  31. public final class RequestExSetPledgeCrestLarge extends L2GameClientPacket
  32. {
  33. private static final String _C__D0_11_REQUESTEXSETPLEDGECRESTLARGE = "[C] D0:11 RequestExSetPledgeCrestLarge";
  34. private int _length;
  35. private byte[] _data = null;
  36. @Override
  37. protected void readImpl()
  38. {
  39. _length = readD();
  40. if (_length > 2176)
  41. {
  42. return;
  43. }
  44. _data = new byte[_length];
  45. readB(_data);
  46. }
  47. @Override
  48. protected void runImpl()
  49. {
  50. final L2PcInstance activeChar = getClient().getActiveChar();
  51. if (activeChar == null)
  52. {
  53. return;
  54. }
  55. final L2Clan clan = activeChar.getClan();
  56. if (clan == null)
  57. {
  58. return;
  59. }
  60. if ((_length < 0) || (_length > 2176))
  61. {
  62. activeChar.sendPacket(SystemMessageId.WRONG_SIZE_UPLOADED_CREST);
  63. return;
  64. }
  65. if (clan.getDissolvingExpiryTime() > System.currentTimeMillis())
  66. {
  67. activeChar.sendPacket(SystemMessageId.CANNOT_SET_CREST_WHILE_DISSOLUTION_IN_PROGRESS);
  68. return;
  69. }
  70. if (!activeChar.hasClanPrivilege(ClanPrivilege.CL_REGISTER_CREST))
  71. {
  72. activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  73. return;
  74. }
  75. if (_length == 0)
  76. {
  77. if (clan.getCrestLargeId() != 0)
  78. {
  79. clan.changeLargeCrest(0);
  80. activeChar.sendPacket(SystemMessageId.CLAN_CREST_HAS_BEEN_DELETED);
  81. }
  82. }
  83. else
  84. {
  85. if (clan.getLevel() < 3)
  86. {
  87. activeChar.sendPacket(SystemMessageId.CLAN_LVL_3_NEEDED_TO_SET_CREST);
  88. return;
  89. }
  90. final L2Crest crest = CrestTable.getInstance().createCrest(_data, CrestType.PLEDGE_LARGE);
  91. if (crest != null)
  92. {
  93. clan.changeLargeCrest(crest.getId());
  94. activeChar.sendPacket(SystemMessageId.CLAN_EMBLEM_WAS_SUCCESSFULLY_REGISTERED);
  95. }
  96. }
  97. }
  98. @Override
  99. public String getType()
  100. {
  101. return _C__D0_11_REQUESTEXSETPLEDGECRESTLARGE;
  102. }
  103. }