AdminGraciaSeeds.java 2.8 KB

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