AdminMammon.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.admincommandhandlers;
  16. import com.l2jserver.gameserver.SevenSigns;
  17. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  18. import com.l2jserver.gameserver.model.AutoSpawnHandler;
  19. import com.l2jserver.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
  20. import com.l2jserver.gameserver.model.actor.L2Npc;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. /**
  23. * Admin Command Handler for Mammon NPCs
  24. *
  25. * @author Tempy
  26. * Typo fix by Zoey76 24/02/2011
  27. */
  28. public class AdminMammon implements IAdminCommandHandler
  29. {
  30. private static final String[] ADMIN_COMMANDS =
  31. {
  32. "admin_mammon_find",
  33. "admin_mammon_respawn",
  34. };
  35. private boolean _isSealValidation = SevenSigns.getInstance().isSealValidationPeriod();
  36. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  37. {
  38. int teleportIndex = -1;
  39. AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false);
  40. AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false);
  41. if (command.startsWith("admin_mammon_find"))
  42. {
  43. try
  44. {
  45. if (command.length() > 17)
  46. teleportIndex = Integer.parseInt(command.substring(18));
  47. }
  48. catch (Exception NumberFormatException)
  49. {
  50. activeChar.sendMessage("Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)");
  51. return false;
  52. }
  53. if (!_isSealValidation)
  54. {
  55. activeChar.sendMessage("The competition period is currently in effect.");
  56. return false;
  57. }
  58. if (blackSpawnInst != null)
  59. {
  60. L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList();
  61. if (blackInst.length > 0)
  62. {
  63. int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ();
  64. activeChar.sendMessage("Blacksmith of Mammon: " + x1 + " " + y1 + " " + z1);
  65. if (teleportIndex == 1)
  66. activeChar.teleToLocation(x1, y1, z1, true);
  67. }
  68. }
  69. else
  70. activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
  71. if (merchSpawnInst != null)
  72. {
  73. L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList();
  74. if (merchInst.length > 0)
  75. {
  76. int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ();
  77. activeChar.sendMessage("Merchant of Mammon: " + x2 + " " + y2 + " " + z2);
  78. if (teleportIndex == 2)
  79. activeChar.teleToLocation(x2, y2, z2, true);
  80. }
  81. }
  82. else
  83. activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
  84. }
  85. else if (command.startsWith("admin_mammon_respawn"))
  86. {
  87. if (!_isSealValidation)
  88. {
  89. activeChar.sendMessage("The competition period is currently in effect.");
  90. return true;
  91. }
  92. if (merchSpawnInst != null)
  93. {
  94. long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst);
  95. activeChar.sendMessage("The Merchant of Mammon will respawn in " + (merchRespawn / 60000) + " minute(s).");
  96. }
  97. else
  98. activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
  99. if (blackSpawnInst != null)
  100. {
  101. long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst);
  102. activeChar.sendMessage("The Blacksmith of Mammon will respawn in " + (blackRespawn / 60000) + " minute(s).");
  103. }
  104. else
  105. activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
  106. }
  107. return true;
  108. }
  109. public String[] getAdminCommandList()
  110. {
  111. return ADMIN_COMMANDS;
  112. }
  113. }