Advertisement
Sarada-L2

CastleManager Acis 372

Sep 5th, 2021
512
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  2. index a1b430a..9692d25 100644
  3. --- a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  4. +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
  5. @@ -17,6 +17,8 @@
  6. import java.util.HashMap;
  7. import java.util.Map;
  8.  
  9. +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.CastleManagersVCmd;
  10. +
  11. public class VoicedCommandHandler
  12. {
  13. private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
  14. @@ -28,7 +30,7 @@
  15.  
  16. protected VoicedCommandHandler()
  17. {
  18. -
  19. + registerHandler(new CastleManagersVCmd());
  20. }
  21. public void registerHandler(IVoicedCommandHandler handler)
  22. {
  23. diff --git a/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/CastleManagersVCmd.java b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/CastleManagersVCmd.java
  24. new file mode 100644
  25. index 0000000..8b355ce
  26. --- /dev/null
  27. +++ b/java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/CastleManagersVCmd.java
  28. @@ -0,0 +1,73 @@
  29. +package net.sf.l2j.gameserver.handler.voicedcommandhandlers;
  30. +
  31. +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
  32. +import net.sf.l2j.gameserver.instancemanager.CastleManager;
  33. +import net.sf.l2j.gameserver.model.actor.instance.Player;
  34. +import net.sf.l2j.gameserver.model.entity.Castle;
  35. +import net.sf.l2j.gameserver.network.SystemMessageId;
  36. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  37. +import net.sf.l2j.gameserver.network.serverpackets.SiegeInfo;
  38. +
  39. +public class CastleManagersVCmd implements IVoicedCommandHandler
  40. +{
  41. + private static final String[] _voicedCommands = {"castlemanager","siege_gludio","siege_dion","siege_giran","siege_oren","siege_aden","siege_innadril","siege_goddard","siege_rune","siege_schuttgart"};
  42. +
  43. + @Override
  44. + public boolean useVoicedCommand(String command, Player activeChar, String target)
  45. + {
  46. + if (command.startsWith("castlemanager"))
  47. + {
  48. + sendHtml(activeChar);
  49. + }
  50. +
  51. + if (command.startsWith("siege_"))
  52. + {
  53. + if (activeChar.getClan() != null && !activeChar.isClanLeader())
  54. + {
  55. + activeChar.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
  56. + return false;
  57. + }
  58. +
  59. + int castleId = 0;
  60. +
  61. + if (command.startsWith("siege_gludio"))
  62. + castleId = 1;
  63. + else if (command.startsWith("siege_dion"))
  64. + castleId = 2;
  65. + else if (command.startsWith("siege_giran"))
  66. + castleId = 3;
  67. + else if (command.startsWith("siege_oren"))
  68. + castleId = 4;
  69. + else if (command.startsWith("siege_aden"))
  70. + castleId = 5;
  71. + else if (command.startsWith("siege_innadril"))
  72. + castleId = 6;
  73. + else if (command.startsWith("siege_goddard"))
  74. + castleId = 7;
  75. + else if (command.startsWith("siege_rune"))
  76. + castleId = 8;
  77. + else if (command.startsWith("siege_schuttgart"))
  78. + castleId = 9;
  79. +
  80. + Castle castle = CastleManager.getInstance().getCastleById(castleId);
  81. + if(castle != null && castleId != 0)
  82. + activeChar.sendPacket(new SiegeInfo(castle));
  83. + }
  84. + return true;
  85. + }
  86. +
  87. + private static void sendHtml(Player activeChar)
  88. + {
  89. + String htmFile = "data/html/mods/CastleManager.htm";
  90. +
  91. + NpcHtmlMessage msg = new NpcHtmlMessage(5);
  92. + msg.setFile(htmFile);
  93. + activeChar.sendPacket(msg);
  94. + }
  95. +
  96. + @Override
  97. + public String[] getVoicedCommandList()
  98. + {
  99. + return _voicedCommands;
  100. + }
  101. +}
  102. \ No newline at end of file
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement