castle.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.voicedcommandhandlers;
  16. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  17. import com.l2jserver.gameserver.instancemanager.CastleManager;
  18. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  19. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  20. import com.l2jserver.gameserver.model.entity.Castle;
  21. /**
  22. *
  23. *
  24. */
  25. public class castle implements IVoicedCommandHandler
  26. {
  27. private static final String[] VOICED_COMMANDS =
  28. {
  29. "open doors",
  30. "close doors",
  31. "ride wyvern"
  32. };
  33. /**
  34. *
  35. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#useVoicedCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  36. */
  37. @Override
  38. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  39. {
  40. if (command.startsWith("open doors") && params.equals("castle") && (activeChar.isClanLeader()))
  41. {
  42. L2DoorInstance door = (L2DoorInstance) activeChar.getTarget();
  43. Castle castle = CastleManager.getInstance().getCastleById(activeChar.getClan().getHasCastle());
  44. if (door == null || castle == null)
  45. return false;
  46. if (castle.checkIfInZone(door.getX(), door.getY(), door.getZ()))
  47. {
  48. door.openMe();
  49. }
  50. }
  51. else if (command.startsWith("close doors") && params.equals("castle") && (activeChar.isClanLeader()))
  52. {
  53. L2DoorInstance door = (L2DoorInstance) activeChar.getTarget();
  54. Castle castle = CastleManager.getInstance().getCastleById(activeChar.getClan().getHasCastle());
  55. if (door == null || castle == null)
  56. return false;
  57. if (castle.checkIfInZone(door.getX(), door.getY(), door.getZ()))
  58. {
  59. door.closeMe();
  60. }
  61. }
  62. else if (command.startsWith("ride wyvern") && params.equals("castle"))
  63. {
  64. if (activeChar.getClan().getHasCastle() > 0 && activeChar.isClanLeader())
  65. {
  66. activeChar.mount(12621, 0, true);
  67. }
  68. }
  69. return true;
  70. }
  71. /**
  72. *
  73. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  74. */
  75. @Override
  76. public String[] getVoicedCommandList()
  77. {
  78. return VOICED_COMMANDS;
  79. }
  80. }