Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/Gatekeeper.java (revision 6)
- +++ 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.teleportTo(RandomZoneTaskManager.getInstance().getCurrentZone().getLoc(), 25);
- else
- super.onBypassFeedback(player, command);
- }
- 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 (working copy)
- @@ -0,0 +1,94 @@
- +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.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 _id;
- + 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);
- + World.getInstance().getPlayers().stream().filter(x -> x.isInsideZone(ZoneId.RANDOM)).forEach(x -> x.teleportTo(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 _id;
- + }
- +
- + public void selectNextZone()
- + {
- + int nextZoneId = Rnd.get(1, getTotalZones());
- + while (getZoneId() == nextZoneId)
- + nextZoneId = Rnd.get(1, getTotalZones());
- + _id = nextZoneId;
- +
- + _timer = getCurrentZone().getTime();
- + }
- +
- + public final RandomZone getCurrentZone()
- + {
- + return ZoneManager.getInstance().getAllZones(RandomZone.class).stream().filter(t -> t.getId() == getZoneId()).findFirst().orElse(null);
- + }
- +
- + public static final int getTotalZones()
- + {
- + return ZoneManager.getInstance().getAllZones(RandomZone.class).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
- Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/RequestRestartPoint.java (revision 6)
- +++ 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
- {
- @@ -120,7 +122,10 @@
- if (!player.isGM() && !player.isFestivalParticipant())
- return;
- - loc = player.getPosition();
- + if (!player.isGM() && player.isInsideZone(ZoneId.RANDOM))
- + loc = RandomZoneTaskManager.getInstance().getCurrentZone().getLoc();
- + else
- + loc = player.getPosition();
- }
- // To jail.
- else if (_requestType == 27)
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 6)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -97,6 +97,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;
- @@ -216,6 +217,7 @@
- RandomAnimationTaskManager.getInstance();
- ShadowItemTaskManager.getInstance();
- WaterTaskManager.getInstance();
- + RandomZoneTaskManager.getInstance();
- StringUtil.printSection("Seven Signs");
- SevenSigns.getInstance().spawnSevenSignsNPC();
- 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 (working copy)
- @@ -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/model/zone/ZoneId.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/zone/ZoneId.java (revision 6)
- +++ 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/network/serverpackets/Die.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/serverpackets/Die.java (revision 6)
- +++ 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();
- }
- #P aCis_datapack
- Index: data/xml/zones/RandomZone.xml
- ===================================================================
- --- data/xml/zones/RandomZone.xml (revision 0)
- +++ data/xml/zones/RandomZone.xml (working copy)
- @@ -0,0 +1,21 @@
- +<?xml version="1.0" encoding="UTF-8"?>
- +<list>
- + <!-- Random Zones -->
- + <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" />
- + <spawn x="73890" y="142656" z="-3778" />
- + </zone>
- +</list>
- \ No newline at end of file
Add Comment
Please, Sign In to add comment