AdminMammon.java 4.4 KB

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