OlympiadStat.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack 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 DataPack 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 handlers.usercommandhandlers;
  20. import com.l2jserver.gameserver.handler.IUserCommandHandler;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.olympiad.Olympiad;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  26. /**
  27. * Olympiad Stat user command.
  28. * @author kamy, Zoey76
  29. */
  30. public class OlympiadStat implements IUserCommandHandler
  31. {
  32. private static final int[] COMMAND_IDS =
  33. {
  34. 109
  35. };
  36. @Override
  37. public boolean useUserCommand(int id, L2PcInstance activeChar)
  38. {
  39. if (id != COMMAND_IDS[0])
  40. {
  41. return false;
  42. }
  43. int nobleObjId = activeChar.getObjectId();
  44. final L2Object target = activeChar.getTarget();
  45. if (target != null)
  46. {
  47. if (target.isPlayer() && target.getActingPlayer().isNoble())
  48. {
  49. nobleObjId = target.getObjectId();
  50. }
  51. else
  52. {
  53. activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY);
  54. return false;
  55. }
  56. }
  57. else if (!activeChar.isNoble())
  58. {
  59. activeChar.sendPacket(SystemMessageId.NOBLESSE_ONLY);
  60. return false;
  61. }
  62. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_CURRENT_RECORD_FOR_THIS_OLYMPIAD_SESSION_IS_S1_MATCHES_S2_WINS_S3_DEFEATS_YOU_HAVE_EARNED_S4_OLYMPIAD_POINTS);
  63. sm.addInt(Olympiad.getInstance().getCompetitionDone(nobleObjId));
  64. sm.addInt(Olympiad.getInstance().getCompetitionWon(nobleObjId));
  65. sm.addInt(Olympiad.getInstance().getCompetitionLost(nobleObjId));
  66. sm.addInt(Olympiad.getInstance().getNoblePoints(nobleObjId));
  67. activeChar.sendPacket(sm);
  68. final SystemMessage sm2 = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_S1_MATCHES_REMAINING_THAT_YOU_CAN_PARTECIPATE_IN_THIS_WEEK_S2_CLASSED_S3_NON_CLASSED_S4_TEAM);
  69. sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatches(nobleObjId));
  70. sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesClassed(nobleObjId));
  71. sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesNonClassed(nobleObjId));
  72. sm2.addInt(Olympiad.getInstance().getRemainingWeeklyMatchesTeam(nobleObjId));
  73. activeChar.sendPacket(sm2);
  74. return true;
  75. }
  76. @Override
  77. public int[] getUserCommandList()
  78. {
  79. return COMMAND_IDS;
  80. }
  81. }