RequestOustFromPartyRoom.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 com.l2jserver.gameserver.model.L2World;
  17. import com.l2jserver.gameserver.model.PartyMatchRoom;
  18. import com.l2jserver.gameserver.model.PartyMatchRoomList;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.ExClosePartyRoom;
  22. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  23. /**
  24. * format (ch) d
  25. * @author -Wooden-
  26. *
  27. */
  28. public final class RequestOustFromPartyRoom extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_09_REQUESTOUSTFROMPARTYROOM = "[C] D0:09 RequestOustFromPartyRoom";
  31. private int _charid;
  32. @Override
  33. protected void readImpl()
  34. {
  35. _charid = readD();
  36. }
  37. @Override
  38. protected void runImpl()
  39. {
  40. L2PcInstance activeChar = getClient().getActiveChar();
  41. if (activeChar == null)
  42. return;
  43. L2PcInstance member = L2World.getInstance().getPlayer(_charid);
  44. if (member == null)
  45. return;
  46. PartyMatchRoom _room = PartyMatchRoomList.getInstance().getPlayerRoom(member);
  47. if (_room == null)
  48. return;
  49. if (_room.getOwner() != activeChar)
  50. return;
  51. if (activeChar.isInParty() && member.isInParty() && activeChar.getParty().getPartyLeaderOID() == member.getParty().getPartyLeaderOID())
  52. {
  53. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_DISMISS_PARTY_MEMBER));
  54. }
  55. else
  56. {
  57. _room.deleteMember(member);
  58. member.setPartyRoom(0);
  59. member.sendPacket(new ExClosePartyRoom());
  60. member.sendPacket(new SystemMessage(SystemMessageId.OUSTED_FROM_PARTY_ROOM));
  61. }
  62. }
  63. @Override
  64. public String getType()
  65. {
  66. return _C__D0_09_REQUESTOUSTFROMPARTYROOM;
  67. }
  68. }