AdminGraciaSeeds.java 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. @Override
  31. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  32. {
  33. StringTokenizer st = new StringTokenizer(command, " ");
  34. String actualCommand = st.nextToken(); // Get actual command
  35. String val = "";
  36. if (st.countTokens() >= 1)
  37. {
  38. val = st.nextToken();
  39. }
  40. if (actualCommand.equalsIgnoreCase("admin_kill_tiat"))
  41. GraciaSeedsManager.getInstance().increaseSoDTiatKilled();
  42. else if (actualCommand.equalsIgnoreCase("admin_set_sodstate"))
  43. GraciaSeedsManager.getInstance().setSoDState(Integer.parseInt(val), true);
  44. showMenu(activeChar);
  45. return true;
  46. }
  47. private void showMenu(L2PcInstance activeChar)
  48. {
  49. NpcHtmlMessage html = new NpcHtmlMessage(0);
  50. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/graciaseeds.htm");
  51. html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
  52. html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
  53. if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
  54. {
  55. Calendar nextChangeDate = Calendar.getInstance();
  56. nextChangeDate.setTimeInMillis(System.currentTimeMillis() + GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange());
  57. html.replace("%sodtime%", nextChangeDate.getTime().toString());
  58. }
  59. else
  60. html.replace("%sodtime%", "-1");
  61. activeChar.sendPacket(html);
  62. }
  63. @Override
  64. public String[] getAdminCommandList()
  65. {
  66. return ADMIN_COMMANDS;
  67. }
  68. }