AdminGraciaSeeds.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 java.util.Calendar;
  17. import java.util.StringTokenizer;
  18. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  19. import com.l2jserver.gameserver.instancemanager.GraciaSeedsManager;
  20. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  21. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  22. public class AdminGraciaSeeds implements IAdminCommandHandler
  23. {
  24. private static final String[] ADMIN_COMMANDS =
  25. {
  26. "admin_gracia_seeds",
  27. "admin_kill_tiat",
  28. "admin_set_sodstate"
  29. };
  30. /**
  31. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
  32. */
  33. @Override
  34. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  35. {
  36. StringTokenizer st = new StringTokenizer(command, " ");
  37. String actualCommand = st.nextToken(); // Get actual command
  38. String val = "";
  39. if (st.countTokens() >= 1)
  40. {
  41. val = st.nextToken();
  42. }
  43. if (actualCommand.equalsIgnoreCase("admin_kill_tiat"))
  44. GraciaSeedsManager.getInstance().increaseSoDTiatKilled();
  45. else if (actualCommand.equalsIgnoreCase("admin_set_sodstate"))
  46. GraciaSeedsManager.getInstance().setSoDState(Integer.parseInt(val), true);
  47. showMenu(activeChar);
  48. return true;
  49. }
  50. private void showMenu(L2PcInstance activeChar)
  51. {
  52. NpcHtmlMessage html = new NpcHtmlMessage(0);
  53. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/graciaseeds.htm");
  54. html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
  55. html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
  56. if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
  57. {
  58. Calendar nextChangeDate = Calendar.getInstance();
  59. nextChangeDate.setTimeInMillis(System.currentTimeMillis() + GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange());
  60. html.replace("%sodtime%", nextChangeDate.getTime().toString());
  61. }
  62. else
  63. html.replace("%sodtime%", "-1");
  64. activeChar.sendPacket(html);
  65. }
  66. /**
  67. *
  68. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
  69. */
  70. @Override
  71. public String[] getAdminCommandList()
  72. {
  73. return ADMIN_COMMANDS;
  74. }
  75. }