Rift.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.logging.Level;
  17. import com.l2jserver.gameserver.handler.IBypassHandler;
  18. import com.l2jserver.gameserver.instancemanager.DimensionalRiftManager;
  19. import com.l2jserver.gameserver.model.actor.L2Character;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. public class Rift implements IBypassHandler
  23. {
  24. private static final String[] COMMANDS =
  25. {
  26. "enterrift",
  27. "changeriftroom",
  28. "exitrift"
  29. };
  30. @Override
  31. public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
  32. {
  33. if (!(target instanceof L2Npc))
  34. {
  35. return false;
  36. }
  37. if (command.toLowerCase().startsWith(COMMANDS[0])) // EnterRift
  38. {
  39. try
  40. {
  41. Byte b1 = Byte.parseByte(command.substring(10)); // Selected Area: Recruit, Soldier etc
  42. DimensionalRiftManager.getInstance().start(activeChar, b1, (L2Npc) target);
  43. return true;
  44. }
  45. catch (Exception e)
  46. {
  47. _log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
  48. }
  49. }
  50. else
  51. {
  52. final boolean inRift = activeChar.isInParty() && activeChar.getParty().isInDimensionalRift();
  53. if (command.toLowerCase().startsWith(COMMANDS[1])) // ChangeRiftRoom
  54. {
  55. if (inRift)
  56. {
  57. activeChar.getParty().getDimensionalRift().manualTeleport(activeChar, (L2Npc) target);
  58. }
  59. else
  60. {
  61. DimensionalRiftManager.getInstance().handleCheat(activeChar, (L2Npc) target);
  62. }
  63. return true;
  64. }
  65. else if (command.toLowerCase().startsWith(COMMANDS[2])) // ExitRift
  66. {
  67. if (inRift)
  68. {
  69. activeChar.getParty().getDimensionalRift().manualExitRift(activeChar, (L2Npc) target);
  70. }
  71. else
  72. {
  73. DimensionalRiftManager.getInstance().handleCheat(activeChar, (L2Npc) target);
  74. }
  75. }
  76. return true;
  77. }
  78. return false;
  79. }
  80. @Override
  81. public String[] getBypassList()
  82. {
  83. return COMMANDS;
  84. }
  85. }