AdminHelpPage.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2004-2013 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.admincommandhandlers;
  20. import com.l2jserver.gameserver.cache.HtmCache;
  21. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  24. /**
  25. * This class handles following admin commands: - help path = shows /data/html/admin/path file to char, should not be used by GM's directly
  26. * @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:02 $
  27. */
  28. public class AdminHelpPage implements IAdminCommandHandler
  29. {
  30. private static final String[] ADMIN_COMMANDS =
  31. {
  32. "admin_help"
  33. };
  34. @Override
  35. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  36. {
  37. if (command.startsWith("admin_help"))
  38. {
  39. try
  40. {
  41. String val = command.substring(11);
  42. showHelpPage(activeChar, val);
  43. }
  44. catch (StringIndexOutOfBoundsException e)
  45. {
  46. // case of empty filename
  47. }
  48. }
  49. return true;
  50. }
  51. @Override
  52. public String[] getAdminCommandList()
  53. {
  54. return ADMIN_COMMANDS;
  55. }
  56. // FIXME: implement method to send html to player in L2PcInstance directly
  57. // PUBLIC & STATIC so other classes from package can include it directly
  58. public static void showHelpPage(L2PcInstance targetChar, String filename)
  59. {
  60. String content = HtmCache.getInstance().getHtmForce(targetChar.getHtmlPrefix(), "data/html/admin/" + filename);
  61. NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
  62. adminReply.setHtml(content);
  63. targetChar.sendPacket(adminReply);
  64. }
  65. }