Rift.java 2.7 KB

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