RequestGiveNickName.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.gameserver.model.L2Clan;
  18. import com.l2jserver.gameserver.model.L2ClanMember;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  22. /**
  23. * This class ...
  24. *
  25. * @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/03/27 15:29:30 $
  26. */
  27. public class RequestGiveNickName extends L2GameClientPacket
  28. {
  29. private static final String _C__55_REQUESTGIVENICKNAME = "[C] 55 RequestGiveNickName";
  30. static Logger _log = Logger.getLogger(RequestGiveNickName.class.getName());
  31. private String _target;
  32. private String _title;
  33. @Override
  34. protected void readImpl()
  35. {
  36. _target = readS();
  37. _title = readS();
  38. }
  39. @Override
  40. protected void runImpl()
  41. {
  42. L2PcInstance activeChar = getClient().getActiveChar();
  43. if (activeChar == null)
  44. return;
  45. // Noblesse can bestow a title to themselves
  46. if (activeChar.isNoble() && _target.matches(activeChar.getName()))
  47. {
  48. activeChar.setTitle(_title);
  49. SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED);
  50. activeChar.sendPacket(sm);
  51. activeChar.broadcastTitleInfo();
  52. }
  53. //Can the player change/give a title?
  54. else if ((activeChar.getClanPrivileges() & L2Clan.CP_CL_GIVE_TITLE) == L2Clan.CP_CL_GIVE_TITLE)
  55. {
  56. if (activeChar.getClan().getLevel() < 3)
  57. {
  58. SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_LVL_3_NEEDED_TO_ENDOWE_TITLE);
  59. activeChar.sendPacket(sm);
  60. sm = null;
  61. return;
  62. }
  63. L2ClanMember member1 = activeChar.getClan().getClanMember(_target);
  64. if (member1 != null)
  65. {
  66. L2PcInstance member = member1.getPlayerInstance();
  67. if (member != null)
  68. {
  69. //is target from the same clan?
  70. member.setTitle(_title);
  71. SystemMessage sm = new SystemMessage(SystemMessageId.TITLE_CHANGED);
  72. member.sendPacket(sm);
  73. member.broadcastTitleInfo();
  74. sm = null;
  75. }
  76. else
  77. activeChar.sendMessage("Target needs to be online to get a title");
  78. }
  79. else
  80. activeChar.sendMessage("Target does not belong to your clan");
  81. }
  82. }
  83. /* (non-Javadoc)
  84. * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
  85. */
  86. @Override
  87. public String getType()
  88. {
  89. return _C__55_REQUESTGIVENICKNAME;
  90. }
  91. }