Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package com.l2jfrozen.gameserver.model.entity.event;
- import java.util.Collection;
- import java.util.concurrent.ScheduledFuture;
- import com.l2jfrozen.gameserver.managers.TownManager;
- import com.l2jfrozen.gameserver.model.L2World;
- import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- import com.l2jfrozen.gameserver.model.entity.Announcements;
- import com.l2jfrozen.gameserver.model.zone.type.L2TownZone;
- import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
- /**
- * @author AbsolutePower
- *
- */
- public class FunnyWarEvent
- {
- static ScheduledFuture<?> _Twar;
- static L2PcInstance aC;
- static int Minutes =30;
- static class StartAutoWar implements Runnable
- {
- @Override
- public void run()
- { aC = this.getActingPlayer();
- startWar(aC);
- ThreadPoolManager.getInstance().scheduleGeneral(new StartAutoWar(), (Minutes)*1000*60);
- }
- private L2PcInstance getActingPlayer()
- {
- return getActingPlayer();
- }
- }
- public static void StartFunnyWar()
- {
- _Twar = ThreadPoolManager.getInstance().scheduleGeneral(new StartAutoWar(), (Minutes)*1000*60);
- }
- public static void StopFunnyWar()
- {
- if(_Twar != null)
- {
- _Twar.cancel(true);
- _Twar = null;
- }
- }
- public static void StopFunnyWarAndStart()
- {
- if(_Twar != null)
- {
- _Twar.cancel(true);
- _Twar = null;
- _Twar = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new StartAutoWar(), (Minutes)*1000*60, (Minutes)*1000*60);
- }
- }
- public static void startWar(final L2PcInstance activeChar)
- {
- final int Gludin =5;
- final String TownName = TownManager.getInstance().getTown(Gludin).getName();
- TownManager.getInstance().getTown(Gludin).setParameter("noPeace", "true");
- Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
- {
- int x,y,z;
- L2TownZone Town;
- byte Tz = 1;
- for(L2PcInstance oP : pls)
- if(oP.isOnline() == 1 )
- {
- x = oP.getX();
- y = oP.getY();
- z = oP.getZ();
- Town = TownManager.getInstance().getTown(x, y, z);
- if(Town != null)
- {
- oP.setInsideZone(Tz, false);
- oP.revalidateZone(true);
- oP.setInTownWar(true);
- }
- }
- Announcements.getInstance().gameAnnounceToAll(TownName + " has been set to war zone.");
- StopFunnyWarAndStart();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement