PartyInfo.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. @Override
  32. public boolean useUserCommand(int id, L2PcInstance activeChar)
  33. {
  34. if (id != COMMAND_IDS[0])
  35. return false;
  36. if (!activeChar.isInParty())
  37. {
  38. activeChar.sendPacket(SystemMessageId.PARTY_INFORMATION);
  39. activeChar.sendPacket(SystemMessageId.FRIEND_LIST_FOOTER);
  40. return false;
  41. }
  42. L2Party playerParty = activeChar.getParty();
  43. int memberCount = playerParty.getMemberCount();
  44. int lootDistribution = playerParty.getLootDistribution();
  45. String partyLeader = playerParty.getMembers().get(0).getName();
  46. activeChar.sendPacket(SystemMessageId.PARTY_INFORMATION);
  47. switch (lootDistribution)
  48. {
  49. case L2Party.ITEM_LOOTER:
  50. activeChar.sendPacket(SystemMessageId.LOOTING_FINDERS_KEEPERS);
  51. break;
  52. case L2Party.ITEM_ORDER:
  53. activeChar.sendPacket(SystemMessageId.LOOTING_BY_TURN);
  54. break;
  55. case L2Party.ITEM_ORDER_SPOIL:
  56. activeChar.sendPacket(SystemMessageId.LOOTING_BY_TURN_INCLUDE_SPOIL);
  57. break;
  58. case L2Party.ITEM_RANDOM:
  59. activeChar.sendPacket(SystemMessageId.LOOTING_RANDOM);
  60. break;
  61. case L2Party.ITEM_RANDOM_SPOIL:
  62. activeChar.sendPacket(SystemMessageId.LOOTING_RANDOM_INCLUDE_SPOIL);
  63. break;
  64. }
  65. SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PARTY_LEADER_C1);
  66. sm.addString(partyLeader);
  67. activeChar.sendPacket(sm);
  68. activeChar.sendMessage("Members: " + memberCount + "/9");
  69. activeChar.sendPacket(SystemMessageId.FRIEND_LIST_FOOTER);
  70. return true;
  71. }
  72. @Override
  73. public int[] getUserCommandList()
  74. {
  75. return COMMAND_IDS;
  76. }
  77. }