CastleVCmd.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (C) 2004-2014 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.voicedcommandhandlers;
  20. import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  21. import com.l2jserver.gameserver.instancemanager.CastleManager;
  22. import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.model.entity.Castle;
  25. import com.l2jserver.gameserver.network.SystemMessageId;
  26. /**
  27. * @author Zoey76
  28. */
  29. public class CastleVCmd implements IVoicedCommandHandler
  30. {
  31. private static final String[] VOICED_COMMANDS =
  32. {
  33. "opendoors",
  34. "closedoors",
  35. "ridewyvern"
  36. };
  37. @Override
  38. public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  39. {
  40. switch (command)
  41. {
  42. case "opendoors":
  43. if (!params.equals("castle"))
  44. {
  45. activeChar.sendMessage("Only Castle doors can be open.");
  46. return false;
  47. }
  48. if (!activeChar.isClanLeader())
  49. {
  50. activeChar.sendPacket(SystemMessageId.ONLY_CLAN_LEADER_CAN_ISSUE_COMMANDS);
  51. return false;
  52. }
  53. final L2DoorInstance door = (L2DoorInstance) activeChar.getTarget();
  54. if (door == null)
  55. {
  56. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  57. return false;
  58. }
  59. final Castle castle = CastleManager.getInstance().getCastleById(activeChar.getClan().getCastleId());
  60. if (castle == null)
  61. {
  62. activeChar.sendMessage("Your clan does not own a castle.");
  63. return false;
  64. }
  65. if (castle.getSiege().isInProgress())
  66. {
  67. activeChar.sendPacket(SystemMessageId.GATES_NOT_OPENED_CLOSED_DURING_SIEGE);
  68. return false;
  69. }
  70. if (castle.checkIfInZone(door.getX(), door.getY(), door.getZ()))
  71. {
  72. activeChar.sendPacket(SystemMessageId.GATE_IS_OPENING);
  73. door.openMe();
  74. }
  75. break;
  76. case "closedoors":
  77. if (!params.equals("castle"))
  78. {
  79. activeChar.sendMessage("Only Castle doors can be closed.");
  80. return false;
  81. }
  82. if (!activeChar.isClanLeader())
  83. {
  84. activeChar.sendPacket(SystemMessageId.ONLY_CLAN_LEADER_CAN_ISSUE_COMMANDS);
  85. return false;
  86. }
  87. final L2DoorInstance door2 = (L2DoorInstance) activeChar.getTarget();
  88. if (door2 == null)
  89. {
  90. activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  91. return false;
  92. }
  93. final Castle castle2 = CastleManager.getInstance().getCastleById(activeChar.getClan().getCastleId());
  94. if (castle2 == null)
  95. {
  96. activeChar.sendMessage("Your clan does not own a castle.");
  97. return false;
  98. }
  99. if (castle2.getSiege().isInProgress())
  100. {
  101. activeChar.sendPacket(SystemMessageId.GATES_NOT_OPENED_CLOSED_DURING_SIEGE);
  102. return false;
  103. }
  104. if (castle2.checkIfInZone(door2.getX(), door2.getY(), door2.getZ()))
  105. {
  106. activeChar.sendMessage("The gate is being closed.");
  107. door2.closeMe();
  108. }
  109. break;
  110. case "ridewyvern":
  111. if (activeChar.isClanLeader() && (activeChar.getClan().getCastleId() > 0))
  112. {
  113. activeChar.mount(12621, 0, true);
  114. }
  115. break;
  116. }
  117. return true;
  118. }
  119. @Override
  120. public String[] getVoicedCommandList()
  121. {
  122. return VOICED_COMMANDS;
  123. }
  124. }