AdminRide.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 com.l2jserver.gameserver.handler.IAdminCommandHandler;
  17. import com.l2jserver.gameserver.instancemanager.TransformationManager;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. * @author
  21. */
  22. public class AdminRide implements IAdminCommandHandler
  23. {
  24. private static final String[] ADMIN_COMMANDS =
  25. {
  26. "admin_ride_horse",
  27. "admin_ride_bike",
  28. "admin_ride_wyvern",
  29. "admin_ride_strider",
  30. "admin_unride_wyvern",
  31. "admin_unride_strider",
  32. "admin_unride",
  33. "admin_ride_wolf",
  34. "admin_unride_wolf",
  35. };
  36. private int _petRideId;
  37. private static final int PURPLE_MANED_HORSE_TRANSFORMATION_ID = 106;
  38. private static final int JET_BIKE_TRANSFORMATION_ID = 20001;
  39. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  40. {
  41. L2PcInstance player = getRideTarget(activeChar);
  42. if(player == null)
  43. return false;
  44. if (command.startsWith("admin_ride"))
  45. {
  46. if (player.isMounted() || player.getPet() != null)
  47. {
  48. activeChar.sendMessage("Target already have a pet.");
  49. return false;
  50. }
  51. if (command.startsWith("admin_ride_wyvern"))
  52. {
  53. _petRideId = 12621;
  54. }
  55. else if (command.startsWith("admin_ride_strider"))
  56. {
  57. _petRideId = 12526;
  58. }
  59. else if (command.startsWith("admin_ride_wolf"))
  60. {
  61. _petRideId = 16041;
  62. }
  63. else if (command.startsWith("admin_ride_horse")) // handled using transformation
  64. {
  65. if (player.isTransformed() || player.isInStance())
  66. //FIXME: Wrong Message
  67. activeChar.sendMessage("Player cannot mount a steed while transformed.");
  68. else
  69. TransformationManager.getInstance().transformPlayer(PURPLE_MANED_HORSE_TRANSFORMATION_ID, player);
  70. return true;
  71. }
  72. else if (command.startsWith("admin_ride_bike")) // handled using transformation
  73. {
  74. if (player.isTransformed() || player.isInStance())
  75. //FIXME: Wrong Message
  76. activeChar.sendMessage("Player cannot mount a steed while transformed.");
  77. else
  78. TransformationManager.getInstance().transformPlayer(JET_BIKE_TRANSFORMATION_ID, player);
  79. return true;
  80. }
  81. else
  82. {
  83. activeChar.sendMessage("Command '" + command + "' not recognized");
  84. return false;
  85. }
  86. player.mount(_petRideId, 0, false);
  87. return false;
  88. }
  89. else if (command.startsWith("admin_unride"))
  90. {
  91. if (player.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
  92. player.untransform();
  93. if (player.getTransformationId() == JET_BIKE_TRANSFORMATION_ID)
  94. player.untransform();
  95. else
  96. player.dismount();
  97. }
  98. return true;
  99. }
  100. private L2PcInstance getRideTarget(L2PcInstance activeChar)
  101. {
  102. L2PcInstance player = null;
  103. if(activeChar.getTarget() == null
  104. || activeChar.getTarget().getObjectId() == activeChar.getObjectId()
  105. || !(activeChar.getTarget() instanceof L2PcInstance))
  106. player = activeChar;
  107. else
  108. player = (L2PcInstance)activeChar.getTarget();
  109. return player;
  110. }
  111. public String[] getAdminCommandList()
  112. {
  113. return ADMIN_COMMANDS;
  114. }
  115. }