2
0

stats.java 2.5 KB

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