PlayerHelp.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.bypasshandlers;
  16. import java.util.StringTokenizer;
  17. import java.util.logging.Level;
  18. import com.l2jserver.gameserver.handler.IBypassHandler;
  19. import com.l2jserver.gameserver.model.actor.L2Character;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  22. public class PlayerHelp implements IBypassHandler
  23. {
  24. private static final String[] COMMANDS =
  25. {
  26. "player_help"
  27. };
  28. @Override
  29. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  30. {
  31. try
  32. {
  33. if (command.length() < 13)
  34. {
  35. return false;
  36. }
  37. final String path = command.substring(12);
  38. if (path.indexOf("..") != -1)
  39. {
  40. return false;
  41. }
  42. final StringTokenizer st = new StringTokenizer(path);
  43. final String[] cmd = st.nextToken().split("#");
  44. NpcHtmlMessage html;
  45. if (cmd.length > 1)
  46. {
  47. final int itemId = Integer.parseInt(cmd[1]);
  48. html = new NpcHtmlMessage(1, itemId);
  49. }
  50. else
  51. {
  52. html = new NpcHtmlMessage(1);
  53. }
  54. html.setFile(activeChar.getHtmlPrefix(), "data/html/help/" + cmd[0]);
  55. html.disableValidation();
  56. activeChar.sendPacket(html);
  57. }
  58. catch (Exception e)
  59. {
  60. _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
  61. }
  62. return true;
  63. }
  64. @Override
  65. public String[] getBypassList()
  66. {
  67. return COMMANDS;
  68. }
  69. }