Advertisement
Guest User

Auto Twar. (AbsolutePower)

a guest
Sep 23rd, 2012
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  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 com.l2jfrozen.gameserver.model.entity.event;
  16.  
  17. import java.util.Collection;
  18. import java.util.concurrent.ScheduledFuture;
  19.  
  20. import com.l2jfrozen.gameserver.managers.TownManager;
  21. import com.l2jfrozen.gameserver.model.L2World;
  22. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jfrozen.gameserver.model.entity.Announcements;
  24. import com.l2jfrozen.gameserver.model.zone.type.L2TownZone;
  25. import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
  26.  
  27. /**
  28. * @author AbsolutePower
  29. *
  30. */
  31. public class FunnyWarEvent
  32. {
  33. static ScheduledFuture<?> _Twar;
  34. static L2PcInstance aC;
  35. static int Minutes =30;
  36.  
  37. static class StartAutoWar implements Runnable
  38. {
  39. @Override
  40. public void run()
  41. { aC = this.getActingPlayer();
  42. startWar(aC);
  43. ThreadPoolManager.getInstance().scheduleGeneral(new StartAutoWar(), (Minutes)*1000*60);
  44. }
  45.  
  46. private L2PcInstance getActingPlayer()
  47. {
  48. return getActingPlayer();
  49. }
  50. }
  51.  
  52. public static void StartFunnyWar()
  53. {
  54. _Twar = ThreadPoolManager.getInstance().scheduleGeneral(new StartAutoWar(), (Minutes)*1000*60);
  55. }
  56.  
  57. public static void StopFunnyWar()
  58. {
  59. if(_Twar != null)
  60. {
  61. _Twar.cancel(true);
  62. _Twar = null;
  63. }
  64. }
  65.  
  66. public static void StopFunnyWarAndStart()
  67. {
  68. if(_Twar != null)
  69. {
  70. _Twar.cancel(true);
  71. _Twar = null;
  72. _Twar = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new StartAutoWar(), (Minutes)*1000*60, (Minutes)*1000*60);
  73. }
  74. }
  75.  
  76. public static void startWar(final L2PcInstance activeChar)
  77. {
  78. final int Gludin =5;
  79. final String TownName = TownManager.getInstance().getTown(Gludin).getName();
  80.  
  81. TownManager.getInstance().getTown(Gludin).setParameter("noPeace", "true");
  82.  
  83. Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
  84. {
  85. int x,y,z;
  86. L2TownZone Town;
  87. byte Tz = 1;
  88.  
  89. for(L2PcInstance oP : pls)
  90. if(oP.isOnline() == 1 )
  91. {
  92. x = oP.getX();
  93. y = oP.getY();
  94. z = oP.getZ();
  95.  
  96. Town = TownManager.getInstance().getTown(x, y, z);
  97. if(Town != null)
  98. {
  99. oP.setInsideZone(Tz, false);
  100. oP.revalidateZone(true);
  101. oP.setInTownWar(true);
  102. }
  103. }
  104.  
  105. Announcements.getInstance().gameAnnounceToAll(TownName + " has been set to war zone.");
  106. StopFunnyWarAndStart();
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement