AdminRide.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. @Override
  40. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  41. {
  42. L2PcInstance player = getRideTarget(activeChar);
  43. if(player == null)
  44. return false;
  45. if (command.startsWith("admin_ride"))
  46. {
  47. if (player.isMounted() || player.getPet() != null)
  48. {
  49. activeChar.sendMessage("Target already have a pet.");
  50. return false;
  51. }
  52. if (command.startsWith("admin_ride_wyvern"))
  53. {
  54. _petRideId = 12621;
  55. }
  56. else if (command.startsWith("admin_ride_strider"))
  57. {
  58. _petRideId = 12526;
  59. }
  60. else if (command.startsWith("admin_ride_wolf"))
  61. {
  62. _petRideId = 16041;
  63. }
  64. else if (command.startsWith("admin_ride_horse")) // handled using transformation
  65. {
  66. if (player.isTransformed() || player.isInStance())
  67. //FIXME: Wrong Message
  68. activeChar.sendMessage("Player cannot mount a steed while transformed.");
  69. else
  70. TransformationManager.getInstance().transformPlayer(PURPLE_MANED_HORSE_TRANSFORMATION_ID, player);
  71. return true;
  72. }
  73. else if (command.startsWith("admin_ride_bike")) // handled using transformation
  74. {
  75. if (player.isTransformed() || player.isInStance())
  76. //FIXME: Wrong Message
  77. activeChar.sendMessage("Player cannot mount a steed while transformed.");
  78. else
  79. TransformationManager.getInstance().transformPlayer(JET_BIKE_TRANSFORMATION_ID, player);
  80. return true;
  81. }
  82. else
  83. {
  84. activeChar.sendMessage("Command '" + command + "' not recognized");
  85. return false;
  86. }
  87. player.mount(_petRideId, 0, false);
  88. return false;
  89. }
  90. else if (command.startsWith("admin_unride"))
  91. {
  92. if (player.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
  93. player.untransform();
  94. if (player.getTransformationId() == JET_BIKE_TRANSFORMATION_ID)
  95. player.untransform();
  96. else
  97. player.dismount();
  98. }
  99. return true;
  100. }
  101. private L2PcInstance getRideTarget(L2PcInstance activeChar)
  102. {
  103. L2PcInstance player = null;
  104. if(activeChar.getTarget() == null
  105. || activeChar.getTarget().getObjectId() == activeChar.getObjectId()
  106. || !(activeChar.getTarget() instanceof L2PcInstance))
  107. player = activeChar;
  108. else
  109. player = (L2PcInstance)activeChar.getTarget();
  110. return player;
  111. }
  112. @Override
  113. public String[] getAdminCommandList()
  114. {
  115. return ADMIN_COMMANDS;
  116. }
  117. }