StatsVCmd.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.voicedcommandhandlers;
  20. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  21. import com.l2jserver.gameserver.model.L2World;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.entity.L2Event;
  24. import com.l2jserver.gameserver.network.SystemMessageId;
  25. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  26. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  27. import com.l2jserver.util.StringUtil;
  28. /**
  29. * @author Zoey76.
  30. */
  31. public class StatsVCmd implements IVoicedCommandHandler
  32. {
  33. private static final String[] VOICED_COMMANDS =
  34. {
  35. "stats"
  36. };
  37. @Override
  38. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  39. {
  40. if (!command.equals("stats") || (params == null) || params.isEmpty())
  41. {
  42. activeChar.sendMessage("Usage: .stats <player name>");
  43. return false;
  44. }
  45. final L2PcInstance pc = L2World.getInstance().getPlayer(params);
  46. if ((pc == null))
  47. {
  48. activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
  49. return false;
  50. }
  51. if (pc.getClient().isDetached())
  52. {
  53. final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_OFFLINE);
  54. sm.addPcName(pc);
  55. activeChar.sendPacket(sm);
  56. return false;
  57. }
  58. if (!L2Event.isParticipant(pc) || (pc.getEventStatus() == null))
  59. {
  60. activeChar.sendMessage("That player is not an event participant.");
  61. return false;
  62. }
  63. final StringBuilder replyMSG = StringUtil.startAppend(300 + (pc.getEventStatus().getKills().size() * 50), "<html><body>" + "<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br><br>Statistics for player <font color=\"LEVEL\">", pc.getName(), "</font><br>Total kills <font color=\"FF0000\">", String.valueOf(pc.getEventStatus().getKills().size()), "</font><br><br>Detailed list: <br>");
  64. for (L2PcInstance plr : pc.getEventStatus().getKills())
  65. {
  66. StringUtil.append(replyMSG, "<font color=\"FF0000\">", plr.getName(), "</font><br>");
  67. }
  68. replyMSG.append("</body></html>");
  69. final NpcHtmlMessage adminReply = new NpcHtmlMessage();
  70. adminReply.setHtml(replyMSG.toString());
  71. activeChar.sendPacket(adminReply);
  72. return true;
  73. }
  74. @Override
  75. public String[] getVoicedCommandList()
  76. {
  77. return VOICED_COMMANDS;
  78. }
  79. }