Advertisement
warc222

VoiceCommandHandler for Mammon spawn

Sep 24th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2jfreecore_trunk
  3. Index: src/main/java/com/l2jfree/Config.java
  4. ===================================================================
  5. --- src/main/java/com/l2jfree/Config.java (revision 4957)
  6. +++ src/main/java/com/l2jfree/Config.java (working copy)
  7. @@ -986,6 +986,7 @@
  8. public static boolean DEVELOPER; // Enable/disable DEVELOPER TREATMENT
  9. public static boolean TEST_KNOWNLIST = false; // Internal properties for developers tests only
  10. public static boolean ALLOW_WEDDING;
  11. + public static boolean ALLOW_MAMMON_VOICE;
  12. public static boolean SERVER_LIST_BRACKET; // Displays [] in front of server name ?
  13. public static boolean SERVER_LIST_CLOCK; // Displays a clock next to the server name ?
  14. public static boolean SERVER_LIST_TESTSERVER; // Display test server in the list of servers ?
  15. @@ -1180,6 +1181,7 @@
  16. ALLOW_PET_WALKERS = Boolean.parseBoolean(optionsSettings.getProperty("AllowPetWalkers", "False"));
  17. ALLOW_CURSED_WEAPONS = Boolean.parseBoolean(optionsSettings.getProperty("AllowCursedWeapons", "False"));
  18. ALLOW_WEDDING = Boolean.parseBoolean(optionsSettings.getProperty("AllowWedding", "False"));
  19. + ALLOW_MAMMON_VOICE = Boolean.parseBoolean(optionsSettings.getProperty("AllowMammonVoice", "False"));
  20. ALLOW_GUARDS = Boolean.parseBoolean(optionsSettings.getProperty("AllowGuards", "False"));
  21.  
  22. DEFAULT_GLOBAL_CHAT = ChatMode.valueOf(optionsSettings.getProperty("GlobalChat", "REGION").toUpperCase());
  23. Index: src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java
  24. ===================================================================
  25. --- src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java (revision 4861)
  26. +++ src/main/java/com/l2jfree/gameserver/handler/VoicedCommandHandler.java (working copy)
  27. @@ -48,6 +48,10 @@
  28. registerVoicedCommandHandler(new CastleDoors());
  29. registerVoicedCommandHandler(new Hellbound());
  30. registerVoicedCommandHandler(new VersionInfo());
  31. + if (Config.ALLOW_MAMMON_VOICE)
  32. + {
  33. + registerVoicedCommandHandler(new Mammon());
  34. + }
  35. if (Config.ALLOW_WEDDING)
  36. {
  37. registerVoicedCommandHandler(new Wedding());
  38. Index: src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Mammon.java
  39. ===================================================================
  40. --- src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Mammon.java (revision 0)
  41. +++ src/main/java/com/l2jfree/gameserver/handler/voicedcommandhandlers/Mammon.java (revision 0)
  42. @@ -0,0 +1,107 @@
  43. +/*
  44. + * This program is free software: you can redistribute it and/or modify it under
  45. + * the terms of the GNU General Public License as published by the Free Software
  46. + * Foundation, either version 3 of the License, or (at your option) any later
  47. + * version.
  48. + *
  49. + * This program is distributed in the hope that it will be useful, but WITHOUT
  50. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  51. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  52. + * details.
  53. + *
  54. + * You should have received a copy of the GNU General Public License along with
  55. + * this program. If not, see <http://www.gnu.org/licenses/>.
  56. + */
  57. +package com.l2jfree.gameserver.handler.voicedcommandhandlers;
  58. +
  59. +import com.l2jfree.gameserver.SevenSigns;
  60. +import com.l2jfree.gameserver.datatables.SpawnTable;
  61. +import com.l2jfree.gameserver.handler.IVoicedCommandHandler;
  62. +import com.l2jfree.gameserver.instancemanager.TownManager;
  63. +import com.l2jfree.gameserver.model.actor.instance.L2PcInstance;
  64. +import com.l2jfree.gameserver.model.entity.Town;
  65. +import com.l2jfree.gameserver.model.L2Spawn;
  66. +
  67. +
  68. +/*
  69. + * @author EverDreaM,Ph@t3
  70. + */
  71. +
  72. +public class Mammon implements IVoicedCommandHandler
  73. +{
  74. + private static String[] _voicedCommands = { "mammon", "mmammon", "bmammon" };
  75. + private String mnearestTown, bnearestTown;
  76. + private SpawnTable s = SpawnTable.getInstance();
  77. +
  78. + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
  79. + {
  80. + if(command.startsWith("mammon"))
  81. + return MammonInfo(activeChar);
  82. + else if(command.startsWith("mmammon"))
  83. + return MMammonInfo(activeChar);
  84. + else if(command.startsWith("bmammon"))
  85. + return BMammonInfo(activeChar);
  86. + return false;
  87. + }
  88. +
  89. + public boolean initMammon(L2PcInstance activeChar)
  90. + {
  91. + if (!SevenSigns.getInstance().isSealValidationPeriod())
  92. + {
  93. + activeChar.sendMessage("The competition period is currently in effect.");
  94. + return false;
  95. + }
  96. + else
  97. + {
  98. + mnearestTown = findNPCLocTown(SevenSigns.MAMMON_MERCHANT_ID);
  99. + bnearestTown = findNPCLocTown(SevenSigns.MAMMON_BLACKSMITH_ID);
  100. + return true;
  101. + }
  102. + }
  103. +
  104. + public String findNPCLocTown(int npcId)
  105. + {
  106. + String nearestTown = "";
  107. + for (L2Spawn spawn : s.getSpawnTable().values())
  108. + if (npcId == spawn.getNpcid()) {
  109. + Town town = TownManager.getInstance().getClosestTown(spawn.getLocx(), spawn.getLocy(), spawn.getLocz());
  110. + if (town != null)
  111. + nearestTown = TownManager.getInstance().getTownName(town.getTownId());
  112. + else
  113. + nearestTown = "None";
  114. + }
  115. + return nearestTown;
  116. +
  117. + }
  118. +
  119. + public boolean MammonInfo(L2PcInstance activeChar)
  120. + {
  121. + if (initMammon(activeChar))
  122. + {
  123. + activeChar.sendMessage("The Merchant of Mammon is near " + mnearestTown);
  124. + activeChar.sendMessage("The Blacksmith of Mammon is near " + bnearestTown);
  125. + }
  126. + return true;
  127. + }
  128. + public boolean MMammonInfo(L2PcInstance activeChar)
  129. + {
  130. + if (initMammon(activeChar))
  131. + {
  132. + activeChar.sendMessage("The Merchant of Mammon is near " + mnearestTown);
  133. + }
  134. + return true;
  135. + }
  136. + public boolean BMammonInfo(L2PcInstance activeChar)
  137. + {
  138. + if (initMammon(activeChar))
  139. + {
  140. + activeChar.sendMessage("The Blacksmith of Mammon is near " + bnearestTown);
  141. + }
  142. + return true;
  143. + }
  144. +
  145. + public String[] getVoicedCommandList()
  146. + {
  147. + return _voicedCommands;
  148. + }
  149. +}
  150. Index: config/options.properties
  151. ===================================================================
  152. --- config/options.properties (revision 4957)
  153. +++ config/options.properties (working copy)
  154. @@ -330,4 +330,7 @@
  155. EnableJythonShell = False
  156.  
  157. # Interval in ms to check for deadlocks, 0 to disable
  158. -DeadLockCheck = 10000
  159. \ No newline at end of file
  160. +DeadLockCheck = 10000
  161. +
  162. +#Allow Voice Command Handler for Mammons spawn location
  163. +AllowMammonVoice = False
  164. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement