AdminRide.java 3.3 KB

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