PartyInfo.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 handlers.usercommandhandlers;
  16. import com.l2jserver.gameserver.handler.IUserCommandHandler;
  17. import com.l2jserver.gameserver.model.L2Party;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.SystemMessageId;
  20. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  21. /**
  22. * Support for /partyinfo command
  23. * Added by Tempy - 28 Jul 05
  24. */
  25. public class PartyInfo implements IUserCommandHandler
  26. {
  27. private static final int[] COMMAND_IDS =
  28. {
  29. 81
  30. };
  31. /**
  32. *
  33. * @see com.l2jserver.gameserver.handler.IUserCommandHandler#useUserCommand(int, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
  34. */
  35. @Override
  36. public boolean useUserCommand(int id, L2PcInstance activeChar)
  37. {
  38. if (id != COMMAND_IDS[0])
  39. return false;
  40. if (!activeChar.isInParty())
  41. {
  42. activeChar.sendPacket(SystemMessageId.PARTY_INFORMATION);
  43. activeChar.sendPacket(SystemMessageId.FRIEND_LIST_FOOTER);
  44. return false;
  45. }
  46. L2Party playerParty = activeChar.getParty();
  47. int memberCount = playerParty.getMemberCount();
  48. int lootDistribution = playerParty.getLootDistribution();
  49. String partyLeader = playerParty.getPartyMembers().get(0).getName();
  50. activeChar.sendPacket(SystemMessageId.PARTY_INFORMATION);
  51. switch (lootDistribution)
  52. {
  53. case L2Party.ITEM_LOOTER:
  54. activeChar.sendPacket(SystemMessageId.LOOTING_FINDERS_KEEPERS);
  55. break;
  56. case L2Party.ITEM_ORDER:
  57. activeChar.sendPacket(SystemMessageId.LOOTING_BY_TURN);
  58. break;
  59. case L2Party.ITEM_ORDER_SPOIL:
  60. activeChar.sendPacket(SystemMessageId.LOOTING_BY_TURN_INCLUDE_SPOIL);
  61. break;
  62. case L2Party.ITEM_RANDOM:
  63. activeChar.sendPacket(SystemMessageId.LOOTING_RANDOM);
  64. break;
  65. case L2Party.ITEM_RANDOM_SPOIL:
  66. activeChar.sendPacket(SystemMessageId.LOOTING_RANDOM_INCLUDE_SPOIL);
  67. break;
  68. }
  69. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PARTY_LEADER_C1);
  70. sm.addString(partyLeader);
  71. activeChar.sendPacket(sm);
  72. activeChar.sendMessage("Members: " + memberCount + "/9");
  73. activeChar.sendPacket(SystemMessageId.FRIEND_LIST_FOOTER);
  74. return true;
  75. }
  76. /**
  77. *
  78. * @see com.l2jserver.gameserver.handler.IUserCommandHandler#getUserCommandList()
  79. */
  80. @Override
  81. public int[] getUserCommandList()
  82. {
  83. return COMMAND_IDS;
  84. }
  85. }