RemoveDeathPenalty.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 com.l2jserver.gameserver.handler.IBypassHandler;
  17. import com.l2jserver.gameserver.model.actor.L2Character;
  18. import com.l2jserver.gameserver.model.actor.L2Npc;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.network.SystemMessageId;
  21. import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
  22. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  23. import com.l2jserver.util.StringUtil;
  24. public class RemoveDeathPenalty implements IBypassHandler
  25. {
  26. private static final String[] COMMANDS =
  27. {
  28. "remove_dp"
  29. };
  30. private static final int[] pen_clear_price =
  31. {
  32. 3600, 8640, 25200, 50400, 86400, 144000, 144000, 144000
  33. };
  34. @Override
  35. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  36. {
  37. if (!(target instanceof L2Npc))
  38. {
  39. return false;
  40. }
  41. try
  42. {
  43. final int cmdChoice = Integer.parseInt(command.substring(10, 11).trim());
  44. final L2Npc npc = (L2Npc) target;
  45. switch (cmdChoice)
  46. {
  47. case 1:
  48. String filename = "data/html/default/30981-1.htm";
  49. NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
  50. html.setFile(activeChar.getHtmlPrefix(), filename);
  51. html.replace("%objectId%", String.valueOf(npc.getObjectId()));
  52. html.replace("%dp_price%", String.valueOf(pen_clear_price[activeChar.getExpertiseLevel()]));
  53. activeChar.sendPacket(html);
  54. break;
  55. case 2:
  56. NpcHtmlMessage Reply = new NpcHtmlMessage(npc.getObjectId());
  57. final StringBuilder replyMSG = StringUtil.startAppend(400, "<html><body>Black Judge:<br>");
  58. if (activeChar.getDeathPenaltyBuffLevel() > 0)
  59. {
  60. if (activeChar.getAdena() >= pen_clear_price[activeChar.getExpertiseLevel()])
  61. {
  62. if (!activeChar.reduceAdena("DeathPenality", pen_clear_price[activeChar.getExpertiseLevel()], npc, true))
  63. {
  64. return false;
  65. }
  66. activeChar.setDeathPenaltyBuffLevel(activeChar.getDeathPenaltyBuffLevel() - 1);
  67. activeChar.sendPacket(SystemMessageId.DEATH_PENALTY_LIFTED);
  68. activeChar.sendPacket(new EtcStatusUpdate(activeChar));
  69. return true;
  70. }
  71. else
  72. {
  73. replyMSG.append("The wound you have received from death's touch is too deep to be healed for the money you have to give me. Find more money if you wish death's mark to be fully removed from you.");
  74. }
  75. }
  76. else
  77. {
  78. replyMSG.append("You have no more death wounds that require healing.<br>" + "Go forth and fight, both for this world and your own glory.");
  79. }
  80. replyMSG.append("</body></html>");
  81. Reply.setHtml(replyMSG.toString());
  82. activeChar.sendPacket(Reply);
  83. break;
  84. }
  85. return true;
  86. }
  87. catch (Exception e)
  88. {
  89. _log.info("Exception in " + getClass().getSimpleName());
  90. }
  91. return false;
  92. }
  93. @Override
  94. public String[] getBypassList()
  95. {
  96. return COMMANDS;
  97. }
  98. }