stats.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.voicedcommandhandlers;
  16. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  17. import com.l2jserver.gameserver.model.L2World;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  20. import com.l2jserver.util.StringUtil;
  21. /**
  22. *
  23. *
  24. */
  25. public class stats implements IVoicedCommandHandler
  26. {
  27. private static final String[] VOICED_COMMANDS =
  28. {
  29. "stats"
  30. };
  31. /**
  32. *
  33. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  34. */
  35. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  36. {
  37. if (command.equalsIgnoreCase("stats"))
  38. {
  39. L2PcInstance pc = L2World.getInstance().getPlayer(params);
  40. if (pc != null)
  41. {
  42. NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  43. final StringBuilder replyMSG = StringUtil.startAppend(
  44. 300 + pc.getEventStatus().kills.size() * 50,
  45. "<html><body>" +
  46. "<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>" +
  47. "<br>Statistics for player <font color=\"LEVEL\">",
  48. pc.getName(),
  49. "</font><br>" +
  50. "Total kills <font color=\"FF0000\">",
  51. String.valueOf(pc.getEventStatus().kills.size()),
  52. "</font><br>" +
  53. "<br>Detailed list: <br>"
  54. );
  55. for (L2PcInstance plr : pc.getEventStatus().kills)
  56. {
  57. StringUtil.append(replyMSG, "<font color=\"FF0000\">", plr.getName(), "</font><br>");
  58. }
  59. replyMSG.append("</body></html>");
  60. adminReply.setHtml(replyMSG.toString());
  61. activeChar.sendPacket(adminReply);
  62. }
  63. }
  64. return true;
  65. }
  66. /**
  67. *
  68. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  69. */
  70. public String[] getVoicedCommandList()
  71. {
  72. return VOICED_COMMANDS;
  73. }
  74. }