Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_datapack
- Index: data/xml/zones/RandomZone.xml
- ===================================================================
- --- data/xml/zones/RandomZone.xml (revision 0)
- +++ data/xml/zones/RandomZone.xml (revision 0)
- @@ -0,0 +1,19 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<list>
- + <zone shape="Cuboid" minZ="-3752" maxZ="-352"><!-- gludin_pvp -->
- + <stat name="id" val="1" />
- + <stat name="name" val="Gludin Arena" />
- + <stat name="time" val="30" /><!-- time in seconds -->
- + <stat name="locs" val="-88339,141802,-3649;-87894,142231,-3649" />
- + <node X="-88411" Y="141732" />
- + <node X="-87429" Y="142708" />
- + </zone>
- + <zone shape="Cuboid" minZ="-3850" maxZ="-350"><!-- giran_pvp_battle -->
- + <stat name="id" val="2" />
- + <stat name="name" val="Giran Arena" />
- + <stat name="time" val="30" /><!-- time in seconds -->
- + <stat name="locs" val="73306,142440,-3775;72646,142403,-3775" />
- + <node X="72493" Y="142263" />
- + <node X="73493" Y="143261" />
- + </zone>
- +</list>
- \ No newline at end of file
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 31)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -100,6 +100,7 @@
- import net.sf.l2j.gameserver.taskmanager.MovementTaskManager;
- import net.sf.l2j.gameserver.taskmanager.PvpFlagTaskManager;
- import net.sf.l2j.gameserver.taskmanager.RandomAnimationTaskManager;
- +import net.sf.l2j.gameserver.taskmanager.RandomZoneTaskManager;
- import net.sf.l2j.gameserver.taskmanager.ShadowItemTaskManager;
- import net.sf.l2j.gameserver.taskmanager.WaterTaskManager;
- import net.sf.l2j.gameserver.xmlfactory.XMLDocumentFactory;
- @@ -221,6 +222,7 @@
- RandomAnimationTaskManager.getInstance();
- ShadowItemTaskManager.getInstance();
- WaterTaskManager.getInstance();
- + RandomZoneTaskManager.getInstance();
- StringUtil.printSection("Seven Signs");
- SevenSigns.getInstance().spawnSevenSignsNPC();
- Index: java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java (revision 30)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java (working copy)
- @@ -12,6 +12,7 @@
- import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
- import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
- +import net.sf.l2j.gameserver.taskmanager.RandomZoneTaskManager;
- /**
- * An instance type extending {@link Folk}, used for teleporters.<br>
- @@ -135,6 +136,8 @@
- }
- showChatWindow(player, val);
- }
- + else if (command.startsWith("pvp"))
- + player.teleToLocation(RandomZoneTaskManager.getInstance().getCurrentZone().getLoc(), 25);
- else
- super.onBypassFeedback(player, command);
- }
- Index: java/net/sf/l2j/gameserver/model/zone/ZoneId.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/zone/ZoneId.java (revision 30)
- +++ java/net/sf/l2j/gameserver/model/zone/ZoneId.java (working copy)
- @@ -21,7 +21,8 @@
- CAST_ON_ARTIFACT(16),
- NO_RESTART(17),
- SCRIPT(18),
- - BOSS(19);
- + BOSS(19),
- + RANDOM(20);
- private final int _id;
- Index: java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java (revision 0)
- +++ java/net/sf/l2j/gameserver/model/zone/type/RandomZone.java (revision 0)
- @@ -0,0 +1,78 @@
- +package net.sf.l2j.gameserver.model.zone.type;
- +
- +import java.util.ArrayList;
- +import java.util.List;
- +
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.gameserver.model.actor.Creature;
- +import net.sf.l2j.gameserver.model.location.Location;
- +import net.sf.l2j.gameserver.model.zone.SpawnZoneType;
- +import net.sf.l2j.gameserver.model.zone.ZoneId;
- +
- +/**
- + * @author StinkyMadness
- + */
- +public class RandomZone extends SpawnZoneType
- +{
- + private int _id;
- + private String _name;
- + private int _time;
- + private List<Location> _locations = new ArrayList<>();
- +
- + public RandomZone(int id)
- + {
- + super(id);
- + }
- +
- + @Override
- + public void setParameter(String name, String value)
- + {
- + if (name.equals("id"))
- + _id = Integer.parseInt(value);
- + else if (name.equals("name"))
- + _name = value;
- + else if (name.equals("time"))
- + _time = Integer.parseInt(value);
- + else if (name.equals("locs"))
- + {
- + for (String locs : value.split(";"))
- + _locations.add(new Location(Integer.valueOf(locs.split(",")[0]), Integer.valueOf(locs.split(",")[1]), Integer.valueOf(locs.split(",")[2])));
- + }
- + else
- + super.setParameter(name, value);
- + }
- +
- + @Override
- + protected void onEnter(Creature character)
- + {
- + character.setInsideZone(ZoneId.RANDOM, true);
- + }
- +
- + @Override
- + protected void onExit(Creature character)
- + {
- + character.setInsideZone(ZoneId.RANDOM, false);
- + }
- +
- + @Override
- + public int getId()
- + {
- + return _id;
- + }
- +
- + public String getName()
- + {
- + return _name;
- + }
- +
- + public int getTime()
- + {
- + return _time;
- + }
- +
- + public Location getLoc()
- + {
- + return _locations.get(Rnd.get(0, _locations.size() - 1));
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (revision 30)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -57,6 +57,7 @@
- import net.sf.l2j.gameserver.scripting.Quest;
- import net.sf.l2j.gameserver.scripting.QuestState;
- import net.sf.l2j.gameserver.taskmanager.GameTimeTaskManager;
- +import net.sf.l2j.gameserver.taskmanager.RandomZoneTaskManager;
- public class EnterWorld extends L2GameClientPacket
- {
- @@ -322,6 +323,9 @@
- if (!player.isGM() && (!player.isInSiege() || player.getSiegeState() < 2) && player.isInsideZone(ZoneId.SIEGE))
- player.teleToLocation(TeleportType.TOWN);
- + if (!player.isGM() && player.isInsideZone(ZoneId.RANDOM))
- + player.teleToLocation(RandomZoneTaskManager.getInstance().getCurrentZone().getLoc(), 25);
- +
- player.sendPacket(ActionFailed.STATIC_PACKET);
- }
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 30)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (working copy)
- @@ -14,6 +14,8 @@
- import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
- import net.sf.l2j.gameserver.model.location.Location;
- import net.sf.l2j.gameserver.model.pledge.Clan;
- +import net.sf.l2j.gameserver.model.zone.ZoneId;
- +import net.sf.l2j.gameserver.taskmanager.RandomZoneTaskManager;
- public final class RequestRestartPoint extends L2GameClientPacket
- {
- @@ -117,6 +119,12 @@
- // Fixed.
- else if (_requestType == 4)
- {
- + if (!player.isGM() && player.isInsideZone(ZoneId.RANDOM))
- + {
- + loc = RandomZoneTaskManager.getInstance().getCurrentZone().getLoc();
- + return;
- + }
- +
- if (!player.isGM() && !player.isFestivalParticipant())
- return;
- Index: java/net/sf/l2j/gameserver/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 30)
- +++ java/net/sf/l2j/gameserver/network/serverpackets/Die.java (working copy)
- @@ -7,6 +7,7 @@
- import net.sf.l2j.gameserver.model.entity.Siege;
- import net.sf.l2j.gameserver.model.entity.Siege.SiegeSide;
- import net.sf.l2j.gameserver.model.pledge.Clan;
- +import net.sf.l2j.gameserver.model.zone.ZoneId;
- public class Die extends L2GameServerPacket
- {
- @@ -27,7 +28,7 @@
- if (cha instanceof Player)
- {
- Player player = (Player) cha;
- - _allowFixedRes = player.getAccessLevel().allowFixedRes();
- + _allowFixedRes = player.getAccessLevel().allowFixedRes() || player.isInsideZone(ZoneId.RANDOM);
- _clan = player.getClan();
- }
- Index: java/net/sf/l2j/gameserver/taskmanager/RandomZoneTaskManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/taskmanager/RandomZoneTaskManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/taskmanager/RandomZoneTaskManager.java (revision 0)
- @@ -0,0 +1,105 @@
- +package net.sf.l2j.gameserver.taskmanager;
- +
- +import net.sf.l2j.commons.concurrent.ThreadPool;
- +import net.sf.l2j.commons.random.Rnd;
- +
- +import net.sf.l2j.gameserver.data.manager.ZoneManager;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.instance.Player;
- +import net.sf.l2j.gameserver.model.zone.ZoneId;
- +import net.sf.l2j.gameserver.model.zone.type.RandomZone;
- +import net.sf.l2j.gameserver.util.Broadcast;
- +
- +/**
- + * @author StinkyMadness
- + */
- +public final class RandomZoneTaskManager implements Runnable
- +{
- + private int _zoneId;
- + private int _timer;
- +
- + public RandomZoneTaskManager()
- + {
- + if (getTotalZones() > 1)
- + ThreadPool.scheduleAtFixedRate(this, 1000, 1000);
- + }
- +
- + @Override
- + public void run()
- + {
- + if (_timer > 0)
- + _timer--;
- + else
- + selectNextZone();
- +
- + switch (_timer)
- + {
- + case 0:
- + Broadcast.announceToOnlinePlayers("PvP zone will has been changed.", true);
- + Broadcast.announceToOnlinePlayers("Current zone : " + getCurrentZone().getName(), true);
- + for (Player player : World.getInstance().getPlayers())
- + if (player != null && player.isOnline() && player.isInsideZone(ZoneId.RANDOM))
- + player.teleToLocation(getCurrentZone().getLoc(), 50);
- + break;
- + case 5:
- + case 15:
- + case 30:
- + Broadcast.announceToOnlinePlayers("PvP zone will change in " + _timer + " second(s).", true);
- + break;
- + case 60:
- + case 300:
- + case 600:
- + case 900:
- + case 1800:
- + Broadcast.announceToOnlinePlayers("PvP zone will change in " + _timer / 60 + " minute(s).", true);
- + break;
- + case 3600:
- + case 7200:
- + Broadcast.announceToOnlinePlayers("PvP zone will change in " + (_timer / 60) / 60 + " hour(s).", true);
- + break;
- + }
- + }
- +
- + public int getZoneId()
- + {
- + return _zoneId;
- + }
- +
- + public void selectNextZone()
- + {
- + int nextZoneId = Rnd.get(1, getTotalZones());
- + while (getZoneId() == nextZoneId)
- + nextZoneId = Rnd.get(1, getTotalZones());
- + _zoneId = nextZoneId;
- +
- + _timer = getCurrentZone().getTime() + 10;
- + }
- +
- + public final RandomZone getCurrentZone()
- + {
- + return ZoneManager.getInstance().getAllZones(RandomZone.class).stream().filter(t -> t.getId() == getZoneId()).findFirst().orElse(null);
- + }
- +
- + public static int getTotalZones()
- + {
- + int size = 0;
- + for (RandomZone i : ZoneManager.getInstance().getAllZones(RandomZone.class))
- + {
- + if (i == null)
- + continue;
- +
- + size++;
- + }
- + return size;
- + }
- +
- + public static final RandomZoneTaskManager getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final RandomZoneTaskManager INSTANCE = new RandomZoneTaskManager();
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement