castle.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  38. {
  39. if (command.startsWith("open doors") && params.equals("castle") && (activeChar.isClanLeader()))
  40. {
  41. L2DoorInstance door = (L2DoorInstance) activeChar.getTarget();
  42. Castle castle = CastleManager.getInstance().getCastleById(activeChar.getClan().getHasCastle());
  43. if (door == null || castle == null)
  44. return false;
  45. if (castle.checkIfInZone(door.getX(), door.getY(), door.getZ()))
  46. {
  47. door.openMe();
  48. }
  49. }
  50. else if (command.startsWith("close doors") && params.equals("castle") && (activeChar.isClanLeader()))
  51. {
  52. L2DoorInstance door = (L2DoorInstance) activeChar.getTarget();
  53. Castle castle = CastleManager.getInstance().getCastleById(activeChar.getClan().getHasCastle());
  54. if (door == null || castle == null)
  55. return false;
  56. if (castle.checkIfInZone(door.getX(), door.getY(), door.getZ()))
  57. {
  58. door.closeMe();
  59. }
  60. }
  61. else if (command.startsWith("ride wyvern") && params.equals("castle"))
  62. {
  63. if (activeChar.getClan().getHasCastle() > 0 && activeChar.isClanLeader())
  64. {
  65. activeChar.mount(12621, 0, true);
  66. }
  67. }
  68. return true;
  69. }
  70. /**
  71. *
  72. * @see com.l2jserver.gameserver.handler.IVoicedCommandHandler#getVoicedCommandList()
  73. */
  74. public String[] getVoicedCommandList()
  75. {
  76. return VOICED_COMMANDS;
  77. }
  78. }