AdminGraciaSeeds.java 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 25/07/2005 17:15:21 $
  6. * $Revision: 1 $
  7. * $Log: AdminTest.java,v $
  8. * Revision 1 25/07/2005 17:15:21 luisantonioa
  9. * Added copyright notice
  10. *
  11. *
  12. * This program is free software: you can redistribute it and/or modify it under
  13. * the terms of the GNU General Public License as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option) any later
  15. * version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License along with
  23. * this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. package handlers.admincommandhandlers;
  26. import java.util.Calendar;
  27. import java.util.StringTokenizer;
  28. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  29. import com.l2jserver.gameserver.instancemanager.GraciaSeedsManager;
  30. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  31. import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  32. public class AdminGraciaSeeds implements IAdminCommandHandler
  33. {
  34. private static final String[] ADMIN_COMMANDS =
  35. {
  36. "admin_gracia_seeds",
  37. "admin_kill_tiat",
  38. "admin_set_sodstate"
  39. };
  40. /**
  41. *
  42. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
  43. */
  44. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  45. {
  46. StringTokenizer st = new StringTokenizer(command, " ");
  47. String actualCommand = st.nextToken(); // Get actual command
  48. String val = "";
  49. if (st.countTokens() >= 1)
  50. {
  51. val = st.nextToken();
  52. }
  53. if (actualCommand.equalsIgnoreCase("admin_kill_tiat"))
  54. GraciaSeedsManager.getInstance().increaseSoDTiatKilled();
  55. else if (actualCommand.equalsIgnoreCase("admin_set_sodstate"))
  56. GraciaSeedsManager.getInstance().setSoDState(Integer.parseInt(val), true);
  57. showMenu(activeChar);
  58. return true;
  59. }
  60. private void showMenu(L2PcInstance activeChar)
  61. {
  62. NpcHtmlMessage html = new NpcHtmlMessage(0);
  63. html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/graciaseeds.htm");
  64. html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
  65. html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
  66. if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
  67. {
  68. Calendar nextChangeDate = Calendar.getInstance();
  69. nextChangeDate.setTimeInMillis(System.currentTimeMillis() + GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange());
  70. html.replace("%sodtime%", nextChangeDate.getTime().toString());
  71. }
  72. else
  73. html.replace("%sodtime%", "-1");
  74. activeChar.sendPacket(html);
  75. }
  76. /**
  77. *
  78. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
  79. */
  80. public String[] getAdminCommandList()
  81. {
  82. return ADMIN_COMMANDS;
  83. }
  84. }