FourSepulchersChangeWarmUpTimeTask.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 com.l2jserver.gameserver.instancemanager.tasks;
  20. import java.util.Calendar;
  21. import java.util.concurrent.ScheduledFuture;
  22. import com.l2jserver.Config;
  23. import com.l2jserver.gameserver.ThreadPoolManager;
  24. import com.l2jserver.gameserver.instancemanager.FourSepulchersManager;
  25. /**
  26. * @author xban1x
  27. */
  28. public final class FourSepulchersChangeWarmUpTimeTask implements Runnable
  29. {
  30. @Override
  31. public void run()
  32. {
  33. final FourSepulchersManager manager = FourSepulchersManager.getInstance();
  34. manager.setIsEntryTime(true);
  35. manager.setIsWarmUpTime(false);
  36. manager.setIsAttackTime(false);
  37. manager.setIsCoolDownTime(false);
  38. long interval = 0;
  39. // searching time when warmup time will be ended:
  40. // counting difference between time when warmup time ends and
  41. // current time
  42. // and then launching change time task
  43. if (manager.isFirstTimeRun())
  44. {
  45. interval = manager.getWarmUpTimeEnd() - Calendar.getInstance().getTimeInMillis();
  46. }
  47. else
  48. {
  49. interval = Config.FS_TIME_WARMUP * 60000L;
  50. }
  51. manager.setChangeAttackTimeTask(ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeAttackTimeTask(), interval));
  52. final ScheduledFuture<?> changeWarmUpTimeTask = manager.getChangeWarmUpTimeTask();
  53. if (changeWarmUpTimeTask != null)
  54. {
  55. changeWarmUpTimeTask.cancel(true);
  56. manager.setChangeWarmUpTimeTask(null);
  57. }
  58. }
  59. }