RequestWithdrawPartyRoom.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.model.PartyMatchRoom;
  21. import com.l2jserver.gameserver.model.PartyMatchRoomList;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.SystemMessageId;
  24. import com.l2jserver.gameserver.network.serverpackets.ExClosePartyRoom;
  25. /**
  26. * @author Gnacik
  27. */
  28. public final class RequestWithdrawPartyRoom extends L2GameClientPacket
  29. {
  30. private static final String _C__D0_0B_REQUESTWITHDRAWPARTYROOM = "[C] D0:0B RequestWithdrawPartyRoom";
  31. private int _roomid;
  32. @SuppressWarnings("unused")
  33. private int _unk1;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _roomid = readD();
  38. _unk1 = readD();
  39. }
  40. @Override
  41. protected void runImpl()
  42. {
  43. final L2PcInstance _activeChar = getClient().getActiveChar();
  44. if (_activeChar == null)
  45. {
  46. return;
  47. }
  48. PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(_roomid);
  49. if (_room == null)
  50. {
  51. return;
  52. }
  53. if ((_activeChar.isInParty() && _room.getOwner().isInParty()) && (_activeChar.getParty().getLeaderObjectId() == _room.getOwner().getParty().getLeaderObjectId()))
  54. {
  55. // If user is in party with Room Owner
  56. // is not removed from Room
  57. // _activeChar.setPartyMatching(0);
  58. _activeChar.broadcastUserInfo();
  59. }
  60. else
  61. {
  62. _room.deleteMember(_activeChar);
  63. _activeChar.setPartyRoom(0);
  64. // _activeChar.setPartyMatching(0);
  65. _activeChar.sendPacket(new ExClosePartyRoom());
  66. _activeChar.sendPacket(SystemMessageId.PARTY_ROOM_EXITED);
  67. }
  68. }
  69. @Override
  70. public String getType()
  71. {
  72. return _C__D0_0B_REQUESTWITHDRAWPARTYROOM;
  73. }
  74. }