StatsVCmd.java 3.0 KB

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