PartyInfo.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 net.sf.l2j.gameserver.handler.usercommandhandlers;
  16. import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  17. import net.sf.l2j.gameserver.model.L2Party;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.network.SystemMessageId;
  20. import net.sf.l2j.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 net.sf.l2j.gameserver.handler.IUserCommandHandler#useUserCommand(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance)
  34. */
  35. public boolean useUserCommand(int id, L2PcInstance activeChar)
  36. {
  37. if (id != COMMAND_IDS[0])
  38. return false;
  39. if (!activeChar.isInParty())
  40. {
  41. activeChar.sendMessage("You are not in a party.");
  42. return false;
  43. }
  44. L2Party playerParty = activeChar.getParty();
  45. int memberCount = playerParty.getMemberCount();
  46. int lootDistribution = playerParty.getLootDistribution();
  47. String partyLeader = playerParty.getPartyMembers().get(0).getName();
  48. activeChar.sendPacket(new SystemMessage(SystemMessageId.PARTY_INFORMATION));
  49. switch (lootDistribution)
  50. {
  51. case L2Party.ITEM_LOOTER:
  52. activeChar.sendPacket(new SystemMessage(SystemMessageId.LOOTING_FINDERS_KEEPERS));
  53. break;
  54. case L2Party.ITEM_ORDER:
  55. activeChar.sendPacket(new SystemMessage(SystemMessageId.LOOTING_BY_TURN));
  56. break;
  57. case L2Party.ITEM_ORDER_SPOIL:
  58. activeChar.sendPacket(new SystemMessage(SystemMessageId.LOOTING_BY_TURN_INCLUDE_SPOIL));
  59. break;
  60. case L2Party.ITEM_RANDOM:
  61. activeChar.sendPacket(new SystemMessage(SystemMessageId.LOOTING_RANDOM));
  62. break;
  63. case L2Party.ITEM_RANDOM_SPOIL:
  64. activeChar.sendPacket(new SystemMessage(SystemMessageId.LOOTING_RANDOM_INCLUDE_SPOIL));
  65. break;
  66. }
  67. SystemMessage sm = new SystemMessage(SystemMessageId.PARTY_LEADER_S1);
  68. sm.addString(partyLeader);
  69. activeChar.sendPacket(sm);
  70. activeChar.sendMessage("Members: " + memberCount + "/9");
  71. activeChar.sendPacket(new SystemMessage(SystemMessageId.WAR_LIST));
  72. return true;
  73. }
  74. /**
  75. *
  76. * @see net.sf.l2j.gameserver.handler.IUserCommandHandler#getUserCommandList()
  77. */
  78. public int[] getUserCommandList()
  79. {
  80. return COMMAND_IDS;
  81. }
  82. }