AdminHellbound.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.admincommandhandlers;
  16. import java.util.StringTokenizer;
  17. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  18. import com.l2jserver.gameserver.instancemanager.HellboundManager;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  21. /**
  22. * @author DS, Gladicek
  23. */
  24. public class AdminHellbound implements IAdminCommandHandler
  25. {
  26. private static final String[] ADMIN_COMMANDS =
  27. {
  28. "admin_hellbound_setlevel", "admin_hellbound"
  29. };
  30. @Override
  31. public String[] getAdminCommandList()
  32. {
  33. return ADMIN_COMMANDS;
  34. }
  35. @Override
  36. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  37. {
  38. if (activeChar == null)
  39. {
  40. return false;
  41. }
  42. if (command.startsWith(ADMIN_COMMANDS[0])) // setlevel
  43. {
  44. try
  45. {
  46. StringTokenizer st = new StringTokenizer(command, " ");
  47. st.nextToken();
  48. final int level = Integer.parseInt(st.nextToken());
  49. if ((level < 0) || (level > 11))
  50. {
  51. throw new NumberFormatException();
  52. }
  53. HellboundManager.getInstance().setLevel(level);
  54. activeChar.sendMessage("Hellbound level set to " + level);
  55. return true;
  56. }
  57. catch (Exception e)
  58. {
  59. activeChar.sendMessage("Usage: //hellbound_setlevel 0-11");
  60. return false;
  61. }
  62. }
  63. else if (command.startsWith(ADMIN_COMMANDS[1])) // Admin menu by Gladicek
  64. {
  65. showMenu(activeChar);
  66. return true;
  67. }
  68. return false;
  69. }
  70. private void showMenu(L2PcInstance activeChar)
  71. {
  72. NpcHtmlMessage html = new NpcHtmlMessage(0);
  73. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/hellbound.htm");
  74. html.replace("%hbstage%", String.valueOf(HellboundManager.getInstance().getLevel()));
  75. html.replace("%trust%", String.valueOf(HellboundManager.getInstance().getTrust()));
  76. html.replace("%maxtrust%", String.valueOf(HellboundManager.getInstance().getMaxTrust()));
  77. html.replace("%mintrust%", String.valueOf(HellboundManager.getInstance().getMinTrust()));
  78. activeChar.sendPacket(html);
  79. }
  80. }