AdminMammon.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.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();
  67. if (blackInst.length > 0)
  68. {
  69. final int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ();
  70. activeChar.sendMessage("Blacksmith of Mammon: " + x1 + " " + y1 + " " + z1);
  71. if (teleportIndex == 1)
  72. {
  73. activeChar.teleToLocation(blackInst[0].getLocation(), true);
  74. }
  75. }
  76. }
  77. else
  78. {
  79. activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
  80. }
  81. if (merchSpawnInst != null)
  82. {
  83. final L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList();
  84. if (merchInst.length > 0)
  85. {
  86. final int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ();
  87. activeChar.sendMessage("Merchant of Mammon: " + x2 + " " + y2 + " " + z2);
  88. if (teleportIndex == 2)
  89. {
  90. activeChar.teleToLocation(merchInst[0].getLocation(), true);
  91. }
  92. }
  93. }
  94. else
  95. {
  96. activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
  97. }
  98. }
  99. else if (command.startsWith("admin_mammon_respawn"))
  100. {
  101. if (!_isSealValidation)
  102. {
  103. activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY);
  104. return true;
  105. }
  106. if (merchSpawnInst != null)
  107. {
  108. long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst);
  109. activeChar.sendMessage("The Merchant of Mammon will respawn in " + (merchRespawn / 60000) + " minute(s).");
  110. }
  111. else
  112. {
  113. activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
  114. }
  115. if (blackSpawnInst != null)
  116. {
  117. long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst);
  118. activeChar.sendMessage("The Blacksmith of Mammon will respawn in " + (blackRespawn / 60000) + " minute(s).");
  119. }
  120. else
  121. {
  122. activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
  123. }
  124. }
  125. return true;
  126. }
  127. @Override
  128. public String[] getAdminCommandList()
  129. {
  130. return ADMIN_COMMANDS;
  131. }
  132. }