ThreadPool manager rework.

This commit is contained in:
MobiusDev
2017-08-23 05:23:31 +00:00
parent 374c53df4b
commit b77de360af
718 changed files with 3180 additions and 7193 deletions
+15 -22
View File
@@ -149,33 +149,26 @@ SkillCheckGM = False
# Thread Configuration
# ---------------------------------------------------------------------------
# Extreme caution should be here, set to defaults if you do not know what you are doing.
# These could possibly hurt your servers performance or improve it depending on your server's configuration, size, and other factors.
# Default: 10
ThreadPoolSizeEffects = 50
# Determines the amount of scheduled thread pools. If set to -1, the server will decide the amount depending on the available processors.
Default: -1
ScheduledThreadPoolCount = -1
# Default: 13
ThreadPoolSizeGeneral = 65
# Specifies how many threads will be in a single scheduled pool.
Default: 4
ThreadsPerScheduledThreadPool = 40
# Default: 2
ThreadPoolSizeEvents = 10
# Determines the amount of instant thread pools. If set to -1, the server will decide the amount depending on the available processors.
Default: -1
InstantThreadPoolCount = -1
# Default: 2
UrgentPacketThreadCoreSize = 20
# Specifies how many threads will be in a single instant pool.
Default: 2
ThreadsPerInstantThreadPool = 20
# Default: 4
GeneralPacketThreadCoreSize = 20
# Default: 4
GeneralThreadCoreSize = 20
# Default: 6
AiMaxThread = 30
# Default: 5
EventsMaxThread = 25
# Dead Lock Detector (a separate thread for detecting deadlocks).
# ---------------------------------------------------------------------------
# Dead Lock Detector (separate thread for detecting deadlocks)
# ---------------------------------------------------------------------------
# For improved crash logs and automatic restart in deadlock case if enabled.
# Check interval is in seconds.
# Default: True
@@ -8,7 +8,6 @@
</tr>
</table>
<br>
<br>
<font color="LEVEL">General:<font><br1>
<table width="270" border="0" bgcolor="444444">
<tr>
@@ -76,30 +75,5 @@
<td><font color="00FF00">%totalMem% MB</font></td>
</tr>
</table>
<br>
<font color="LEVEL">Thread - General (STP):<font><br1>
%theardInfoGen%
<br>
<font color="LEVEL">Thread - Effects (STP):<font><br1>
%theardInfoEff%
<br>
<font color="LEVEL">Thread - AI (STP):<font><br1>
%theardInfoAi%
<br>
<font color="LEVEL">Thread - Event (STP):<font><br1>
%theardInfoEvent%
<br>
<font color="LEVEL">Thread - Packets (TP):<font><br1>
%theardInfoPack%
<br>
<font color="LEVEL">Thread - I/O Packets (TP):<font><br1>
%theardInfoIOPack%
<br>
<font color="LEVEL">Thread - General Tasks (TP):<font><br1>
%theardInfoGenTask%
<br>
<font color="LEVEL">Thread - Event Tasks (TP):<font><br1>
%theardInfoEvnTask%
<br>
</center>
</body></html>
@@ -131,11 +131,11 @@ public final class Parade extends AbstractNpcAI
// Starts at 8:00 and repeats every 6 hours.
final long diff = timeLeftMilli(8, 0, 0), cycle = 3600000L;
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Start(), diff, cycle);
ThreadPoolManager.scheduleAtFixedRate(new Start(), diff, cycle);
// Test - Starts 3 minutes after server startup and repeats every 20 minutes.
// final long diff = timeLeftMilli(8, 0, 0), cycle = 600000L;
// ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Start(), 180000L, cycle);
// ThreadPoolManager.scheduleAtFixedRate(new Start(), 180000L, cycle);
_log.info("Fantasy Isle: Parade starting at " + new SimpleDateFormat("yyyy/MM/dd HH:mm").format(System.currentTimeMillis() + diff) + " and is scheduled each next " + (cycle / 3600000) + " hours.");
}
@@ -173,9 +173,9 @@ public final class Parade extends AbstractNpcAI
public void run()
{
load();
spawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Spawn(), 0, 5000);
deleteTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Delete(), 10000, 1000);
cleanTask = ThreadPoolManager.getInstance().scheduleGeneral(new Clean(), 420000);
spawnTask = ThreadPoolManager.scheduleAtFixedRate(new Spawn(), 0, 5000);
deleteTask = ThreadPoolManager.scheduleAtFixedRate(new Delete(), 10000, 1000);
cleanTask = ThreadPoolManager.schedule(new Clean(), 420000);
}
}
@@ -128,7 +128,7 @@ public final class DenOfEvil extends AbstractNpcAI
zone.addSkill(skillId, skillLevel + 1);
if (skillLevel == 3) // 3+1=4
{
ThreadPoolManager.getInstance().scheduleAi(new KashaDestruction(zone), 2 * 60 * 1000l);
ThreadPoolManager.schedule(new KashaDestruction(zone), 2 * 60 * 1000l);
zone.broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.KASHA_S_EYE_PITCHES_AND_TOSSES_LIKE_IT_S_ABOUT_TO_EXPLODE));
}
else if (skillLevel == 2)
@@ -141,7 +141,7 @@ public final class DenOfEvil extends AbstractNpcAI
@Override
public String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
ThreadPoolManager.schedule(new RespawnNewEye(npc.getLocation()), 15000);
final L2EffectZone zone = ZoneManager.getInstance().getZone(npc, L2EffectZone.class);
if (zone == null)
{
@@ -216,7 +216,7 @@ public final class DenOfEvil extends AbstractNpcAI
final L2Npc npc = (L2Npc) character;
if (Util.contains(EYE_IDS, npc.getId()))
{
ThreadPoolManager.getInstance().scheduleAi(new RespawnNewEye(npc.getLocation()), 15000);
ThreadPoolManager.schedule(new RespawnNewEye(npc.getLocation()), 15000);
}
}
}
@@ -91,7 +91,7 @@ public final class RandomSpawn extends AbstractNpcAI
if (!npc.isInsideRadius(loc, 200, false, false))
{
npc.getSpawn().setLocation(loc);
ThreadPoolManager.getInstance().scheduleGeneral(new Teleport(npc, loc), 100);
ThreadPoolManager.schedule(new Teleport(npc, loc), 100);
}
return super.onSpawn(npc);
}
@@ -246,7 +246,7 @@ public final class QueenAnt extends AbstractNpcAI
}
case QUEEN:
{
_task = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new QueenAntTask(), 5 * 1000, 5 * 1000);
_task = ThreadPoolManager.scheduleAtFixedRate(new QueenAntTask(), 5 * 1000, 5 * 1000);
break;
}
}
@@ -55,8 +55,8 @@ public class TarBeetleSpawn implements IXmlReader
parseDatapackFile("data/spawnZones/tar_beetle.xml");
if (!zones.isEmpty())
{
spawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> zones.forEach(SpawnZone::refreshSpawn), 1000, 60000);
shotTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> zones.forEach(SpawnZone::refreshShots), 300000, 300000);
spawnTask = ThreadPoolManager.scheduleAtFixedRate(() -> zones.forEach(SpawnZone::refreshSpawn), 1000, 60000);
shotTask = ThreadPoolManager.scheduleAtFixedRate(() -> zones.forEach(SpawnZone::refreshShots), 300000, 300000);
}
}
@@ -110,7 +110,7 @@ public class NpcBufferAI implements Runnable
break;
}
}
ThreadPoolManager.getInstance().scheduleGeneral(this, _skillData.getDelay());
ThreadPoolManager.schedule(this, _skillData.getDelay());
}
/**
@@ -54,7 +54,7 @@ public final class NpcBuffers extends AbstractNpcAI
final NpcBufferData data = _npcBuffers.getNpcBuffer(npc.getId());
for (NpcBufferSkillData skill : data.getSkills())
{
ThreadPoolManager.getInstance().scheduleAi(new NpcBufferAI(npc, skill), skill.getInitialDelay());
ThreadPoolManager.schedule(new NpcBufferAI(npc, skill), skill.getInitialDelay());
}
return super.onSpawn(npc);
}
@@ -76,8 +76,8 @@ public final class CabaleBuffer extends AbstractNpcAI
@Override
public String onSpawn(L2Npc npc)
{
ThreadPoolManager.getInstance().scheduleGeneral(new CabaleAI(npc), 3000);
ThreadPoolManager.getInstance().scheduleGeneral(new Talk(npc), 60000);
ThreadPoolManager.schedule(new CabaleAI(npc), 3000);
ThreadPoolManager.schedule(new Talk(npc), 60000);
return super.onSpawn(npc);
}
@@ -101,7 +101,7 @@ public final class CabaleBuffer extends AbstractNpcAI
messages = PREACHER_MSG;
}
broadcastSay(_npc, messages[getRandom(messages.length)], null, -1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
}
}
}
@@ -224,7 +224,7 @@ public final class CabaleBuffer extends AbstractNpcAI
break;
}
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 3000);
ThreadPoolManager.schedule(this, 3000);
}
/**
@@ -159,7 +159,7 @@ public final class FortressOfTheDead extends ClanHallSiegeEngine
{
cancelSiegeTask();
final long scheduleTime = (24 - hoursLeft) * 10 * 60000;
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeStarts(), scheduleTime);
_siegeTask = ThreadPoolManager.schedule(new SiegeStarts(), scheduleTime);
}
else
{
@@ -116,7 +116,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
}
if (_acceptedClans.size() >= 2)
{
_nextSiege = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeStart(), 3600000);
_nextSiege = ThreadPoolManager.schedule(new SiegeStart(), 3600000);
_rainbow.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
}
else
@@ -140,7 +140,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
// XXX _rainbow.siegeStarts();
spawnGourds();
_siegeEnd = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeEnd(null), _rainbow.getSiegeLenght() - 120000);
_siegeEnd = ThreadPoolManager.schedule(new SiegeEnd(null), _rainbow.getSiegeLenght() - 120000);
}
}
@@ -178,10 +178,10 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
// XXX _rainbow.siegeEnds();
ThreadPoolManager.getInstance().scheduleGeneral(new SetFinalAttackers(), _rainbow.getNextSiegeTime());
ThreadPoolManager.schedule(new SetFinalAttackers(), _rainbow.getNextSiegeTime());
setRegistrationEndString((_rainbow.getNextSiegeTime() + System.currentTimeMillis()) - 3600000);
// Teleport out of the arenas is made 2 mins after game ends
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportBack(), 120000);
ThreadPoolManager.schedule(new TeleportBack(), 120000);
}
}
@@ -287,7 +287,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
if (delay > -1)
{
setRegistrationEndString(delay - 3600000);
_nextSiege = ThreadPoolManager.getInstance().scheduleGeneral(new SetFinalAttackers(), delay);
_nextSiege = ThreadPoolManager.schedule(new SetFinalAttackers(), delay);
}
else
{
@@ -616,7 +616,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
{
_siegeEnd.cancel(false);
}
ThreadPoolManager.getInstance().executeGeneral(new SiegeEnd(clan));
ThreadPoolManager.execute(new SiegeEnd(clan));
}
}
@@ -896,7 +896,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
public static void launchSiege()
{
_nextSiege.cancel(false);
ThreadPoolManager.getInstance().executeGeneral(new SiegeStart());
ThreadPoolManager.execute(new SiegeStart());
}
@Override
@@ -906,7 +906,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
{
_siegeEnd.cancel(false);
}
ThreadPoolManager.getInstance().executeGeneral(new SiegeEnd(null));
ThreadPoolManager.execute(new SiegeEnd(null));
}
public static void updateAdminDate(long date)
@@ -923,7 +923,7 @@ public final class RainbowSpringsChateau extends ClanHallSiegeEngine
}
date -= 3600000;
setRegistrationEndString(date);
_nextSiege = ThreadPoolManager.getInstance().scheduleGeneral(new SetFinalAttackers(), _rainbow.getNextSiegeTime());
_nextSiege = ThreadPoolManager.schedule(new SetFinalAttackers(), _rainbow.getNextSiegeTime());
}
public static void main(String[] args)
@@ -402,7 +402,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
doUnSpawns(data);
}
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
for (int doorId : INNER_DOORS_TO_OPEN)
{
@@ -457,7 +457,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
Broadcast.toAllOnlinePlayers(msg);
_hall.updateSiegeStatus(SiegeStatus.WAITING_BATTLE);
_siegeTask = ThreadPoolManager.getInstance().scheduleGeneral(new SiegeStarts(), 3600000);
_siegeTask = ThreadPoolManager.schedule(new SiegeStarts(), 3600000);
}
@Override
@@ -499,7 +499,7 @@ public abstract class FlagWar extends ClanHallSiegeEngine
}
// Schedule open doors closement and siege start in 2 minutes
ThreadPoolManager.getInstance().scheduleGeneral(new CloseOutterDoorsTask(this), 300000);
ThreadPoolManager.schedule(new CloseOutterDoorsTask(this), 300000);
}
/**
@@ -111,7 +111,7 @@ public final class Elpies extends Event
Broadcast.toAllOnlinePlayers("Help us exterminate them!");
Broadcast.toAllOnlinePlayers("You have " + EVENT_DURATION_MINUTES + " minutes!");
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_eventTask = ThreadPoolManager.schedule(() ->
{
Broadcast.toAllOnlinePlayers("Time is up!");
eventStop();
@@ -137,7 +137,7 @@ public final class Race extends Event
Broadcast.toAllOnlinePlayers("Visit Event Manager in Dion village and signup, you have " + _time_register + " min before Race Start...");
// Schedule Event end
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> StartRace(), _time_register * 60 * 1000);
_eventTask = ThreadPoolManager.schedule(() -> StartRace(), _time_register * 60 * 1000);
return true;
@@ -180,7 +180,7 @@ public final class Race extends Event
}
}
// Schedule timeup for Race
_eventTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> timeUp(), _time_race * 60 * 1000);
_eventTask = ThreadPoolManager.schedule(() -> timeUp(), _time_race * 60 * 1000);
}
@Override
@@ -943,7 +943,7 @@ public class EnergySeeds extends AbstractNpcAI
public void scheduleRespawn(long waitTime)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
// if the AI is inactive, do not spawn the NPC
if (isSeedActive(_seedId))
@@ -561,8 +561,8 @@ public class HallOfErosionAttack extends AbstractNpcAI
npc.deleteMe();
world.deadTumor = addSpawn(TUMOR_DEAD, loc, world.getInstanceId());
world.deadTumors.add(world.deadTumor);
ThreadPoolManager.getInstance().scheduleGeneral(new TumorRevival(world.deadTumor, world), tumorRespawnTime);
ThreadPoolManager.getInstance().scheduleGeneral(new RegenerationCoffinSpawn(world.deadTumor, world), 20000);
ThreadPoolManager.schedule(new TumorRevival(world.deadTumor, world), tumorRespawnTime);
ThreadPoolManager.schedule(new RegenerationCoffinSpawn(world.deadTumor, world), 20000);
if (world.tumorCount >= 1)
{
broadCastPacket(world, new ExShowScreenMessage(NpcStringId.THE_TUMOR_INSIDE_S1_HAS_BEEN_DESTROYED_NIN_ORDER_TO_DRAW_OUT_THE_COWARDLY_COHEMENES_YOU_MUST_DESTROY_ALL_THE_TUMORS, 2, 8000));
@@ -358,7 +358,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
world.addAllowed(player.getObjectId());
}
((HEDWorld) world).finishTask = ThreadPoolManager.getInstance().scheduleGeneral(new FinishTask((HEDWorld) world), 20 * 60000);
((HEDWorld) world).finishTask = ThreadPoolManager.schedule(new FinishTask((HEDWorld) world), 20 * 60000);
runTumors((HEDWorld) world);
}
}
@@ -391,7 +391,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
{
final L2Npc npc = addSpawn(spawn[0], spawn[1], spawn[2], spawn[3], spawn[4], false, 0, false, world.getInstanceId());
world.deadTumors.add(npc);
ThreadPoolManager.getInstance().scheduleGeneral(new RegenerationCoffinSpawn(npc, world), 1000);
ThreadPoolManager.schedule(new RegenerationCoffinSpawn(npc, world), 1000);
}
}
@@ -403,7 +403,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
}
}
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (!conquestEnded)
{
@@ -544,7 +544,7 @@ public class HallOfErosionDefence extends AbstractNpcAI
world.deadTumor = addSpawn(TUMOR_DEAD, npc.getLocation(), world.getInstanceId());
world.deadTumors.add(world.deadTumor);
broadCastPacket(world, new ExShowScreenMessage(NpcStringId.THE_TUMOR_INSIDE_S1_HAS_BEEN_DESTROYED_NTHE_NEARBY_UNDEAD_THAT_WERE_ATTACKING_SEED_OF_LIFE_START_LOSING_THEIR_ENERGY_AND_RUN_AWAY, 2, 8000));
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
world.deadTumor.deleteMe();
final L2Npc tumor = addSpawn(TUMOR_ALIVE, world.deadTumor.getLocation(), world.getInstanceId());
@@ -358,7 +358,7 @@ public class HeartInfinityAttack extends Quest
}
conquestBegun = true;
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
for (int objId : world.getAllowed())
{
@@ -366,7 +366,7 @@ public class HeartInfinityAttack extends Quest
player.showQuestMovie(2); // ExStartScenePlayer.SCENE_ECHMUS_OPENING
}
ThreadPoolManager.getInstance().scheduleGeneral(() -> conquestBegins(world), 62500);
ThreadPoolManager.schedule(() -> conquestBegins(world), 62500);
}, 20000);
}
@@ -420,7 +420,7 @@ public class HeartInfinityAttack extends Quest
world.hounds.add(addSpawn(HOUND, -179224, 209624, -15504, 16384, false, 0, false, world.getInstanceId()));
world.hounds.add(addSpawn(HOUND, -179880, 209464, -15504, 16384, false, 0, false, world.getInstanceId()));
world.startTime = System.currentTimeMillis();
world.timerTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TimerTask(world), 298 * 1000, 5 * 60 * 1000);
world.timerTask = ThreadPoolManager.scheduleAtFixedRate(new TimerTask(world), 298 * 1000, 5 * 60 * 1000);
}
@Override
@@ -607,8 +607,8 @@ public class HeartInfinityAttack extends Quest
npc.deleteMe();
world.deadTumor = addSpawn(DEADTUMOR, loc, world.getInstanceId());
world.deadTumors.add(world.deadTumor);
ThreadPoolManager.getInstance().scheduleGeneral(new TumorRevival(world.deadTumor, world), tumorRespawnTime);
ThreadPoolManager.getInstance().scheduleGeneral(new RegenerationCoffinSpawn(world.deadTumor, world), 20000);
ThreadPoolManager.schedule(new TumorRevival(world.deadTumor, world), tumorRespawnTime);
ThreadPoolManager.schedule(new RegenerationCoffinSpawn(world.deadTumor, world), 20000);
if (world.tumorCount < 1)
{
houndBlocked = true;
@@ -825,7 +825,7 @@ public class HeartInfinityAttack extends Quest
}
}
ThreadPoolManager.getInstance().scheduleGeneral(() -> broadCastPacket(world, new ExShowScreenMessage(NpcStringId.EKIMUS_HAS_SENSED_ABNORMAL_ACTIVITY_NTHE_ADVANCING_PARTY_IS_FORCEFULLY_EXPELLED, 2, 8000)), 10000);
ThreadPoolManager.schedule(() -> broadCastPacket(world, new ExShowScreenMessage(NpcStringId.EKIMUS_HAS_SENSED_ABNORMAL_ACTIVITY_NTHE_ADVANCING_PARTY_IS_FORCEFULLY_EXPELLED, 2, 8000)), 10000);
}
protected void conquestConclusion(HIAWorld world)
@@ -365,15 +365,15 @@ public class HeartInfinityDefence extends Quest
}
}
((HIDWorld) world).startTime = System.currentTimeMillis();
((HIDWorld) world).finishTask = ThreadPoolManager.getInstance().scheduleGeneral(new FinishTask((HIDWorld) world), 30 * 60000);
((HIDWorld) world).timerTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new TimerTask((HIDWorld) world), 298 * 1000, 5 * 60 * 1000);
((HIDWorld) world).finishTask = ThreadPoolManager.schedule(new FinishTask((HIDWorld) world), 30 * 60000);
((HIDWorld) world).timerTask = ThreadPoolManager.scheduleAtFixedRate(new TimerTask((HIDWorld) world), 298 * 1000, 5 * 60 * 1000);
conquestBegins((HIDWorld) world);
}
}
private void conquestBegins(HIDWorld world)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
broadCastPacket(world, new ExShowScreenMessage(NpcStringId.YOU_CAN_HEAR_THE_UNDEAD_OF_EKIMUS_RUSHING_TOWARD_YOU_S1_S2_IT_HAS_NOW_BEGUN, 2, 8000));
for (int[] spawn1 : ROOMS_MOBS)
@@ -406,7 +406,7 @@ public class HeartInfinityDefence extends Quest
InstanceManager.getInstance().getInstance(world.getInstanceId()).getDoor(14240102).openMe();
preawakenedEchmus = addSpawn(29161, -179534, 208510, -15496, 16342, false, 0, false, world.getInstanceId());
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (!conquestEnded)
{
@@ -423,7 +423,7 @@ public class HeartInfinityDefence extends Quest
}
}, 60000);
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (!conquestEnded)
{
@@ -452,7 +452,7 @@ public class HeartInfinityDefence extends Quest
}
}, tumorRespawnTime);
world.wagonSpawnTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() -> addSpawn(SOULWAGON, -179544, 207400, -15496, 0, false, 0, false, world.getInstanceId()), 1000, wagonRespawnTime);
world.wagonSpawnTask = ThreadPoolManager.scheduleAtFixedRate(() -> addSpawn(SOULWAGON, -179544, 207400, -15496, 0, false, 0, false, world.getInstanceId()), 1000, wagonRespawnTime);
}, 20000);
}
@@ -593,7 +593,7 @@ public class HeartInfinityDefence extends Quest
wagonRespawnTime += 10000;
broadCastPacket(world, new ExShowScreenMessage(NpcStringId.THE_TUMOR_INSIDE_S1_HAS_BEEN_DESTROYED_NTHE_SPEED_THAT_EKIMUS_CALLS_OUT_HIS_PREY_HAS_SLOWED_DOWN, 2, 8000));
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
world.deadTumor.deleteMe();
final L2Npc alivetumor = addSpawn(ALIVETUMOR, loc, world.getInstanceId());
@@ -307,11 +307,11 @@ public abstract class AirShipController extends Quest
}
}
ThreadPoolManager.getInstance().scheduleGeneral(_decayTask, 1000);
ThreadPoolManager.schedule(_decayTask, 1000);
}
else
{
_departSchedule = ThreadPoolManager.getInstance().scheduleGeneral(_departTask, DEPART_INTERVAL);
_departSchedule = ThreadPoolManager.schedule(_departTask, DEPART_INTERVAL);
}
}
}
@@ -252,7 +252,7 @@ public final class AirShipGludioGracia extends Quest implements Runnable
case 1:
// _ship.teleToLocation(-167874, 256731, -509, 41035, false);
_ship.setOustLoc(OUST_GRACIA);
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
break;
case 2:
_ship.executePath(WARPGATE_TO_GRACIA);
@@ -261,7 +261,7 @@ public final class AirShipGludioGracia extends Quest implements Runnable
broadcastInGracia(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_HAS_ARRIVED_IT_WILL_DEPART_FOR_THE_ADEN_CONTINENT_IN_1_MINUTE);
_ship.setInDock(GRACIA_DOCK_ID);
_ship.oustPlayers();
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
case 4:
broadcastInGracia(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_THAT_FLIES_TO_THE_ADEN_CONTINENT_HAS_DEPARTED);
@@ -271,7 +271,7 @@ public final class AirShipGludioGracia extends Quest implements Runnable
case 5:
// _ship.teleToLocation(-157261, 255664, 221, 64781, false);
_ship.setOustLoc(OUST_GLUDIO);
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
break;
case 6:
_ship.executePath(WARPGATE_TO_GLUDIO);
@@ -280,7 +280,7 @@ public final class AirShipGludioGracia extends Quest implements Runnable
broadcastInGludio(NpcStringId.THE_REGULARLY_SCHEDULED_AIRSHIP_HAS_ARRIVED_IT_WILL_DEPART_FOR_THE_GRACIA_CONTINENT_IN_1_MINUTE);
_ship.setInDock(GLUDIO_DOCK_ID);
_ship.oustPlayers();
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
}
_cycle++;
@@ -385,7 +385,7 @@ public class AdminEditChar implements IAdminCommandHandler
if ((race != player.getRace()) || (((race == Race.HUMAN) || (race == Race.ORC)) && (isMage != player.isMageClass())))
{
TransformData.getInstance().transformPlayer(105, player);
ThreadPoolManager.getInstance().scheduleGeneral(new Untransform(player), 200);
ThreadPoolManager.schedule(new Untransform(player), 200);
}
}
else
@@ -493,7 +493,7 @@ public class AdminEditChar implements IAdminCommandHandler
player.broadcastUserInfo();
// Transform-untransorm player quickly to force the client to reload the character textures
TransformData.getInstance().transformPlayer(105, player);
ThreadPoolManager.getInstance().scheduleGeneral(new Untransform(player), 200);
ThreadPoolManager.schedule(new Untransform(player), 200);
}
else if (command.startsWith("admin_setcolor"))
@@ -109,7 +109,7 @@ public class AdminMonsterRace implements IAdminCommandHandler
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
ThreadPoolManager.schedule(new RunRace(codes, activeChar), 5000);
}
}
@@ -139,7 +139,7 @@ public class AdminMonsterRace implements IAdminCommandHandler
final MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
activeChar.sendPacket(spk);
activeChar.broadcastPacket(spk);
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
ThreadPoolManager.schedule(new RunEnd(activeChar), 30000);
}
}
@@ -553,7 +553,7 @@ public final class AdminPForge implements IAdminCommandHandler
p.setBuffers(bb, activeChar.getClient(), new NioNetStringBuffer(2000));
if (p.read())
{
ThreadPoolManager.getInstance().executePacket(p);
ThreadPoolManager.execute(p);
}
}
}
@@ -20,15 +20,14 @@ import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameServer;
import com.l2jmobius.gameserver.GameTimeController;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
@@ -71,14 +70,6 @@ public class AdminServerInfo implements IAdminCommandHandler
html.replace("%usedMem%", (RunTime.maxMemory() / mb) - (((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb));
html.replace("%freeMem%", ((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb);
html.replace("%totalMem%", Runtime.getRuntime().maxMemory() / 1048576);
html.replace("%theardInfoGen%", buildTheardInfo("GENERAL"));
html.replace("%theardInfoEff%", buildTheardInfo("EFFECTS"));
html.replace("%theardInfoAi%", buildTheardInfo("AI"));
html.replace("%theardInfoEvent%", buildTheardInfo("EVENT"));
html.replace("%theardInfoPack%", buildTheardInfo("PACKETS"));
html.replace("%theardInfoIOPack%", buildTheardInfo("IOPACKETS"));
html.replace("%theardInfoGenTask%", buildTheardInfo("GENERAL_TASKS"));
html.replace("%theardInfoEvnTask%", buildTheardInfo("EVENT_TASKS"));
activeChar.sendPacket(html);
}
return true;
@@ -92,25 +83,7 @@ public class AdminServerInfo implements IAdminCommandHandler
time -= TimeUnit.DAYS.toMillis(days);
final long hours = TimeUnit.MILLISECONDS.toHours(time);
time -= TimeUnit.HOURS.toMillis(hours);
final long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
return days + " Days, " + hours + " Hours, " + minutes + " Minutes";
}
private String buildTheardInfo(String category)
{
final StringBuilder tb = new StringBuilder();
tb.append("<table width=\"270\" border=\"0\" bgcolor=\"444444\">");
for (Entry<String, Object> info : ThreadPoolManager.getInstance().getStats(category).getSet().entrySet())
{
tb.append("<tr>");
tb.append("<td>" + info.getKey() + ":</td>");
tb.append("<td><font color=\"00FF00\">" + info.getValue() + "</font></td>");
tb.append("</tr>");
}
tb.append("</table>");
return tb.toString();
return days + " Days, " + hours + " Hours, " + TimeUnit.MILLISECONDS.toMinutes(time) + " Minutes";
}
private int getPlayersCount(String type)
@@ -119,7 +92,7 @@ public class AdminServerInfo implements IAdminCommandHandler
{
case "ALL":
{
return L2World.getInstance().getAllPlayersCount();
return L2World.getInstance().getPlayers().size();
}
case "OFF_TRADE":
{
@@ -138,7 +111,7 @@ public class AdminServerInfo implements IAdminCommandHandler
case "GM":
{
int onlineGMcount = 0;
for (L2PcInstance gm : L2World.getInstance().getAllGMs())
for (L2PcInstance gm : AdminData.getInstance().getAllGms(true))
{
if ((gm != null) && gm.isOnline() && (gm.getClient() != null) && !gm.getClient().isDetached())
{
@@ -153,7 +126,7 @@ public class AdminServerInfo implements IAdminCommandHandler
for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
{
if (((onlinePlayer != null) && (onlinePlayer.getClient() != null)) && !onlinePlayer.getClient().isDetached())
if ((onlinePlayer != null) && (onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached())
{
realPlayers.add(onlinePlayer.getIPAddress());
}
@@ -46,7 +46,7 @@ public class AdminTest implements IAdminCommandHandler
{
if (command.equals("admin_stats"))
{
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
activeChar.sendMessage(line);
}
@@ -74,7 +74,7 @@ public final class ServitorShare extends AbstractEffect
final L2Character effected = info.getEffected().isPlayer() ? info.getEffected().getSummon() : info.getEffected().getActingPlayer();
if (effected != null)
{
ThreadPoolManager.getInstance().scheduleEffect(new ScheduledEffectExitTask(effected, info.getSkill().getId()), 100);
ThreadPoolManager.schedule(new ScheduledEffectExitTask(effected, info.getSkill().getId()), 100);
}
}
}
@@ -168,7 +168,7 @@ public class JailHandler implements IPunishmentHandler
OlympiadManager.getInstance().removeDisconnectedCompetitor(player);
}
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationIn()), 2000);
ThreadPoolManager.schedule(new TeleportTask(player, L2JailZone.getLocationIn()), 2000);
// Open a Html message to inform the player
final NpcHtmlMessage msg = new NpcHtmlMessage();
@@ -204,7 +204,7 @@ public class JailHandler implements IPunishmentHandler
*/
private static void removeFromPlayer(L2PcInstance player)
{
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationOut()), 2000);
ThreadPoolManager.schedule(new TeleportTask(player, L2JailZone.getLocationOut()), 2000);
// Open a Html message to inform the player
final NpcHtmlMessage msg = new NpcHtmlMessage();
@@ -109,54 +109,6 @@ public class DebugHandler implements ITelnetHandler
targetPlayer.sendPacket(sp);
_print.println("Packet sent to player " + charName);
}
else if (dbg.equals("PacketTP"))
{
final String str = ThreadPoolManager.getInstance().getPacketStats();
_print.println(str);
int i = 0;
File f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-PacketTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos, "UTF-8");
out.write(str);
}
else if (dbg.equals("IOPacketTP"))
{
final String str = ThreadPoolManager.getInstance().getIOPacketStats();
_print.println(str);
int i = 0;
File f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-IOPacketTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos, "UTF-8");
out.write(str);
}
else if (dbg.equals("GeneralTP"))
{
final String str = ThreadPoolManager.getInstance().getGeneralStats();
_print.println(str);
int i = 0;
File f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
while (f.exists())
{
i++;
f = new File("./log/StackTrace-GeneralTP-" + i + ".txt");
}
f.getParentFile().mkdirs();
fos = new FileOutputStream(f);
out = new OutputStreamWriter(fos, "UTF-8");
out.write(str);
}
else if (dbg.equals("full"))
{
final Calendar cal = Calendar.getInstance();
@@ -248,7 +200,7 @@ public class DebugHandler implements ITelnetHandler
}
sb.append("\n\n## Thread Pool Manager Statistics ##\n");
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
sb.append(line);
sb.append('\n');
@@ -38,7 +38,7 @@ public class ThreadHandler implements ITelnetHandler
{
if (command.equals("performance"))
{
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
_print.println(line);
}
@@ -46,10 +46,10 @@ public class ThreadHandler implements ITelnetHandler
}
else if (command.equals("purge"))
{
ThreadPoolManager.getInstance().purge();
ThreadPoolManager.purge();
_print.println("STATUS OF THREAD POOLS AFTER PURGE COMMAND:");
_print.println("");
for (String line : ThreadPoolManager.getInstance().getStats())
for (String line : ThreadPoolManager.getStats())
{
_print.println(line);
}
@@ -111,7 +111,7 @@ public class Unstuck implements IUserCommandHandler
// End SoE Animation section
// continue execution later
activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(new EscapeFinalizer(activeChar), unstuckTimer));
activeChar.setSkillCast(ThreadPoolManager.schedule(new EscapeFinalizer(activeChar), unstuckTimer));
return true;
}
@@ -472,7 +472,7 @@ public class Wedding implements IVoicedCommandHandler
final EscapeFinalizer ef = new EscapeFinalizer(activeChar, partner.getLocation(), partner.isIn7sDungeon());
// continue execution later
activeChar.setSkillCast(ThreadPoolManager.getInstance().scheduleGeneral(ef, teleportTimer));
activeChar.setSkillCast(ThreadPoolManager.schedule(ef, teleportTimer));
activeChar.forceIsCasting(GameTimeController.getInstance().getGameTicks() + (teleportTimer / GameTimeController.MILLIS_IN_TICK));
return true;
@@ -76,7 +76,7 @@ public final class Chimeras extends AbstractNpcAI
if (!npc.isInsideRadius(loc, 200, false, false))
{
npc.getSpawn().setLocation(loc);
ThreadPoolManager.getInstance().scheduleGeneral(new Teleport(npc, loc), 100);
ThreadPoolManager.schedule(new Teleport(npc, loc), 100);
}
}
return super.onSpawn(npc);
@@ -557,7 +557,7 @@ public final class TowerOfNaia extends AbstractNpcAI
{
removeForeigners(npcId, party);
startRoom(npcId);
ThreadPoolManager.getInstance().scheduleGeneral(new StopRoomTask(npcId), 300000);
ThreadPoolManager.schedule(new StopRoomTask(npcId), 300000);
}
else
{
@@ -847,7 +847,7 @@ public final class TowerOfNaia extends AbstractNpcAI
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(() -> addSpawn(MUTATED_ELPY, -45474, 247450, -13994, 49152, false, 0, false), respawnTime - System.currentTimeMillis());
ThreadPoolManager.schedule(() -> addSpawn(MUTATED_ELPY, -45474, 247450, -13994, 49152, false, 0, false), respawnTime - System.currentTimeMillis());
}
}
@@ -1207,7 +1207,7 @@ public final class TullyWorkshop extends AbstractNpcAI
DoorData.getInstance().getDoor(19260052).openMe();
countdownTime = 600000;
_countdown = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
_countdown = ThreadPoolManager.scheduleAtFixedRate(() ->
{
countdownTime -= 10000;
L2Npc _npc = null;
@@ -1570,20 +1570,20 @@ public final class TullyWorkshop extends AbstractNpcAI
{
DoorData.getInstance().getDoor(20250005).openMe();
DoorData.getInstance().getDoor(20250004).openMe();
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250006,
20250007
}, STATE_OPEN), 2000);
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250778
}, STATE_CLOSE), 3000);
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250777
}, STATE_CLOSE), 6000);
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250009,
20250008
@@ -1594,12 +1594,12 @@ public final class TullyWorkshop extends AbstractNpcAI
{
DoorData.getInstance().getDoor(20250009).closeMe();
DoorData.getInstance().getDoor(20250008).closeMe();
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250777,
20250778
}, STATE_OPEN), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new DoorTask(new int[]
ThreadPoolManager.schedule(new DoorTask(new int[]
{
20250005,
20250004,
@@ -167,7 +167,7 @@ public final class UrbanArea extends AbstractInstance
final Instance inst = InstanceManager.getInstance().getInstance(world.getInstanceId());
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
ThreadPoolManager.getInstance().scheduleGeneral(new ExitInstance(party, world), 285000);
ThreadPoolManager.schedule(new ExitInstance(party, world), 285000);
htmltext = "32343-02d.htm";
}
}
@@ -221,7 +221,7 @@ public final class UrbanArea extends AbstractInstance
world.activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPoolManager.getInstance().scheduleGeneral(new CallAmaskari(npc), 25000);
world.activeAmaskariCall = ThreadPoolManager.schedule(new CallAmaskari(npc), 25000);
}
}
}
@@ -267,7 +267,7 @@ public final class UrbanArea extends AbstractInstance
{
world.activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPoolManager.getInstance().scheduleGeneral(new CallAmaskari(npc), 25000);
world.activeAmaskariCall = ThreadPoolManager.schedule(new CallAmaskari(npc), 25000);
}
}
}
@@ -313,7 +313,7 @@ public final class UrbanArea extends AbstractInstance
{
world.activeAmaskariCall.cancel(true);
}
world.activeAmaskariCall = ThreadPoolManager.getInstance().scheduleGeneral(new CallAmaskari(npc), 25000);
world.activeAmaskariCall = ThreadPoolManager.schedule(new CallAmaskari(npc), 25000);
}
}
}
@@ -62,7 +62,7 @@ public abstract class Chamber extends AbstractInstance
{
currentRoom = 0;
partyInside = party;
_banishTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new BanishTask(), 60000, 60000);
_banishTask = ThreadPoolManager.scheduleAtFixedRate(new BanishTask(), 60000, 60000);
}
protected L2Party getPartyInside()
@@ -78,7 +78,7 @@ public abstract class Chamber extends AbstractInstance
// Schedule next room change only if remaining time is enough
if ((inst.getInstanceEndTime() - System.currentTimeMillis()) > nextInterval)
{
_roomChangeTask = ThreadPoolManager.getInstance().scheduleGeneral(new ChangeRoomTask(), nextInterval - 5000);
_roomChangeTask = ThreadPoolManager.schedule(new ChangeRoomTask(), nextInterval - 5000);
}
}
@@ -619,7 +619,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
{
openDoor(doorId, world.getInstanceId());
}
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(world, 0), 600000);
ThreadPoolManager.schedule(new IntroTask(world, 0), 600000);
break;
case 3: // first morph
if (world.songEffectTask != null)
@@ -634,7 +634,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
}
handleReenterTime(world);
world.activeScarlet.doCast(FIRST_MORPH_SKILL.getSkill());
ThreadPoolManager.getInstance().scheduleGeneral(new SongTask(world, 2), 1500);
ThreadPoolManager.schedule(new SongTask(world, 2), 1500);
break;
case 4: // second morph
world.isVideo = true;
@@ -644,8 +644,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
world.songEffectTask.cancel(false);
}
world.songEffectTask = null;
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(world, 23), 2000);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(world, 24), 2100);
ThreadPoolManager.schedule(new IntroTask(world, 23), 2000);
ThreadPoolManager.schedule(new IntroTask(world, 24), 2100);
break;
case 5: // raid success
world.isVideo = true;
@@ -660,7 +660,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
}
world.songTask = null;
world.songEffectTask = null;
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(world, 33), 500);
ThreadPoolManager.schedule(new IntroTask(world, 33), 500);
break;
case 6: // open doors
InstanceManager.getInstance().getInstance(world.getInstanceId()).setDuration(300000);
@@ -745,7 +745,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
updateKnownList(_world, demon);
_world.demons.add(demon);
}
ThreadPoolManager.getInstance().scheduleGeneral(new DemonSpawnTask(_world), TIME_BETWEEN_DEMON_SPAWNS);
ThreadPoolManager.schedule(new DemonSpawnTask(_world), TIME_BETWEEN_DEMON_SPAWNS);
}
}
@@ -788,7 +788,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
case 0: // new song play
if (_world.isVideo)
{
_world.songTask = ThreadPoolManager.getInstance().scheduleGeneral(new SongTask(_world, 0), 1000);
_world.songTask = ThreadPoolManager.schedule(new SongTask(_world, 0), 1000);
}
else if ((_world.frintezza != null) && !_world.frintezza.isDead())
{
@@ -802,15 +802,15 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.OnSong = element;
broadCastPacket(_world, new ExShowScreenMessage(2, -1, 2, 0, 0, 0, 0, true, 4000, false, null, element.songName, null));
broadCastPacket(_world, new MagicSkillUse(_world.frintezza, _world.frintezza, element.skill.getSkillId(), element.skill.getSkillLvl(), element.skill.getSkill().getHitTime(), 0));
_world.songEffectTask = ThreadPoolManager.getInstance().scheduleGeneral(new SongTask(_world, 1), element.skill.getSkill().getHitTime() - 10000);
_world.songTask = ThreadPoolManager.getInstance().scheduleGeneral(new SongTask(_world, 0), element.skill.getSkill().getHitTime());
_world.songEffectTask = ThreadPoolManager.schedule(new SongTask(_world, 1), element.skill.getSkill().getHitTime() - 10000);
_world.songTask = ThreadPoolManager.schedule(new SongTask(_world, 0), element.skill.getSkill().getHitTime());
break;
}
}
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new SoulBreakingArrow(_world.frintezza), 35000);
ThreadPoolManager.schedule(new SoulBreakingArrow(_world.frintezza), 35000);
}
}
break;
@@ -878,8 +878,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
switch (_status)
{
case 0:
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 1), 27000);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 2), 30000);
ThreadPoolManager.schedule(new IntroTask(_world, 1), 27000);
ThreadPoolManager.schedule(new IntroTask(_world, 2), 30000);
broadCastPacket(_world, new Earthquake(-87784, -155083, -9087, 45, 27));
break;
case 1:
@@ -924,7 +924,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.scarletDummy.setIsImmobilized(true);
stopPc();
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 3), 1000);
ThreadPoolManager.schedule(new IntroTask(_world, 3), 1000);
break;
case 3:
broadCastPacket(_world, new SpecialCamera(_world.overheadDummy, 0, 75, -89, 0, 100, 0, 0, 1, 0, 0));
@@ -945,41 +945,41 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
updateKnownList(_world, demon);
_world.demons.add(demon);
}
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 4), 6500);
ThreadPoolManager.schedule(new IntroTask(_world, 4), 6500);
break;
case 4:
broadCastPacket(_world, new SpecialCamera(_world.frintezzaDummy, 1800, 90, 8, 6500, 7000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 5), 900);
ThreadPoolManager.schedule(new IntroTask(_world, 5), 900);
break;
case 5:
broadCastPacket(_world, new SpecialCamera(_world.frintezzaDummy, 140, 90, 10, 2500, 4500, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 6), 4000);
ThreadPoolManager.schedule(new IntroTask(_world, 6), 4000);
break;
case 6:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 40, 75, -10, 0, 1000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 40, 75, -10, 0, 12000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 7), 1350);
ThreadPoolManager.schedule(new IntroTask(_world, 7), 1350);
break;
case 7:
broadCastPacket(_world, new SocialAction(_world.frintezza.getObjectId(), 2));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 8), 7000);
ThreadPoolManager.schedule(new IntroTask(_world, 8), 7000);
break;
case 8:
_world.frintezzaDummy.deleteMe();
_world.frintezzaDummy = null;
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 9), 1000);
ThreadPoolManager.schedule(new IntroTask(_world, 9), 1000);
break;
case 9:
broadCastPacket(_world, new SocialAction(_world.demons.get(1).getObjectId(), 1));
broadCastPacket(_world, new SocialAction(_world.demons.get(2).getObjectId(), 1));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 10), 400);
ThreadPoolManager.schedule(new IntroTask(_world, 10), 400);
break;
case 10:
broadCastPacket(_world, new SocialAction(_world.demons.get(0).getObjectId(), 1));
broadCastPacket(_world, new SocialAction(_world.demons.get(3).getObjectId(), 1));
sendPacketX(new SpecialCamera(_world.portraitDummy1, 1000, 118, 0, 0, 1000, 0, 0, 1, 0, 0), new SpecialCamera(_world.portraitDummy3, 1000, 62, 0, 0, 1000, 0, 0, 1, 0, 0), -87784);
sendPacketX(new SpecialCamera(_world.portraitDummy1, 1000, 118, 0, 0, 10000, 0, 0, 1, 0, 0), new SpecialCamera(_world.portraitDummy3, 1000, 62, 0, 0, 10000, 0, 0, 1, 0, 0), -87784);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 11), 2000);
ThreadPoolManager.schedule(new IntroTask(_world, 11), 2000);
break;
case 11:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 240, 90, 0, 0, 1000, 0, 0, 1, 0, 0));
@@ -989,36 +989,36 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.portraitDummy3.deleteMe();
_world.portraitDummy1 = null;
_world.portraitDummy3 = null;
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 12), 4500);
ThreadPoolManager.schedule(new IntroTask(_world, 12), 4500);
break;
case 12:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 100, 195, 35, 0, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 13), 700);
ThreadPoolManager.schedule(new IntroTask(_world, 13), 700);
break;
case 13:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 100, 195, 35, 0, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 14), 1300);
ThreadPoolManager.schedule(new IntroTask(_world, 14), 1300);
break;
case 14:
broadCastPacket(_world, new ExShowScreenMessage(NpcStringId.MOURNFUL_CHORALE_PRELUDE, 2, 5000));
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 120, 180, 45, 1500, 10000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new MagicSkillUse(_world.frintezza, _world.frintezza, 5006, 1, 34000, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 15), 1500);
ThreadPoolManager.schedule(new IntroTask(_world, 15), 1500);
break;
case 15:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 520, 135, 45, 8000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 16), 7500);
ThreadPoolManager.schedule(new IntroTask(_world, 16), 7500);
break;
case 16:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 1500, 110, 25, 10000, 13000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 17), 9500);
ThreadPoolManager.schedule(new IntroTask(_world, 17), 9500);
break;
case 17:
broadCastPacket(_world, new SpecialCamera(_world.overheadDummy, 930, 160, -20, 0, 1000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new SpecialCamera(_world.overheadDummy, 600, 180, -25, 0, 10000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new MagicSkillUse(_world.scarletDummy, _world.overheadDummy, 5004, 1, 5800, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 18), 5000);
ThreadPoolManager.schedule(new IntroTask(_world, 18), 5000);
break;
case 18:
_world.activeScarlet = (L2GrandBossInstance) addSpawn(29046, -87789, -153295, -9176, 16384, false, 0, false, _world.getInstanceId());
@@ -1029,16 +1029,16 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
updateKnownList(_world, _world.activeScarlet);
broadCastPacket(_world, new SocialAction(_world.activeScarlet.getObjectId(), 3));
broadCastPacket(_world, new SpecialCamera(_world.scarletDummy, 800, 180, 10, 1000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 19), 2100);
ThreadPoolManager.schedule(new IntroTask(_world, 19), 2100);
break;
case 19:
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 300, 60, 8, 0, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 20), 2000);
ThreadPoolManager.schedule(new IntroTask(_world, 20), 2000);
break;
case 20:
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 500, 90, 10, 3000, 5000, 0, 0, 1, 0, 0));
_world.songTask = ThreadPoolManager.getInstance().scheduleGeneral(new SongTask(_world, 0), 100);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 21), 3000);
_world.songTask = ThreadPoolManager.schedule(new SongTask(_world, 0), 100);
ThreadPoolManager.schedule(new IntroTask(_world, 21), 3000);
break;
case 21:
for (int i = 0; i < PORTRAIT_SPAWNS.length; i++)
@@ -1053,7 +1053,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.overheadDummy = null;
_world.scarletDummy = null;
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 22), 2000);
ThreadPoolManager.schedule(new IntroTask(_world, 22), 2000);
break;
case 22:
for (L2MonsterInstance demon : _world.demons)
@@ -1071,7 +1071,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.frintezza.setIsMortal(false);
startPc();
ThreadPoolManager.getInstance().scheduleGeneral(new DemonSpawnTask(_world), TIME_BETWEEN_DEMON_SPAWNS);
ThreadPoolManager.schedule(new DemonSpawnTask(_world), TIME_BETWEEN_DEMON_SPAWNS);
break;
case 23:
broadCastPacket(_world, new SocialAction(_world.frintezza.getObjectId(), 4));
@@ -1085,16 +1085,16 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
_world.activeScarlet.setIsInvul(true);
_world.activeScarlet.setIsImmobilized(true);
_world.activeScarlet.disableAllSkills();
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 25), 7000);
ThreadPoolManager.schedule(new IntroTask(_world, 25), 7000);
break;
case 25:
broadCastPacket(_world, new MagicSkillUse(_world.frintezza, _world.frintezza, 5006, 1, 34000, 0));
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 500, 70, 15, 3000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 26), 3000);
ThreadPoolManager.schedule(new IntroTask(_world, 26), 3000);
break;
case 26:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 2500, 90, 12, 6000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 27), 3000);
ThreadPoolManager.schedule(new IntroTask(_world, 27), 3000);
break;
case 27:
_world.scarlet_x = _world.activeScarlet.getX();
@@ -1111,13 +1111,13 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
}
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 250, _world.scarlet_a, 12, 0, 1000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 250, _world.scarlet_a, 12, 0, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 28), 500);
ThreadPoolManager.schedule(new IntroTask(_world, 28), 500);
break;
case 28:
_world.activeScarlet.doDie(_world.activeScarlet);
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 450, _world.scarlet_a, 14, 8000, 8000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 29), 6250);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 30), 7200);
ThreadPoolManager.schedule(new IntroTask(_world, 29), 6250);
ThreadPoolManager.schedule(new IntroTask(_world, 30), 7200);
break;
case 29:
_world.activeScarlet.deleteMe();
@@ -1132,11 +1132,11 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 450, _world.scarlet_a, 12, 500, 14000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 31), 8100);
ThreadPoolManager.schedule(new IntroTask(_world, 31), 8100);
break;
case 31:
broadCastPacket(_world, new SocialAction(_world.activeScarlet.getObjectId(), 2));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 32), 9000);
ThreadPoolManager.schedule(new IntroTask(_world, 32), 9000);
break;
case 32:
startPc();
@@ -1148,8 +1148,8 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
case 33:
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 300, _world.scarlet_a - 180, 5, 0, 7000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new SpecialCamera(_world.activeScarlet, 200, _world.scarlet_a, 85, 4000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 34), 7400);
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 35), 7500);
ThreadPoolManager.schedule(new IntroTask(_world, 34), 7400);
ThreadPoolManager.schedule(new IntroTask(_world, 35), 7500);
break;
case 34:
_world.frintezza.doDie(_world.frintezza);
@@ -1157,11 +1157,11 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
case 35:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 100, 120, 5, 0, 7000, 0, 0, 1, 0, 0));
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 100, 90, 5, 5000, 15000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 36), 7000);
ThreadPoolManager.schedule(new IntroTask(_world, 36), 7000);
break;
case 36:
broadCastPacket(_world, new SpecialCamera(_world.frintezza, 900, 90, 25, 7000, 10000, 0, 0, 1, 0, 0));
ThreadPoolManager.getInstance().scheduleGeneral(new IntroTask(_world, 37), 9000);
ThreadPoolManager.schedule(new IntroTask(_world, 37), 9000);
break;
case 37:
controlStatus(_world);
@@ -1243,7 +1243,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
switch (_status)
{
case 0:
ThreadPoolManager.getInstance().scheduleGeneral(new StatusTask(_world, 1), 2000);
ThreadPoolManager.schedule(new StatusTask(_world, 1), 2000);
for (int doorId : FIRST_ROOM_DOORS)
{
openDoor(doorId, _world.getInstanceId());
@@ -1253,7 +1253,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
addAggroToMobs();
break;
case 2:
ThreadPoolManager.getInstance().scheduleGeneral(new StatusTask(_world, 3), 100);
ThreadPoolManager.schedule(new StatusTask(_world, 3), 100);
for (int doorId : SECOND_ROOM_DOORS)
{
openDoor(doorId, _world.getInstanceId());
@@ -1386,7 +1386,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
final FETWorld world = (FETWorld) tmpworld;
if (npc.getId() == HALL_ALARM)
{
ThreadPoolManager.getInstance().scheduleGeneral(new StatusTask(world, 0), 2000);
ThreadPoolManager.schedule(new StatusTask(world, 0), 2000);
if (debug)
{
_log.info("[Final Emperial Tomb] Hall alarm is disabled, doors will open!");
@@ -1397,7 +1397,7 @@ public final class FinalEmperialTomb extends AbstractInstance implements IXmlRea
world.darkChoirPlayerCount--;
if (world.darkChoirPlayerCount < 1)
{
ThreadPoolManager.getInstance().scheduleGeneral(new StatusTask(world, 2), 2000);
ThreadPoolManager.schedule(new StatusTask(world, 2), 2000);
if (debug)
{
_log.info("[Final Emperial Tomb] All Dark Choir Players are killed, doors will open!");
@@ -296,7 +296,7 @@ public final class Q00511_AwlUnderFoot extends Quest
dungeon.setReEnterTime(System.currentTimeMillis() + REENTERTIME);
InstanceManager.getInstance().addWorld(world);
_log.info("Fortress AwlUnderFoot started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
ThreadPoolManager.getInstance().scheduleGeneral(new spawnRaid((FAUWorld) world), RAID_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnRaid((FAUWorld) world), RAID_SPAWN_DELAY);
// teleport players
if (player.getParty() == null)
@@ -398,7 +398,7 @@ public final class Q00511_AwlUnderFoot extends Quest
else
{
world.incStatus();
ThreadPoolManager.getInstance().scheduleGeneral(new spawnRaid(world), RAID_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnRaid(world), RAID_SPAWN_DELAY);
}
}
return null;
@@ -286,7 +286,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
world.setStatus(0);
dungeon.setReEnterTime(System.currentTimeMillis() + 14400000);
InstanceManager.getInstance().addWorld(world);
ThreadPoolManager.getInstance().scheduleGeneral(new spawnNpcs((PAWORLD) world), 10000);
ThreadPoolManager.schedule(new spawnNpcs((PAWORLD) world), 10000);
for (L2PcInstance partyMember : party.getMembers())
{
@@ -397,7 +397,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
protected void FirstWave(PAWORLD world)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
addSpawn(SEDUCED_KNIGHT, 49384, -12232, -9384, 0, false, 0, false, world.getInstanceId());
addSpawn(SEDUCED_RANGER, 49192, -12232, -9384, 0, false, 0, false, world.getInstanceId());
@@ -409,7 +409,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
{
addSpawn(KANADIS_FOLLOWER1, 50536, -12232, -9384, 32768, false, 0, false, world.getInstanceId());
}
ThreadPoolManager.getInstance().scheduleGeneral(() -> SecondWave(world), 8 * 60 * 1000);
ThreadPoolManager.schedule(() -> SecondWave(world), 8 * 60 * 1000);
}, 10000);
}
@@ -421,7 +421,7 @@ public class Q00726_LightWithinTheDarkness extends Quest
{
addSpawn(KANADIS_FOLLOWER2, 50536, -12232, -9384, 32768, false, 0, false, world.getInstanceId());
}
ThreadPoolManager.getInstance().scheduleGeneral(() -> ThirdWave(world), 8 * 60 * 1000);
ThreadPoolManager.schedule(() -> ThirdWave(world), 8 * 60 * 1000);
}
protected void ThirdWave(PAWORLD world)
@@ -477,7 +477,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
// Destroy instance after 5 minutes
inst.setDuration(5 * 60000);
inst.setEmptyDestroyTime(0);
ThreadPoolManager.getInstance().scheduleGeneral(new completeDungeon(world, player), 1500);
ThreadPoolManager.schedule(new completeDungeon(world, player), 1500);
}
}
}
@@ -634,7 +634,7 @@ public class Q00727_HopeWithinTheDarkness extends Quest
world.setStatus(0);
dungeon.setReEnterTime(System.currentTimeMillis() + REENTER_INTERVAL);
InstanceManager.getInstance().addWorld(world);
ThreadPoolManager.getInstance().scheduleGeneral(new spawnNpcs((CAUWorld) world), INITIAL_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnNpcs((CAUWorld) world), INITIAL_SPAWN_DELAY);
if (DEBUG)
{
_log.info("Castle HopeWithinTheDarkness started " + template + " Instance: " + instanceId + " created by player: " + player.getName());
@@ -681,21 +681,21 @@ public class Q00727_HopeWithinTheDarkness extends Quest
_instance.spawnGroup("victims");
_instance.spawnGroup("bosses_1");
ThreadPoolManager.getInstance().scheduleGeneral(new spawnNpcs(_world), WAVE_SPAWN_DELAY);
ThreadPoolManager.getInstance().scheduleGeneral(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnNpcs(_world), WAVE_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
}
else if (_world.getStatus() == 1)
{
_instance.spawnGroup("bosses_2");
ThreadPoolManager.getInstance().scheduleGeneral(new spawnNpcs(_world), WAVE_SPAWN_DELAY);
ThreadPoolManager.getInstance().scheduleGeneral(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnNpcs(_world), WAVE_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
}
else if (_world.getStatus() == 2)
{
_instance.spawnGroup("bosses_3");
ThreadPoolManager.getInstance().scheduleGeneral(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
ThreadPoolManager.schedule(new spawnPrivates(_world), PRIVATE_SPAWN_DELAY);
}
}
catch (Exception e)
@@ -166,7 +166,7 @@ public final class Q10292_SevenSignsGirlOfDoubt extends Quest
creature1.setIsNoRndWalk(true);
final L2Npc creature2 = addSpawn(CREATURE_OF_THE_DUSK2, 89524, -238131, -9632, 56, false, 0, false, player.getInstanceId());
creature2.setIsNoRndWalk(true);
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
creature1.deleteMe();
creature2.deleteMe();
@@ -161,30 +161,30 @@ public class BoatGiranTalking implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], LEAVE_GIRAN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], LEAVE_GIRAN1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], LEAVE_GIRAN0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().broadcastPackets(GIRAN_DOCK, TALKING_DOCK[0], LEAVING_GIRAN, ARRIVAL_TALKING15);
_boat.broadcastPacket(GIRAN_SOUND);
_boat.payForRide(3946, 1, 46763, 187041, -3451);
_boat.executePath(GIRAN_TO_TALKING);
ThreadPoolManager.getInstance().scheduleGeneral(this, 250000);
ThreadPoolManager.schedule(this, 250000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, ARRIVAL_TALKING10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, ARRIVAL_TALKING5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, ARRIVAL_TALKING1);
@@ -203,7 +203,7 @@ public class BoatGiranTalking implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(TALKING_DOCK);
@@ -212,19 +212,19 @@ public class BoatGiranTalking implements Runnable
BoatManager.getInstance().dockShip(BoatManager.TALKING_ISLAND, true);
BoatManager.getInstance().broadcastPackets(TALKING_DOCK[0], GIRAN_DOCK, ARRIVED_AT_TALKING, ARRIVED_AT_TALKING_2);
_boat.broadcastPacket(TALKING_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 9:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, LEAVE_TALKING5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 10:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, LEAVE_TALKING1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 11:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GIRAN_DOCK, LEAVE_TALKING0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 12:
BoatManager.getInstance().dockShip(BoatManager.TALKING_ISLAND, false);
@@ -232,23 +232,23 @@ public class BoatGiranTalking implements Runnable
_boat.broadcastPacket(TALKING_SOUND);
_boat.payForRide(3945, 1, -96777, 258970, -3623);
_boat.executePath(TALKING_TO_GIRAN);
ThreadPoolManager.getInstance().scheduleGeneral(this, 200000);
ThreadPoolManager.schedule(this, 200000);
break;
case 13:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], ARRIVAL_GIRAN20);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 14:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], ARRIVAL_GIRAN15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 15:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], ARRIVAL_GIRAN10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 16:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], ARRIVAL_GIRAN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 17:
BoatManager.getInstance().broadcastPacket(GIRAN_DOCK, TALKING_DOCK[0], ARRIVAL_GIRAN1);
@@ -256,7 +256,7 @@ public class BoatGiranTalking implements Runnable
case 18:
BoatManager.getInstance().broadcastPackets(GIRAN_DOCK, TALKING_DOCK[0], ARRIVED_AT_GIRAN, ARRIVED_AT_GIRAN_2);
_boat.broadcastPacket(GIRAN_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_shoutCount = 0;
@@ -176,15 +176,15 @@ public class BoatGludinRune implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], LEAVE_GLUDIN0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, false);
@@ -192,19 +192,19 @@ public class BoatGludinRune implements Runnable
_boat.broadcastPacket(GLUDIN_SOUND);
_boat.payForRide(7905, 1, -90015, 150422, -3610);
_boat.executePath(GLUDIN_TO_RUNE);
ThreadPoolManager.getInstance().scheduleGeneral(this, 250000);
ThreadPoolManager.schedule(this, 250000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 7:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_RUNE1);
@@ -223,7 +223,7 @@ public class BoatGludinRune implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(RUNE_DOCK);
@@ -232,19 +232,19 @@ public class BoatGludinRune implements Runnable
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], GLUDIN_DOCK[0], ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2);
_boat.broadcastPacket(RUNE_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 10:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 11:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 12:
BoatManager.getInstance().broadcastPacket(RUNE_DOCK[0], GLUDIN_DOCK[0], LEAVE_RUNE0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 13:
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, false);
@@ -252,19 +252,19 @@ public class BoatGludinRune implements Runnable
_boat.broadcastPacket(RUNE_SOUND);
_boat.payForRide(7904, 1, 34513, -38009, -3640);
_boat.executePath(RUNE_TO_GLUDIN);
ThreadPoolManager.getInstance().scheduleGeneral(this, 60000);
ThreadPoolManager.schedule(this, 60000);
break;
case 14:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 15:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 16:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 17:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVAL_GLUDIN1);
@@ -283,7 +283,7 @@ public class BoatGludinRune implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(GLUDIN_DOCK);
@@ -292,7 +292,7 @@ public class BoatGludinRune implements Runnable
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, true);
BoatManager.getInstance().broadcastPackets(GLUDIN_DOCK[0], RUNE_DOCK[0], ARRIVED_AT_GLUDIN, ARRIVED_AT_GLUDIN_2);
_boat.broadcastPacket(GLUDIN_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_shoutCount = 0;
@@ -119,44 +119,44 @@ public class BoatInnadrilTour implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL1);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, LEAVE_INNADRIL0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().broadcastPackets(DOCK, DOCK, LEAVING_INNADRIL, INNADRIL_SOUND);
_boat.payForRide(0, 1, 107092, 219098, -3952);
_boat.executePath(TOUR);
ThreadPoolManager.getInstance().scheduleGeneral(this, 650000);
ThreadPoolManager.schedule(this, 650000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL20);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL15);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 7:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 8:
BoatManager.getInstance().broadcastPacket(DOCK, DOCK, ARRIVAL1);
break;
case 9:
BoatManager.getInstance().broadcastPackets(DOCK, DOCK, ARRIVED_AT_INNADRIL, INNADRIL_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_cycle++;
@@ -118,7 +118,7 @@ public class BoatRunePrimeval implements Runnable
break;
case 1:
BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], ARRIVED_AT_PRIMEVAL, ARRIVED_AT_PRIMEVAL_2, PRIMEVAL_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
ThreadPoolManager.schedule(this, 180000);
break;
case 2:
BoatManager.getInstance().broadcastPackets(PRIMEVAL_DOCK, RUNE_DOCK[0], LEAVING_PRIMEVAL, PRIMEVAL_SOUND);
@@ -139,7 +139,7 @@ public class BoatRunePrimeval implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(RUNE_DOCK);
@@ -147,7 +147,7 @@ public class BoatRunePrimeval implements Runnable
case 4:
BoatManager.getInstance().dockShip(BoatManager.RUNE_HARBOR, true);
BoatManager.getInstance().broadcastPackets(RUNE_DOCK[0], PRIMEVAL_DOCK, ARRIVED_AT_RUNE, ARRIVED_AT_RUNE_2, RUNE_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 180000);
ThreadPoolManager.schedule(this, 180000);
break;
}
_shoutCount = 0;
@@ -145,15 +145,15 @@ public class BoatTalkingGludin implements Runnable
{
case 0:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_TALKING5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 1:
BoatManager.getInstance().broadcastPackets(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_TALKING1, LEAVE_TALKING1_2);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 2:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_TALKING0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 3:
BoatManager.getInstance().dockShip(BoatManager.TALKING_ISLAND, false);
@@ -161,15 +161,15 @@ public class BoatTalkingGludin implements Runnable
_boat.broadcastPacket(TALKING_SOUND);
_boat.payForRide(1074, 1, -96777, 258970, -3623);
_boat.executePath(TALKING_TO_GLUDIN);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 4:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], TALKING_DOCK[0], ARRIVAL_GLUDIN10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 5:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], TALKING_DOCK[0], ARRIVAL_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 6:
BoatManager.getInstance().broadcastPacket(GLUDIN_DOCK[0], TALKING_DOCK[0], ARRIVAL_GLUDIN1);
@@ -188,7 +188,7 @@ public class BoatTalkingGludin implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(GLUDIN_DOCK);
@@ -197,19 +197,19 @@ public class BoatTalkingGludin implements Runnable
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, true);
BoatManager.getInstance().broadcastPackets(GLUDIN_DOCK[0], TALKING_DOCK[0], ARRIVED_AT_GLUDIN, ARRIVED_AT_GLUDIN_2);
_boat.broadcastPacket(GLUDIN_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 9:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_GLUDIN5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 10:
BoatManager.getInstance().broadcastPackets(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_GLUDIN1, LEAVE_TALKING1_2);
ThreadPoolManager.getInstance().scheduleGeneral(this, 40000);
ThreadPoolManager.schedule(this, 40000);
break;
case 11:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], LEAVE_GLUDIN0);
ThreadPoolManager.getInstance().scheduleGeneral(this, 20000);
ThreadPoolManager.schedule(this, 20000);
break;
case 12:
BoatManager.getInstance().dockShip(BoatManager.GLUDIN_HARBOR, false);
@@ -217,15 +217,15 @@ public class BoatTalkingGludin implements Runnable
_boat.broadcastPacket(GLUDIN_SOUND);
_boat.payForRide(1075, 1, -90015, 150422, -3610);
_boat.executePath(GLUDIN_TO_TALKING);
ThreadPoolManager.getInstance().scheduleGeneral(this, 150000);
ThreadPoolManager.schedule(this, 150000);
break;
case 13:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_TALKING10);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
case 14:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_TALKING5);
ThreadPoolManager.getInstance().scheduleGeneral(this, 240000);
ThreadPoolManager.schedule(this, 240000);
break;
case 15:
BoatManager.getInstance().broadcastPacket(TALKING_DOCK[0], GLUDIN_DOCK[0], ARRIVAL_TALKING1);
@@ -244,7 +244,7 @@ public class BoatTalkingGludin implements Runnable
_shoutCount = 0;
}
ThreadPoolManager.getInstance().scheduleGeneral(this, 5000);
ThreadPoolManager.schedule(this, 5000);
return;
}
_boat.executePath(TALKING_DOCK);
@@ -253,7 +253,7 @@ public class BoatTalkingGludin implements Runnable
BoatManager.getInstance().dockShip(BoatManager.TALKING_ISLAND, true);
BoatManager.getInstance().broadcastPackets(TALKING_DOCK[0], GLUDIN_DOCK[0], ARRIVED_AT_TALKING, ARRIVED_AT_TALKING_2);
_boat.broadcastPacket(TALKING_SOUND);
ThreadPoolManager.getInstance().scheduleGeneral(this, 300000);
ThreadPoolManager.schedule(this, 300000);
break;
}
_shoutCount = 0;
@@ -463,14 +463,10 @@ public final class Config
public static boolean ALT_DEV_NO_SPAWNS;
public static boolean ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS;
public static boolean ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS;
public static int THREAD_P_EFFECTS;
public static int THREAD_P_GENERAL;
public static int THREAD_E_EVENTS;
public static int GENERAL_PACKET_THREAD_CORE_SIZE;
public static int IO_PACKET_THREAD_CORE_SIZE;
public static int GENERAL_THREAD_CORE_SIZE;
public static int AI_MAX_THREAD;
public static int EVENT_MAX_THREAD;
public static int SCHEDULED_THREAD_POOL_COUNT;
public static int THREADS_PER_SCHEDULED_THREAD_POOL;
public static int INSTANT_THREAD_POOL_COUNT;
public static int THREADS_PER_INSTANT_THREAD_POOL;
public static int CLIENT_PACKET_QUEUE_SIZE;
public static int CLIENT_PACKET_QUEUE_MAX_BURST_SIZE;
public static int CLIENT_PACKET_QUEUE_MAX_PACKETS_PER_SECOND;
@@ -1817,14 +1813,10 @@ public final class Config
ALT_DEV_NO_SPAWNS = General.getBoolean("AltDevNoSpawns", false) || Boolean.getBoolean("nospawns");
ALT_DEV_SHOW_QUESTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowQuestsLoadInLogs", false);
ALT_DEV_SHOW_SCRIPTS_LOAD_IN_LOGS = General.getBoolean("AltDevShowScriptsLoadInLogs", false);
THREAD_P_EFFECTS = General.getInt("ThreadPoolSizeEffects", 10);
THREAD_P_GENERAL = General.getInt("ThreadPoolSizeGeneral", 13);
THREAD_E_EVENTS = General.getInt("ThreadPoolSizeEvents", 2);
IO_PACKET_THREAD_CORE_SIZE = General.getInt("UrgentPacketThreadCoreSize", 2);
GENERAL_PACKET_THREAD_CORE_SIZE = General.getInt("GeneralPacketThreadCoreSize", 4);
GENERAL_THREAD_CORE_SIZE = General.getInt("GeneralThreadCoreSize", 4);
AI_MAX_THREAD = General.getInt("AiMaxThread", 6);
EVENT_MAX_THREAD = General.getInt("EventsMaxThread", 5);
SCHEDULED_THREAD_POOL_COUNT = General.getInt("ScheduledThreadPoolCount", -1);
THREADS_PER_SCHEDULED_THREAD_POOL = General.getInt("ThreadsPerScheduledThreadPool", 4);
INSTANT_THREAD_POOL_COUNT = General.getInt("InstantThreadPoolCount", -1);
THREADS_PER_INSTANT_THREAD_POOL = General.getInt("ThreadsPerInstantThreadPool", 2);
CLIENT_PACKET_QUEUE_SIZE = General.getInt("ClientPacketQueueSize", 0);
if (CLIENT_PACKET_QUEUE_SIZE == 0)
{
@@ -160,13 +160,15 @@ public final class GameServer
{
final long serverLoadStart = System.currentTimeMillis();
printSection("IdFactory");
if (!IdFactory.getInstance().isInitialized())
{
_log.severe(getClass().getSimpleName() + ": Could not read object IDs from database. Please check your configuration.");
throw new Exception("Could not initialize the ID factory!");
}
ThreadPoolManager.getInstance();
printSection("ThreadPool");
ThreadPoolManager.init();
EventDispatcher.getInstance();
new File("log/game").mkdirs();
@@ -143,7 +143,7 @@ public final class GameTimeController extends Thread
if (isNight)
{
ThreadPoolManager.getInstance().executeAi(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
ThreadPoolManager.execute(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
}
while (true)
@@ -175,7 +175,7 @@ public final class GameTimeController extends Thread
{
isNight = !isNight;
ThreadPoolManager.getInstance().executeAi(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
ThreadPoolManager.execute(() -> DayNightSpawnManager.getInstance().notifyChangeMode());
}
}
}
@@ -31,7 +31,7 @@ public final class ItemsAutoDestroy
protected ItemsAutoDestroy()
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::removeItems, 5000, 5000);
ThreadPoolManager.scheduleAtFixedRate(this::removeItems, 5000, 5000);
}
public static ItemsAutoDestroy getInstance()
@@ -109,7 +109,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION)
{
_activeMakers.put(manufacturer.getObjectId(), maker);
ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
ThreadPoolManager.schedule(maker, 100);
}
else
{
@@ -158,7 +158,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION)
{
_activeMakers.put(player.getObjectId(), maker);
ThreadPoolManager.getInstance().scheduleGeneral(maker, 100);
ThreadPoolManager.schedule(maker, 100);
}
else
{
@@ -353,7 +353,7 @@ public class RecipeController
_player.broadcastPacket(msk);
_player.sendPacket(new SetupGauge(0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{
@@ -536,7 +536,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION && isWait)
{
_player.sendPacket(new SetupGauge(0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{
@@ -558,7 +558,7 @@ public class RecipeController
if (Config.ALT_GAME_CREATION && isWait)
{
_player.sendPacket(new SetupGauge(0, _delay));
ThreadPoolManager.getInstance().scheduleGeneral(this, 100 + _delay);
ThreadPoolManager.schedule(this, 100 + _delay);
}
else
{
@@ -186,7 +186,7 @@ public class SevenSigns
// Schedule a time for the next period change.
final SevenSignsPeriodChange sspc = new SevenSignsPeriodChange();
ThreadPoolManager.getInstance().scheduleGeneral(sspc, milliToChange);
ThreadPoolManager.schedule(sspc, milliToChange);
// Thanks to http://rainbow.arch.scriptmania.com/scripts/timezone_countdown.html for help with this.
final double numSecs = (milliToChange / 1000) % 60;
@@ -1538,7 +1538,7 @@ public class SevenSigns
setCalendarForNextPeriodChange();
final SevenSignsPeriodChange sspc = new SevenSignsPeriodChange();
ThreadPoolManager.getInstance().scheduleGeneral(sspc, getMilliToPeriodChange());
ThreadPoolManager.schedule(sspc, getMilliToPeriodChange());
}
}
@@ -912,7 +912,7 @@ public class SevenSignsFestival implements SpawnListener
// at the specified time, then invoke it automatically after every cycle.
_managerInstance = new FestivalManager();
setNextFestivalStart(Config.ALT_FESTIVAL_MANAGER_START + FESTIVAL_SIGNUP_TIME);
_managerScheduledTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(_managerInstance, Config.ALT_FESTIVAL_MANAGER_START, Config.ALT_FESTIVAL_CYCLE_LENGTH);
_managerScheduledTask = ThreadPoolManager.scheduleAtFixedRate(_managerInstance, Config.ALT_FESTIVAL_MANAGER_START, Config.ALT_FESTIVAL_CYCLE_LENGTH);
_log.info("SevenSignsFestival: The first Festival of Darkness cycle begins in " + (Config.ALT_FESTIVAL_MANAGER_START / 60000) + " minute(s).");
}
@@ -213,7 +213,7 @@ public class Shutdown extends Thread
// stop all thread pools
try
{
ThreadPoolManager.getInstance().shutdown();
ThreadPoolManager.shutdown();
_log.info("Thread Pool Manager: Manager has been shut down(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
}
catch (Throwable t)
@@ -16,790 +16,284 @@
*/
package com.l2jmobius.gameserver;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.StatsSet;
/**
* This class handles thread pooling system. It relies on two ThreadPoolExecutor arrays, which poolers number is generated using config.
* <p>
* This class is made to handle all the ThreadPools used in L2J.
* Those arrays hold following pools :
* </p>
* <p>
* Scheduled Tasks can either be sent to a {@link #_generalScheduledThreadPool "general"} or {@link #_effectsScheduledThreadPool "effects"} {@link ScheduledThreadPoolExecutor ScheduledThreadPool}: The "effects" one is used for every effects (skills, hp/mp regen ...) while the "general" one is used
* for everything else that needs to be scheduled.<br>
* There also is an {@link #_aiScheduledThreadPool "ai"} {@link ScheduledThreadPoolExecutor ScheduledThreadPool} used for AI Tasks.
* </p>
* <p>
* Tasks can be sent to {@link ScheduledThreadPoolExecutor ScheduledThreadPool} either with:
* <ul>
* <li>{@link #scheduleEffect(Runnable, long, TimeUnit)} and {@link #scheduleEffect(Runnable, long)} : for effects Tasks that needs to be executed only once.</li>
* <li>{@link #scheduleGeneral(Runnable, long, TimeUnit)} and {@link #scheduleGeneral(Runnable, long)} : for scheduled Tasks that needs to be executed once.</li>
* <li>{@link #scheduleAi(Runnable, long, TimeUnit)} and {@link #scheduleAi(Runnable, long)} : for AI Tasks that needs to be executed once</li>
* <li>Scheduled pool keeps a track about incoming, future events.</li>
* <li>Instant pool handles short-life events.</li>
* </ul>
* or
* <ul>
* <li>{@link #scheduleEffectAtFixedRate(Runnable, long, long, TimeUnit)} and {@link #scheduleEffectAtFixedRate(Runnable, long, long)} : for effects Tasks that needs to be executed periodically.</li>
* <li>{@link #scheduleGeneralAtFixedRate(Runnable, long, long, TimeUnit)} and {@link #scheduleGeneralAtFixedRate(Runnable, long, long)} : for scheduled Tasks that needs to be executed periodically.</li>
* <li>{@link #scheduleAiAtFixedRate(Runnable, long, long, TimeUnit)} and {@link #scheduleAiAtFixedRate(Runnable, long, long)} : for AI Tasks that needs to be executed periodically</li>
* </ul>
* </p>
* <p>
* For all Tasks that should be executed with no delay asynchronously in a ThreadPool there also are usual {@link ThreadPoolExecutor ThreadPools} that can grow/shrink according to their load.:
* <ul>
* <li>{@link #_generalPacketsThreadPool GeneralPackets} where most packets handler are executed.</li>
* <li>{@link #_ioPacketsThreadPool I/O Packets} where all the i/o packets are executed.</li>
* <li>There will be an AI ThreadPool where AI events should be executed</li>
* <li>A general ThreadPool where everything else that needs to run asynchronously with no delay should be executed ({@link com.l2jmobius.gameserver.model.actor.knownlist KnownList} updates, SQL updates/inserts...)?</li>
* </ul>
* </p>
* @author -Wooden-
*/
public class ThreadPoolManager
public final class ThreadPoolManager
{
protected static final Logger _log = Logger.getLogger(ThreadPoolManager.class.getName());
protected static final Logger LOG = Logger.getLogger(ThreadPoolManager.class.getName());
private static final class RunnableWrapper implements Runnable
private static final long MAX_DELAY = TimeUnit.NANOSECONDS.toMillis(Long.MAX_VALUE - System.nanoTime()) / 2;
private static int _threadPoolRandomizer;
protected static ScheduledThreadPoolExecutor[] _scheduledPools;
protected static ThreadPoolExecutor[] _instantPools;
/**
* Init the different pools, based on Config. It is launched only once, on Gameserver instance.
*/
public static void init()
{
private final Runnable _r;
public RunnableWrapper(Runnable r)
// Feed scheduled pool.
int poolCount = Config.SCHEDULED_THREAD_POOL_COUNT;
if (poolCount == -1)
{
_r = r;
poolCount = Runtime.getRuntime().availableProcessors();
}
@Override
public final void run()
_scheduledPools = new ScheduledThreadPoolExecutor[poolCount];
for (int i = 0; i < poolCount; i++)
{
try
{
_r.run();
}
catch (Throwable e)
{
final Thread t = Thread.currentThread();
final UncaughtExceptionHandler h = t.getUncaughtExceptionHandler();
if (h != null)
{
h.uncaughtException(t, e);
}
}
_scheduledPools[i] = new ScheduledThreadPoolExecutor(Config.THREADS_PER_SCHEDULED_THREAD_POOL);
}
}
protected ScheduledThreadPoolExecutor _effectsScheduledThreadPool;
protected ScheduledThreadPoolExecutor _generalScheduledThreadPool;
protected ScheduledThreadPoolExecutor _aiScheduledThreadPool;
protected ScheduledThreadPoolExecutor _eventScheduledThreadPool;
private final ThreadPoolExecutor _generalPacketsThreadPool;
private final ThreadPoolExecutor _ioPacketsThreadPool;
private final ThreadPoolExecutor _generalThreadPool;
private final ThreadPoolExecutor _eventThreadPool;
private boolean _shutdown;
public static ThreadPoolManager getInstance()
{
return SingletonHolder._instance;
}
protected ThreadPoolManager()
{
_effectsScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_EFFECTS, new PriorityThreadFactory("EffectsSTPool", Thread.NORM_PRIORITY));
_generalScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_GENERAL, new PriorityThreadFactory("GeneralSTPool", Thread.NORM_PRIORITY));
_eventScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_E_EVENTS, new PriorityThreadFactory("EventSTPool", Thread.NORM_PRIORITY));
_ioPacketsThreadPool = new ThreadPoolExecutor(Config.IO_PACKET_THREAD_CORE_SIZE, Integer.MAX_VALUE, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("I/O Packet Pool", Thread.NORM_PRIORITY + 1));
_generalPacketsThreadPool = new ThreadPoolExecutor(Config.GENERAL_PACKET_THREAD_CORE_SIZE, Config.GENERAL_PACKET_THREAD_CORE_SIZE + 2, 15L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("Normal Packet Pool", Thread.NORM_PRIORITY + 1));
_generalThreadPool = new ThreadPoolExecutor(Config.GENERAL_THREAD_CORE_SIZE, Config.GENERAL_THREAD_CORE_SIZE + 2, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("General Pool", Thread.NORM_PRIORITY));
_aiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.AI_MAX_THREAD, new PriorityThreadFactory("AISTPool", Thread.NORM_PRIORITY));
_eventThreadPool = new ThreadPoolExecutor(Config.EVENT_MAX_THREAD, Config.EVENT_MAX_THREAD + 2, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("Event Pool", Thread.NORM_PRIORITY));
scheduleGeneralAtFixedRate(new PurgeTask(), 10, 5, TimeUnit.MINUTES);
// Feed instant pool.
poolCount = Config.INSTANT_THREAD_POOL_COUNT;
if (poolCount == -1)
{
poolCount = Runtime.getRuntime().availableProcessors();
}
_instantPools = new ThreadPoolExecutor[poolCount];
for (int i = 0; i < poolCount; i++)
{
_instantPools[i] = new ThreadPoolExecutor(Config.THREADS_PER_INSTANT_THREAD_POOL, Config.THREADS_PER_INSTANT_THREAD_POOL, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100000));
}
// Prestart core threads.
for (ScheduledThreadPoolExecutor threadPool : _scheduledPools)
{
threadPool.prestartAllCoreThreads();
}
for (ThreadPoolExecutor threadPool : _instantPools)
{
threadPool.prestartAllCoreThreads();
}
// Launch purge task.
scheduleAtFixedRate(() ->
{
purge();
}, 600000, 600000);
LOG.info("ThreadPoolManager: Initialized " + getPoolSize(_instantPools) + "/" + getMaximumPoolSize(_instantPools) + " instant thread(s).");
LOG.info("ThreadPoolManager: Initialized " + getPoolSize(_scheduledPools) + "/" + getMaximumPoolSize(_scheduledPools) + " scheduled thread(s).");
}
public static void purge()
{
for (ScheduledThreadPoolExecutor threadPool1 : _scheduledPools)
{
threadPool1.purge();
}
for (ThreadPoolExecutor threadPool2 : _instantPools)
{
threadPool2.purge();
}
}
/**
* Schedules an effect task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in the given time unit
* @param unit the time unit of the delay parameter
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
* Schedules a one-shot action that becomes enabled after a delay. The pool is chosen based on pools activity.
* @param r : the task to execute.
* @param delay : the time from now to delay execution.
* @return a ScheduledFuture representing pending completion of the task and whose get() method will return null upon completion.
*/
public ScheduledFuture<?> scheduleEffect(Runnable task, long delay, TimeUnit unit)
public static ScheduledFuture<?> schedule(Runnable r, long delay)
{
try
{
return _effectsScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
return getPool(_scheduledPools).schedule(new TaskWrapper(r), validate(delay), TimeUnit.MILLISECONDS);
}
catch (RejectedExecutionException e)
catch (Exception e)
{
return null;
}
}
/**
* Schedules an effect task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
* Schedules a periodic action that becomes enabled after a delay. The pool is chosen based on pools activity.
* @param r : the task to execute.
* @param delay : the time from now to delay execution.
* @param period : the period between successive executions.
* @return a ScheduledFuture representing pending completion of the task and whose get() method will throw an exception upon cancellation.
*/
public ScheduledFuture<?> scheduleEffect(Runnable task, long delay)
{
return scheduleEffect(task, delay, TimeUnit.MILLISECONDS);
}
/**
* Schedules an effect task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in the given time unit
* @param period the period between executions in the given time unit
* @param unit the time unit of the initialDelay and period parameters
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
public static ScheduledFuture<?> scheduleAtFixedRate(Runnable r, long delay, long period)
{
try
{
return _effectsScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
return getPool(_scheduledPools).scheduleAtFixedRate(new TaskWrapper(r), validate(delay), validate(period), TimeUnit.MILLISECONDS);
}
catch (RejectedExecutionException e)
catch (Exception e)
{
return null; /* shutdown, ignore */
return null;
}
}
/**
* Schedules an effect task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in milliseconds
* @param period the period between executions in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
* Executes the given task sometime in the future.
* @param r : the task to execute.
*/
public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable task, long initialDelay, long period)
{
return scheduleEffectAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
}
/**
* Schedules a general task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in the given time unit
* @param unit the time unit of the delay parameter
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay, TimeUnit unit)
public static void execute(Runnable r)
{
try
{
return _generalScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
getPool(_instantPools).execute(new TaskWrapper(r));
}
catch (RejectedExecutionException e)
catch (Exception e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules a general task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleGeneral(Runnable task, long delay)
public static String[] getStats()
{
return scheduleGeneral(task, delay, TimeUnit.MILLISECONDS);
List<String> stats = new ArrayList<>();
for (int i = 0; i < _scheduledPools.length; i++)
{
final ScheduledThreadPoolExecutor threadPool = _scheduledPools[i];
stats.add("Scheduled pool #" + i + ":");
stats.add(" |- ActiveCount: ...... " + threadPool.getActiveCount());
stats.add(" |- CorePoolSize: ..... " + threadPool.getCorePoolSize());
stats.add(" |- PoolSize: ......... " + threadPool.getPoolSize());
stats.add(" |- LargestPoolSize: .. " + threadPool.getLargestPoolSize());
stats.add(" |- MaximumPoolSize: .. " + threadPool.getMaximumPoolSize());
stats.add(" |- CompletedTaskCount: " + threadPool.getCompletedTaskCount());
stats.add(" |- QueuedTaskCount: .. " + threadPool.getQueue().size());
stats.add(" |- TaskCount: ........ " + threadPool.getTaskCount());
stats.add(" | -------");
}
for (int i = 0; i < _instantPools.length; i++)
{
final ThreadPoolExecutor threadPool = _instantPools[i];
stats.add("Scheduled pool #" + i + ":");
stats.add(" |- ActiveCount: ...... " + threadPool.getActiveCount());
stats.add(" |- CorePoolSize: ..... " + threadPool.getCorePoolSize());
stats.add(" |- PoolSize: ......... " + threadPool.getPoolSize());
stats.add(" |- LargestPoolSize: .. " + threadPool.getLargestPoolSize());
stats.add(" |- MaximumPoolSize: .. " + threadPool.getMaximumPoolSize());
stats.add(" |- CompletedTaskCount: " + threadPool.getCompletedTaskCount());
stats.add(" |- QueuedTaskCount: .. " + threadPool.getQueue().size());
stats.add(" |- TaskCount: ........ " + threadPool.getTaskCount());
stats.add(" | -------");
}
return stats.toArray(new String[stats.size()]);
}
/**
* Schedules a general task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in the given time unit
* @param period the period between executions in the given time unit
* @param unit the time unit of the initialDelay and period parameters
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
* Shutdown thread pooling system correctly. Send different informations.
*/
public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
public static void shutdown()
{
try
{
return _generalScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
}
catch (RejectedExecutionException e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules a event task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in the given time unit
* @param unit the time unit of the delay parameter
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleEvent(Runnable task, long delay, TimeUnit unit)
{
try
{
return _eventScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
}
catch (RejectedExecutionException e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules a event task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleEvent(Runnable task, long delay)
{
return scheduleEvent(task, delay, TimeUnit.MILLISECONDS);
}
/**
* Schedules a event task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in the given time unit
* @param period the period between executions in the given time unit
* @param unit the time unit of the initialDelay and period parameters
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleEventAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
{
try
{
return _eventScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
}
catch (RejectedExecutionException e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules a general task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in milliseconds
* @param period the period between executions in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable task, long initialDelay, long period)
{
return scheduleGeneralAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
}
/**
* Schedules an AI task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in the given time unit
* @param unit the time unit of the delay parameter
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleAi(Runnable task, long delay, TimeUnit unit)
{
try
{
return _aiScheduledThreadPool.schedule(new RunnableWrapper(task), delay, unit);
}
catch (RejectedExecutionException e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules an AI task to be executed after the given delay.
* @param task the task to execute
* @param delay the delay in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleAi(Runnable task, long delay)
{
return scheduleAi(task, delay, TimeUnit.MILLISECONDS);
}
/**
* Schedules a general task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in the given time unit
* @param period the period between executions in the given time unit
* @param unit the time unit of the initialDelay and period parameters
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period, TimeUnit unit)
{
try
{
return _aiScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(task), initialDelay, period, unit);
}
catch (RejectedExecutionException e)
{
return null; /* shutdown, ignore */
}
}
/**
* Schedules a general task to be executed at fixed rate.
* @param task the task to execute
* @param initialDelay the initial delay in milliseconds
* @param period the period between executions in milliseconds
* @return a ScheduledFuture representing pending completion of the task, and whose get() method will throw an exception upon cancellation
*/
public ScheduledFuture<?> scheduleAiAtFixedRate(Runnable task, long initialDelay, long period)
{
return scheduleAiAtFixedRate(task, initialDelay, period, TimeUnit.MILLISECONDS);
}
/**
* Executes a packet task sometime in future in another thread.
* @param task the task to execute
*/
public void executePacket(Runnable task)
{
try
{
_generalPacketsThreadPool.execute(task);
}
catch (RejectedExecutionException e)
{
/* shutdown, ignore */
}
}
/**
* Executes an IO packet task sometime in future in another thread.
* @param task the task to execute
*/
public void executeIOPacket(Runnable task)
{
try
{
_ioPacketsThreadPool.execute(task);
}
catch (RejectedExecutionException e)
{
/* shutdown, ignore */
}
}
/**
* Executes a general task sometime in future in another thread.
* @param task the task to execute
*/
public void executeGeneral(Runnable task)
{
try
{
_generalThreadPool.execute(new RunnableWrapper(task));
}
catch (RejectedExecutionException e)
{
/* shutdown, ignore */
}
}
/**
* Executes an AI task sometime in future in another thread.
* @param task the task to execute
*/
public void executeAi(Runnable task)
{
try
{
_aiScheduledThreadPool.execute(new RunnableWrapper(task));
}
catch (RejectedExecutionException e)
{
/* shutdown, ignore */
}
}
/**
* Executes an Event task sometime in future in another thread.
* @param task the task to execute
*/
public void executeEvent(Runnable task)
{
try
{
_eventThreadPool.execute(new RunnableWrapper(task));
}
catch (RejectedExecutionException e)
{
/* shutdown, ignore */
}
}
public StatsSet getStats(String category)
{
final StatsSet StatsSet = new StatsSet();
switch (category)
{
case "EFFECTS":
{
StatsSet.set("ActiveThreads", _effectsScheduledThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _effectsScheduledThreadPool.getCorePoolSize());
StatsSet.set("PoolSize", _effectsScheduledThreadPool.getPoolSize());
StatsSet.set("MaximumPoolSize", _effectsScheduledThreadPool.getMaximumPoolSize());
StatsSet.set("CompletedTasks", (int) _effectsScheduledThreadPool.getCompletedTaskCount());
StatsSet.set("ScheduledTasks", _effectsScheduledThreadPool.getQueue().size());
break;
}
case "GENERAL":
{
StatsSet.set("ActiveThreads", _generalScheduledThreadPool.getActiveCount());
StatsSet.set("getCorePoolSizes", _generalScheduledThreadPool.getCorePoolSize());
StatsSet.set("PoolSizes", _generalScheduledThreadPool.getPoolSize());
StatsSet.set("MaximumPoolSizes", _generalScheduledThreadPool.getMaximumPoolSize());
StatsSet.set("CompletedTasks", (int) _generalScheduledThreadPool.getCompletedTaskCount());
StatsSet.set("ScheduledTasks", _generalScheduledThreadPool.getQueue().size());
break;
}
case "AI":
{
StatsSet.set("ActiveThreads", _aiScheduledThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _aiScheduledThreadPool.getCorePoolSize());
StatsSet.set("PoolSize", _aiScheduledThreadPool.getPoolSize());
StatsSet.set("MaximumPoolSize", _aiScheduledThreadPool.getMaximumPoolSize());
StatsSet.set("CompletedTasks", (int) _aiScheduledThreadPool.getCompletedTaskCount());
StatsSet.set("ScheduledTasks", _aiScheduledThreadPool.getQueue().size());
break;
}
case "EVENT":
{
StatsSet.set("ActiveThreads", _eventScheduledThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _eventScheduledThreadPool.getCorePoolSize());
StatsSet.set("PoolSize", _eventScheduledThreadPool.getPoolSize());
StatsSet.set("MaximumPoolSize", _eventScheduledThreadPool.getMaximumPoolSize());
StatsSet.set("CompletedTasks", (int) _eventScheduledThreadPool.getCompletedTaskCount());
StatsSet.set("ScheduledTasks", _eventScheduledThreadPool.getQueue().size());
break;
}
case "PACKETS":
{
StatsSet.set("ActiveThreads", _generalPacketsThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _generalPacketsThreadPool.getCorePoolSize());
StatsSet.set("MaximumPoolSize", _generalPacketsThreadPool.getMaximumPoolSize());
StatsSet.set("LargestPoolSize", _generalPacketsThreadPool.getLargestPoolSize());
StatsSet.set("PoolSize", _generalPacketsThreadPool.getPoolSize());
StatsSet.set("CompletedTasks", (int) _generalPacketsThreadPool.getCompletedTaskCount());
StatsSet.set("QueuedTasks", _generalPacketsThreadPool.getQueue().size());
break;
}
case "IOPACKETS":
{
StatsSet.set("ActiveThreads", _ioPacketsThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _ioPacketsThreadPool.getCorePoolSize());
StatsSet.set("MaximumPoolSize", _ioPacketsThreadPool.getMaximumPoolSize());
StatsSet.set("LargestPoolSize", _ioPacketsThreadPool.getLargestPoolSize());
StatsSet.set("PoolSize", _ioPacketsThreadPool.getPoolSize());
StatsSet.set("CompletedTasks", (int) _ioPacketsThreadPool.getCompletedTaskCount());
StatsSet.set("QueuedTasks", _ioPacketsThreadPool.getQueue().size());
break;
}
case "GENERAL_TASKS":
{
StatsSet.set("ActiveThreads", _generalThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _generalThreadPool.getCorePoolSize());
StatsSet.set("MaximumPoolSize", _generalThreadPool.getMaximumPoolSize());
StatsSet.set("LargestPoolSize", _generalThreadPool.getLargestPoolSize());
StatsSet.set("PoolSize", _generalThreadPool.getPoolSize());
StatsSet.set("CompletedTasks", (int) _generalThreadPool.getCompletedTaskCount());
StatsSet.set("QueuedTasks", _generalThreadPool.getQueue().size());
break;
}
case "EVENT_TASKS":
{
StatsSet.set("ActiveThreads", _eventThreadPool.getActiveCount());
StatsSet.set("getCorePoolSize", _eventThreadPool.getCorePoolSize());
StatsSet.set("MaximumPoolSize", _eventThreadPool.getMaximumPoolSize());
StatsSet.set("LargestPoolSize", _eventThreadPool.getLargestPoolSize());
StatsSet.set("PoolSize", _eventThreadPool.getPoolSize());
StatsSet.set("CompletedTasks", (int) _eventThreadPool.getCompletedTaskCount());
StatsSet.set("QueuedTasks", _eventThreadPool.getQueue().size());
break;
}
}
return StatsSet;
}
public String[] getStats()
{
return new String[]
{
"STP:",
" + Effects:",
" |- ActiveThreads: " + _effectsScheduledThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _effectsScheduledThreadPool.getCorePoolSize(),
" |- PoolSize: " + _effectsScheduledThreadPool.getPoolSize(),
" |- MaximumPoolSize: " + _effectsScheduledThreadPool.getMaximumPoolSize(),
" |- CompletedTasks: " + _effectsScheduledThreadPool.getCompletedTaskCount(),
" |- ScheduledTasks: " + _effectsScheduledThreadPool.getQueue().size(),
" | -------",
" + General:",
" |- ActiveThreads: " + _generalScheduledThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _generalScheduledThreadPool.getCorePoolSize(),
" |- PoolSize: " + _generalScheduledThreadPool.getPoolSize(),
" |- MaximumPoolSize: " + _generalScheduledThreadPool.getMaximumPoolSize(),
" |- CompletedTasks: " + _generalScheduledThreadPool.getCompletedTaskCount(),
" |- ScheduledTasks: " + _generalScheduledThreadPool.getQueue().size(),
" | -------",
" + AI:",
" |- ActiveThreads: " + _aiScheduledThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _aiScheduledThreadPool.getCorePoolSize(),
" |- PoolSize: " + _aiScheduledThreadPool.getPoolSize(),
" |- MaximumPoolSize: " + _aiScheduledThreadPool.getMaximumPoolSize(),
" |- CompletedTasks: " + _aiScheduledThreadPool.getCompletedTaskCount(),
" |- ScheduledTasks: " + _aiScheduledThreadPool.getQueue().size(),
" | -------",
" + Event:",
" |- ActiveThreads: " + _eventScheduledThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _eventScheduledThreadPool.getCorePoolSize(),
" |- PoolSize: " + _eventScheduledThreadPool.getPoolSize(),
" |- MaximumPoolSize: " + _eventScheduledThreadPool.getMaximumPoolSize(),
" |- CompletedTasks: " + _eventScheduledThreadPool.getCompletedTaskCount(),
" |- ScheduledTasks: " + _eventScheduledThreadPool.getQueue().size(),
"TP:",
" + Packets:",
" |- ActiveThreads: " + _generalPacketsThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _generalPacketsThreadPool.getCorePoolSize(),
" |- MaximumPoolSize: " + _generalPacketsThreadPool.getMaximumPoolSize(),
" |- LargestPoolSize: " + _generalPacketsThreadPool.getLargestPoolSize(),
" |- PoolSize: " + _generalPacketsThreadPool.getPoolSize(),
" |- CompletedTasks: " + _generalPacketsThreadPool.getCompletedTaskCount(),
" |- QueuedTasks: " + _generalPacketsThreadPool.getQueue().size(),
" | -------",
" + I/O Packets:",
" |- ActiveThreads: " + _ioPacketsThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _ioPacketsThreadPool.getCorePoolSize(),
" |- MaximumPoolSize: " + _ioPacketsThreadPool.getMaximumPoolSize(),
" |- LargestPoolSize: " + _ioPacketsThreadPool.getLargestPoolSize(),
" |- PoolSize: " + _ioPacketsThreadPool.getPoolSize(),
" |- CompletedTasks: " + _ioPacketsThreadPool.getCompletedTaskCount(),
" |- QueuedTasks: " + _ioPacketsThreadPool.getQueue().size(),
" | -------",
" + General Tasks:",
" |- ActiveThreads: " + _generalThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _generalThreadPool.getCorePoolSize(),
" |- MaximumPoolSize: " + _generalThreadPool.getMaximumPoolSize(),
" |- LargestPoolSize: " + _generalThreadPool.getLargestPoolSize(),
" |- PoolSize: " + _generalThreadPool.getPoolSize(),
" |- CompletedTasks: " + _generalThreadPool.getCompletedTaskCount(),
" |- QueuedTasks: " + _generalThreadPool.getQueue().size(),
" | -------",
" + Event Tasks:",
" |- ActiveThreads: " + _eventThreadPool.getActiveCount(),
" |- getCorePoolSize: " + _eventThreadPool.getCorePoolSize(),
" |- MaximumPoolSize: " + _eventThreadPool.getMaximumPoolSize(),
" |- LargestPoolSize: " + _eventThreadPool.getLargestPoolSize(),
" |- PoolSize: " + _eventThreadPool.getPoolSize(),
" |- CompletedTasks: " + _eventThreadPool.getCompletedTaskCount(),
" |- QueuedTasks: " + _eventThreadPool.getQueue().size(),
" | -------"
};
}
private static class PriorityThreadFactory implements ThreadFactory
{
private final int _prio;
private final String _name;
private final AtomicInteger _threadNumber = new AtomicInteger(1);
private final ThreadGroup _group;
public PriorityThreadFactory(String name, int prio)
{
_prio = prio;
_name = name;
_group = new ThreadGroup(_name);
}
@Override
public Thread newThread(Runnable r)
{
final Thread t = new Thread(_group, r, _name + "-" + _threadNumber.getAndIncrement());
t.setPriority(_prio);
return t;
}
public ThreadGroup getGroup()
{
return _group;
}
}
public void shutdown()
{
_shutdown = true;
try
{
_effectsScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_generalScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_generalPacketsThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_ioPacketsThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_generalThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_eventThreadPool.awaitTermination(1, TimeUnit.SECONDS);
_effectsScheduledThreadPool.shutdown();
_generalScheduledThreadPool.shutdown();
_generalPacketsThreadPool.shutdown();
_ioPacketsThreadPool.shutdown();
_generalThreadPool.shutdown();
_eventThreadPool.shutdown();
_log.info("All ThreadPools are now stopped");
}
catch (InterruptedException e)
{
_log.log(Level.WARNING, "There has been a problem shuting down the thread pool manager!", e);
}
}
public boolean isShutdown()
{
return _shutdown;
}
public void purge()
{
_effectsScheduledThreadPool.purge();
_generalScheduledThreadPool.purge();
_aiScheduledThreadPool.purge();
_eventScheduledThreadPool.purge();
_ioPacketsThreadPool.purge();
_generalPacketsThreadPool.purge();
_generalThreadPool.purge();
_eventThreadPool.purge();
}
public String getPacketStats()
{
final StringBuilder sb = new StringBuilder(1000);
final ThreadFactory tf = _generalPacketsThreadPool.getThreadFactory();
if (tf instanceof PriorityThreadFactory)
{
final PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
final int count = ptf.getGroup().activeCount();
final Thread[] threads = new Thread[count + 2];
ptf.getGroup().enumerate(threads);
sb.append("General Packet Thread Pool:" + Config.EOL + "Tasks in the queue: " + _generalPacketsThreadPool.getQueue().size() + Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be " + count + " Threads" + Config.EOL);
for (Thread t : threads)
{
if (t == null)
{
continue;
}
sb.append(t.getName());
sb.append(Config.EOL);
for (StackTraceElement ste : t.getStackTrace())
{
sb.append(ste);
sb.append(Config.EOL);
}
}
}
sb.append("Packet Tp stack traces printed.");
sb.append(Config.EOL);
return sb.toString();
}
public String getIOPacketStats()
{
final StringBuilder sb = new StringBuilder(1000);
final ThreadFactory tf = _ioPacketsThreadPool.getThreadFactory();
if (tf instanceof PriorityThreadFactory)
{
final PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
final int count = ptf.getGroup().activeCount();
final Thread[] threads = new Thread[count + 2];
ptf.getGroup().enumerate(threads);
sb.append("I/O Packet Thread Pool:" + Config.EOL + "Tasks in the queue: " + _ioPacketsThreadPool.getQueue().size() + Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be " + count + " Threads" + Config.EOL);
System.out.println("ThreadPoolManager: Shutting down.");
for (Thread t : threads)
for (ScheduledThreadPoolExecutor threadPool : _scheduledPools)
{
if (t == null)
{
continue;
}
sb.append(t.getName());
sb.append(Config.EOL);
for (StackTraceElement ste : t.getStackTrace())
{
sb.append(ste);
sb.append(Config.EOL);
}
threadPool.shutdownNow();
}
}
sb.append("Packet Tp stack traces printed." + Config.EOL);
return sb.toString();
}
public String getGeneralStats()
{
final StringBuilder sb = new StringBuilder(1000);
final ThreadFactory tf = _generalThreadPool.getThreadFactory();
if (tf instanceof PriorityThreadFactory)
{
final PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
final int count = ptf.getGroup().activeCount();
final Thread[] threads = new Thread[count + 2];
ptf.getGroup().enumerate(threads);
sb.append("General Thread Pool:" + Config.EOL + "Tasks in the queue: " + _generalThreadPool.getQueue().size() + Config.EOL + "Showing threads stack trace:" + Config.EOL + "There should be " + +count + " Threads" + Config.EOL);
for (Thread t : threads)
for (ThreadPoolExecutor threadPool : _instantPools)
{
if (t == null)
{
continue;
}
sb.append(t.getName());
sb.append(Config.EOL);
for (StackTraceElement ste : t.getStackTrace())
{
sb.append(ste);
sb.append(Config.EOL);
}
threadPool.shutdownNow();
}
}
sb.append("Packet Tp stack traces printed." + Config.EOL);
return sb.toString();
catch (Throwable t)
{
t.printStackTrace();
}
}
protected class PurgeTask implements Runnable
/**
* @param <T> : The pool type.
* @param threadPools : The pool array to check.
* @return the less fed pool.
*/
private static <T> T getPool(T[] threadPools)
{
return threadPools[_threadPoolRandomizer++ % threadPools.length];
}
/**
* @param delay : The delay to validate.
* @return a secured value, from 0 to MAX_DELAY.
*/
private static long validate(long delay)
{
return Math.max(0, Math.min(MAX_DELAY, delay));
}
/**
* @param threadPools : The pool array to check.
* @return the overall actual pools size.
*/
private static long getPoolSize(ThreadPoolExecutor[] threadPools)
{
long result = 0;
for (ThreadPoolExecutor threadPool : threadPools)
{
result += threadPool.getPoolSize();
}
return result;
}
/**
* @param threadPools : The pool array to check.
* @return the overall maximum pools size.
*/
private static long getMaximumPoolSize(ThreadPoolExecutor[] threadPools)
{
long result = 0;
for (ThreadPoolExecutor threadPool : threadPools)
{
result += threadPool.getMaximumPoolSize();
}
return result;
}
public static final class TaskWrapper implements Runnable
{
private final Runnable _runnable;
public TaskWrapper(Runnable runnable)
{
_runnable = runnable;
}
@Override
public void run()
{
_effectsScheduledThreadPool.purge();
_generalScheduledThreadPool.purge();
_aiScheduledThreadPool.purge();
_eventScheduledThreadPool.purge();
try
{
_runnable.run();
}
catch (RuntimeException e)
{
LOG.warning("Exception in a Runnable execution:" + e);
}
}
}
private static class SingletonHolder
{
protected static final ThreadPoolManager _instance = new ThreadPoolManager();
}
}
@@ -836,7 +836,7 @@ public abstract class AbstractAI implements Ctrl
// Create and Launch an AI Follow Task to execute every 1s
_followTarget = target;
_followTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FollowTask(), 5, FOLLOW_INTERVAL);
_followTask = ThreadPoolManager.scheduleAtFixedRate(new FollowTask(), 5, FOLLOW_INTERVAL);
}
/**
@@ -853,7 +853,7 @@ public abstract class AbstractAI implements Ctrl
}
_followTarget = target;
_followTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FollowTask(range), 5, ATTACK_FOLLOW_INTERVAL);
_followTask = ThreadPoolManager.scheduleAtFixedRate(new FollowTask(range), 5, ATTACK_FOLLOW_INTERVAL);
}
/**
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.GameTimeController;
@@ -301,7 +300,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}
@@ -400,7 +399,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
{
if ((_fearTime > 0) && (_fearTask == null))
{
_fearTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new FearTask(this, effector, start), 0, FEAR_TICKS, TimeUnit.SECONDS);
_fearTask = ThreadPoolManager.scheduleAtFixedRate(new FearTask(this, effector, start), 0, FEAR_TICKS * 1000); // seconds
_actor.startAbnormalVisualEffect(true, AbnormalVisualEffect.TURN_FLEE);
}
else
@@ -311,7 +311,7 @@ public class L2CharacterAI extends AbstractAI
if (_actor.getBowAttackEndTime() > GameTimeController.getInstance().getGameTicks())
{
ThreadPoolManager.getInstance().scheduleGeneral(new CastTask(_actor, skill, target), (_actor.getBowAttackEndTime() - GameTimeController.getInstance().getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
ThreadPoolManager.schedule(new CastTask(_actor, skill, target), (_actor.getBowAttackEndTime() - GameTimeController.getInstance().getGameTicks()) * GameTimeController.MILLIS_IN_TICK);
}
else
{
@@ -87,7 +87,7 @@ public class L2DoorAI extends L2CharacterAI
@Override
protected void onEvtAttacked(L2Character attacker)
{
ThreadPoolManager.getInstance().executeGeneral(new onEventAttackedDoorTask((L2DoorInstance) _actor, attacker));
ThreadPoolManager.execute(new onEventAttackedDoorTask((L2DoorInstance) _actor, attacker));
}
@Override
@@ -205,7 +205,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}
@@ -203,7 +203,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
// If not idle - create an AI task (schedule onEvtThink repeatedly)
if (_aiTask == null)
{
_aiTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 1000, 1000);
_aiTask = ThreadPoolManager.scheduleAtFixedRate(this, 1000, 1000);
}
}
@@ -295,7 +295,7 @@ public class L2SummonAI extends L2PlayableAI implements Runnable
{
if (_avoidTask == null)
{
_avoidTask = ThreadPoolManager.getInstance().scheduleAiAtFixedRate(this, 100, 100);
_avoidTask = ThreadPoolManager.scheduleAtFixedRate(this, 100, 100);
}
}
@@ -33,7 +33,7 @@ public class WarehouseCacheManager
protected WarehouseCacheManager()
{
ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new CacheScheduler(), 120000, 60000);
ThreadPoolManager.scheduleAtFixedRate(new CacheScheduler(), 120000, 60000);
}
public void addCacheTask(L2PcInstance pc)
@@ -345,7 +345,7 @@ public class ClanTable
public void scheduleRemoveClan(int clanId)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (getClan(clanId) == null)
{
@@ -422,11 +422,11 @@ public final class BotReportTable
c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) + 1);
}
ThreadPoolManager.getInstance().scheduleGeneral(new ResetPointTask(), c.getTimeInMillis() - System.currentTimeMillis());
ThreadPoolManager.schedule(new ResetPointTask(), c.getTimeInMillis() - System.currentTimeMillis());
}
catch (Exception e)
{
ThreadPoolManager.getInstance().scheduleGeneral(new ResetPointTask(), 24 * 3600 * 1000);
ThreadPoolManager.schedule(new ResetPointTask(), 24 * 3600 * 1000);
LOGGER.log(Level.WARNING, "BotReportTable: Could not properly schedule bot report points reset task. Scheduled in 24 hours.", e);
}
}
@@ -220,14 +220,14 @@ public class ItemTable
if ((raid.getFirstCommandChannelAttacked() != null) && !Config.AUTO_LOOT_RAIDS)
{
item.setOwnerId(raid.getFirstCommandChannelAttacked().getLeaderObjectId());
itemLootShedule = ThreadPoolManager.getInstance().scheduleGeneral(new ResetOwner(item), Config.LOOT_RAIDS_PRIVILEGE_INTERVAL);
itemLootShedule = ThreadPoolManager.schedule(new ResetOwner(item), Config.LOOT_RAIDS_PRIVILEGE_INTERVAL);
item.setItemLootShedule(itemLootShedule);
}
}
else if (!Config.AUTO_LOOT || ((reference instanceof L2EventMonsterInstance) && ((L2EventMonsterInstance) reference).eventDropOnGround()))
{
item.setOwnerId(actor.getObjectId());
itemLootShedule = ThreadPoolManager.getInstance().scheduleGeneral(new ResetOwner(item), 15000);
itemLootShedule = ThreadPoolManager.schedule(new ResetOwner(item), 15000);
item.setItemLootShedule(itemLootShedule);
}
}
@@ -53,7 +53,7 @@ public class BitSetIDFactory extends IdFactory
synchronized (BitSetIDFactory.class)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
ThreadPoolManager.scheduleAtFixedRate(new BitSetCapacityCheck(), 30000, 30000);
initialize();
}
_log.info(getClass().getSimpleName() + ": " + _freeIds.size() + " id's available.");
@@ -28,7 +28,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
@@ -102,7 +101,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
// Schedule autosave
if (!Config.ALT_MANOR_SAVE_ALL_ACTIONS)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this::storeMe, Config.ALT_MANOR_SAVE_PERIOD_RATE, Config.ALT_MANOR_SAVE_PERIOD_RATE, TimeUnit.HOURS);
ThreadPoolManager.scheduleAtFixedRate(this::storeMe, Config.ALT_MANOR_SAVE_PERIOD_RATE * 60 * 60 * 1000, Config.ALT_MANOR_SAVE_PERIOD_RATE * 60 * 60 * 1000);
}
// Send debug message
@@ -279,7 +278,7 @@ public final class CastleManorManager implements IXmlReader, IStorable
}
}
// Schedule mode change
ThreadPoolManager.getInstance().scheduleGeneral(this::changeMode, _nextModeChange.getTimeInMillis() - System.currentTimeMillis());
ThreadPoolManager.schedule(this::changeMode, _nextModeChange.getTimeInMillis() - System.currentTimeMillis());
}
public final void changeMode()
@@ -79,7 +79,7 @@ public class FishingChampionshipManager
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new finishChamp(), _enddate - System.currentTimeMillis());
ThreadPoolManager.schedule(new finishChamp(), _enddate - System.currentTimeMillis());
}
}
@@ -305,7 +305,7 @@ public class FishingChampionshipManager
pl.sendPacket(html);
refreshResult();
ThreadPoolManager.getInstance().scheduleGeneral(new needRefresh(), 60000);
ThreadPoolManager.schedule(new needRefresh(), 60000);
return;
}
@@ -471,7 +471,7 @@ public class FishingChampionshipManager
shutdown();
_log.info("FishingChampionshipManager : new event period start.");
ThreadPoolManager.getInstance().scheduleGeneral(new finishChamp(), _enddate - System.currentTimeMillis());
ThreadPoolManager.schedule(new finishChamp(), _enddate - System.currentTimeMillis());
}
}
@@ -204,25 +204,25 @@ public final class FourSepulchersManager
if ((currentTime >= _coolDownTimeEnd) && (currentTime < _entryTimeEnd)) // entry time check
{
clean();
_changeEntryTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeEntryTimeTask(), 0);
_changeEntryTimeTask = ThreadPoolManager.schedule(new FourSepulchersChangeEntryTimeTask(), 0);
_log.info(getClass().getSimpleName() + ": Beginning in Entry time");
}
else if ((currentTime >= _entryTimeEnd) && (currentTime < _warmUpTimeEnd)) // warmup time check
{
clean();
_changeWarmUpTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeWarmUpTimeTask(), 0);
_changeWarmUpTimeTask = ThreadPoolManager.schedule(new FourSepulchersChangeWarmUpTimeTask(), 0);
_log.info(getClass().getSimpleName() + ": Beginning in WarmUp time");
}
else if ((currentTime >= _warmUpTimeEnd) && (currentTime < _attackTimeEnd)) // attack time check
{
clean();
_changeAttackTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeAttackTimeTask(), 0);
_changeAttackTimeTask = ThreadPoolManager.schedule(new FourSepulchersChangeAttackTimeTask(), 0);
_log.info(getClass().getSimpleName() + ": Beginning in Attack time");
}
else
// else cooldown time and without cleanup because it's already implemented
{
_changeCoolDownTimeTask = ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeCoolDownTimeTask(), 0);
_changeCoolDownTimeTask = ThreadPoolManager.schedule(new FourSepulchersChangeCoolDownTimeTask(), 0);
_log.info(getClass().getSimpleName() + ": Beginning in Cooldown time");
}
}
@@ -109,7 +109,7 @@ public final class GrandBossManager implements IStorable
{
_log.log(Level.WARNING, "Error while initializing GrandBossManager: " + e.getMessage(), e);
}
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new GrandBossManagerStoreTask(), 5 * 60 * 1000, 5 * 60 * 1000);
ThreadPoolManager.scheduleAtFixedRate(new GrandBossManagerStoreTask(), 5 * 60 * 1000, 5 * 60 * 1000);
}
/**
@@ -86,7 +86,7 @@ public final class HandysBlockCheckerManager
{
holder.checkAndShuffle();
}
ThreadPoolManager.getInstance().executeGeneral(holder.getEvent().new StartEvent());
ThreadPoolManager.execute(holder.getEvent().new StartEvent());
}
else
{
@@ -345,7 +345,7 @@ public final class HandysBlockCheckerManager
private void schedulePenaltyRemoval(int objId)
{
ThreadPoolManager.getInstance().scheduleGeneral(new PenaltyRemoveTask(objId), 10000);
ThreadPoolManager.schedule(new PenaltyRemoveTask(objId), 10000);
}
/**
@@ -47,7 +47,7 @@ public final class ItemsOnGroundManager implements Runnable
{
if (Config.SAVE_DROPPED_ITEM_INTERVAL > 0)
{
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(this, Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
ThreadPoolManager.scheduleAtFixedRate(this, Config.SAVE_DROPPED_ITEM_INTERVAL, Config.SAVE_DROPPED_ITEM_INTERVAL);
}
load();
}
@@ -72,11 +72,11 @@ public final class MailManager
if (expiration < System.currentTimeMillis())
{
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msgId), 10000);
ThreadPoolManager.schedule(new MessageDeletionTask(msgId), 10000);
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msgId), expiration - System.currentTimeMillis());
ThreadPoolManager.schedule(new MessageDeletionTask(msgId), expiration - System.currentTimeMillis());
}
}
}
@@ -181,7 +181,7 @@ public final class MailManager
receiver.sendPacket(ExNoticePostArrived.valueOf(true));
}
ThreadPoolManager.getInstance().scheduleGeneral(new MessageDeletionTask(msg.getId()), msg.getExpiration() - System.currentTimeMillis());
ThreadPoolManager.schedule(new MessageDeletionTask(msg.getId()), msg.getExpiration() - System.currentTimeMillis());
}
public final void markAsReadInDb(int msgId)
@@ -110,7 +110,7 @@ public class PremiumManager
*/
private void startExpireTask(L2PcInstance player, long delay)
{
ScheduledFuture<?> task = ThreadPoolManager.getInstance().scheduleEvent(new PremiumExpireTask(player), delay);
ScheduledFuture<?> task = ThreadPoolManager.schedule(new PremiumExpireTask(player), delay);
expiretasks.put(player.getAccountName(), task);
}
@@ -186,7 +186,7 @@ public class RaidBossSpawnManager
time.setTimeInMillis(respawnTime);
_log.info(getClass().getSimpleName() + ": Updated " + boss.getName() + " respawn time to " + time.getTime());
_schedules.put(boss.getId(), ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(boss.getId()), respawnDelay));
_schedules.put(boss.getId(), ThreadPoolManager.schedule(new SpawnSchedule(boss.getId()), respawnDelay));
updateDb();
}
}
@@ -242,7 +242,7 @@ public class RaidBossSpawnManager
}
else
{
_schedules.put(bossId, ThreadPoolManager.getInstance().scheduleGeneral(new SpawnSchedule(bossId), respawnTime - Calendar.getInstance().getTimeInMillis()));
_schedules.put(bossId, ThreadPoolManager.schedule(new SpawnSchedule(bossId), respawnTime - Calendar.getInstance().getTimeInMillis()));
}
_spawns.put(bossId, spawnDat);
@@ -71,7 +71,7 @@ public class ServerRestartManager
if (lastRestart != null)
{
nextRestartTime = new SimpleDateFormat("HH:mm").format(lastRestart.getTime());
ThreadPoolManager.getInstance().scheduleGeneral(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
ThreadPoolManager.schedule(new ServerRestartTask(), lastDelay - (Config.SERVER_RESTART_SCHEDULE_COUNTDOWN * 1000));
_log.info("Scheduled server restart at " + lastRestart.getTime().toString() + ".");
}
}
@@ -102,7 +102,7 @@ public final class SoDManager
}
else
{
ThreadPoolManager.getInstance().scheduleEffect(new UpdateSoDStateTask(), Config.SOD_STAGE_2_LENGTH - timePast);
ThreadPoolManager.schedule(new UpdateSoDStateTask(), Config.SOD_STAGE_2_LENGTH - timePast);
}
break;
case 3:
@@ -116,7 +116,7 @@ public class SoIManager
spawnOpenedSeed();
DoorData.getInstance().getDoor(14240102).openMe();
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
closeSeed();
setCurrentStage(4);
@@ -275,7 +275,7 @@ public final class TerritoryWarManager implements Siegable
{
_scheduledEndTWTask.cancel(false);
}
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), 1000);
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), 1000);
}
else
{
@@ -283,7 +283,7 @@ public final class TerritoryWarManager implements Siegable
{
_scheduledStartTWTask.cancel(false);
}
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), 1000);
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), 1000);
}
}
@@ -1261,14 +1261,14 @@ public final class TerritoryWarManager implements Siegable
if (timeRemaining > 7200000)
{
_isRegistrationOver = false;
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining - 7200000); // Prepare task for 2h before TW start to end registration
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining - 7200000); // Prepare task for 2h before TW start to end registration
}
else if ((timeRemaining <= 7200000) && (timeRemaining > 1200000))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_TERRITORY_WAR_REQUEST_PERIOD_HAS_ENDED);
Broadcast.toAllOnlinePlayers(sm);
_isRegistrationOver = true;
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining - 1200000); // Prepare task for 20 mins left before TW start.
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining - 1200000); // Prepare task for 20 mins left before TW start.
}
else if ((timeRemaining <= 1200000) && (timeRemaining > 600000))
{
@@ -1277,7 +1277,7 @@ public final class TerritoryWarManager implements Siegable
_isTWChannelOpen = true;
_isRegistrationOver = true;
updatePlayerTWStateFlags(false);
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining - 600000); // Prepare task for 10 mins left before TW start.
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining - 600000); // Prepare task for 10 mins left before TW start.
}
else if ((timeRemaining <= 600000) && (timeRemaining > 300000))
{
@@ -1286,7 +1286,7 @@ public final class TerritoryWarManager implements Siegable
_isTWChannelOpen = true;
_isRegistrationOver = true;
updatePlayerTWStateFlags(false);
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining - 300000); // Prepare task for 5 mins left before TW start.
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining - 300000); // Prepare task for 5 mins left before TW start.
}
else if ((timeRemaining <= 300000) && (timeRemaining > 60000))
{
@@ -1295,7 +1295,7 @@ public final class TerritoryWarManager implements Siegable
_isTWChannelOpen = true;
_isRegistrationOver = true;
updatePlayerTWStateFlags(false);
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining - 60000); // Prepare task for 1 min left before TW start.
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining - 60000); // Prepare task for 1 min left before TW start.
}
else if ((timeRemaining <= 60000) && (timeRemaining > 0))
{
@@ -1304,15 +1304,15 @@ public final class TerritoryWarManager implements Siegable
_isTWChannelOpen = true;
_isRegistrationOver = true;
updatePlayerTWStateFlags(false);
_scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), timeRemaining); // Prepare task for TW start.
_scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), timeRemaining); // Prepare task for TW start.
}
else if ((timeRemaining + WARLENGTH) > 0)
{
_isTWChannelOpen = true;
_isRegistrationOver = true;
startTerritoryWar();
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), 1000); // Prepare task for TW end.
_scheduledRewardOnlineTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RewardOnlineParticipants(), 60000, 60000);
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), 1000); // Prepare task for TW end.
_scheduledRewardOnlineTask = ThreadPoolManager.scheduleAtFixedRate(new RewardOnlineParticipants(), 60000, 60000);
}
}
catch (Exception e)
@@ -1342,41 +1342,41 @@ public final class TerritoryWarManager implements Siegable
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_TERRITORY_WAR_WILL_END_IN_S1_HOUR_S);
sm.addInt(2);
announceToParticipants(sm, 0, 0);
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), timeRemaining - 3600000); // Prepare task for 1 hr left.
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), timeRemaining - 3600000); // Prepare task for 1 hr left.
}
else if ((timeRemaining <= 3600000) && (timeRemaining > 600000))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_TERRITORY_WAR_WILL_END_IN_S1_MINUTE_S);
sm.addInt((int) (timeRemaining / 60000));
announceToParticipants(sm, 0, 0);
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), timeRemaining - 600000); // Prepare task for 10 minute left.
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), timeRemaining - 600000); // Prepare task for 10 minute left.
}
else if ((timeRemaining <= 600000) && (timeRemaining > 300000))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_TERRITORY_WAR_WILL_END_IN_S1_MINUTE_S);
sm.addInt((int) (timeRemaining / 60000));
announceToParticipants(sm, 0, 0);
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), timeRemaining - 300000); // Prepare task for 5 minute left.
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), timeRemaining - 300000); // Prepare task for 5 minute left.
}
else if ((timeRemaining <= 300000) && (timeRemaining > 10000))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_TERRITORY_WAR_WILL_END_IN_S1_MINUTE_S);
sm.addInt((int) (timeRemaining / 60000));
announceToParticipants(sm, 0, 0);
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), timeRemaining - 10000); // Prepare task for 10 seconds count down
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), timeRemaining - 10000); // Prepare task for 10 seconds count down
}
else if ((timeRemaining <= 10000) && (timeRemaining > 0))
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_SECOND_S_TO_THE_END_OF_TERRITORY_WAR);
sm.addInt((int) (timeRemaining / 1000));
announceToParticipants(sm, 0, 0);
_scheduledEndTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleEndTWTask(), timeRemaining); // Prepare task for second count down
_scheduledEndTWTask = ThreadPoolManager.schedule(new ScheduleEndTWTask(), timeRemaining); // Prepare task for second count down
}
else
{
endTerritoryWar();
// _scheduledStartTWTask = ThreadPoolManager.getInstance().scheduleGeneral(new ScheduleStartTWTask(), 1000);
ThreadPoolManager.getInstance().scheduleGeneral(new closeTerritoryChannelTask(), 600000);
// _scheduledStartTWTask = ThreadPoolManager.schedule(new ScheduleStartTWTask(), 1000);
ThreadPoolManager.schedule(new closeTerritoryChannelTask(), 600000);
}
}
catch (Exception e)
@@ -271,7 +271,7 @@ public final class WalkingManager implements IXmlReader
npc.sendDebugMessage("Starting to move at route '" + routeName + "'");
npc.setIsRunning(node.runToLocation());
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, node);
walk.setWalkCheckTask(ThreadPoolManager.getInstance().scheduleAiAtFixedRate(new StartMovingTask(npc, routeName), 60000, 60000)); // start walk check task, for resuming walk after fight
walk.setWalkCheckTask(ThreadPoolManager.scheduleAtFixedRate(new StartMovingTask(npc, routeName), 60000, 60000)); // start walk check task, for resuming walk after fight
npc.getKnownList().startTrackingTask();
@@ -280,7 +280,7 @@ public final class WalkingManager implements IXmlReader
else
{
npc.sendDebugMessage("Failed to start moving along route '" + routeName + "', scheduled");
ThreadPoolManager.getInstance().scheduleGeneral(new StartMovingTask(npc, routeName), 60000);
ThreadPoolManager.schedule(new StartMovingTask(npc, routeName), 60000);
}
}
// walk was stopped due to some reason (arrived to node, script action, fight or something else), resume it
@@ -422,7 +422,7 @@ public final class WalkingManager implements IXmlReader
{
walk.setLastAction(System.currentTimeMillis());
}
ThreadPoolManager.getInstance().scheduleGeneral(new ArrivedTask(npc, walk), 100 + (node.getDelay() * 1000L));
ThreadPoolManager.schedule(new ArrivedTask(npc, walk), 100 + (node.getDelay() * 1000L));
}
/**
@@ -152,12 +152,12 @@ public class Lottery
if (_enddate > System.currentTimeMillis())
{
_isStarted = true;
ThreadPoolManager.getInstance().scheduleGeneral(new finishLottery(), _enddate - System.currentTimeMillis());
ThreadPoolManager.schedule(new finishLottery(), _enddate - System.currentTimeMillis());
if (_enddate > (System.currentTimeMillis() + (12 * MINUTE)))
{
_isSellingTickets = true;
ThreadPoolManager.getInstance().scheduleGeneral(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
ThreadPoolManager.schedule(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
}
return;
}
@@ -195,8 +195,8 @@ public class Lottery
_enddate = finishtime.getTimeInMillis();
}
ThreadPoolManager.getInstance().scheduleGeneral(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
ThreadPoolManager.getInstance().scheduleGeneral(new finishLottery(), _enddate - System.currentTimeMillis());
ThreadPoolManager.schedule(new stopSellingTickets(), _enddate - System.currentTimeMillis() - (10 * MINUTE));
ThreadPoolManager.schedule(new finishLottery(), _enddate - System.currentTimeMillis());
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement(INSERT_LOTTERY))
@@ -436,7 +436,7 @@ public class Lottery
_log.log(Level.WARNING, "Lottery: Could not store finished lottery data: " + e.getMessage(), e);
}
ThreadPoolManager.getInstance().scheduleGeneral(new startLottery(), MINUTE);
ThreadPoolManager.schedule(new startLottery(), MINUTE);
_number++;
_isStarted = false;
@@ -61,14 +61,14 @@ public final class FourSepulchersChangeAttackTimeTask implements Runnable
{
final Calendar inter = Calendar.getInstance();
inter.set(Calendar.MINUTE, (int) min);
ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersManagerSayTask(), inter.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
ThreadPoolManager.schedule(new FourSepulchersManagerSayTask(), inter.getTimeInMillis() - Calendar.getInstance().getTimeInMillis());
break;
}
}
}
else
{
ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersManagerSayTask(), 5 * 60400);
ThreadPoolManager.schedule(new FourSepulchersManagerSayTask(), 5 * 60400);
}
// searching time when attack time will be ended:
// counting difference between time when attack time ends and
@@ -83,7 +83,7 @@ public final class FourSepulchersChangeAttackTimeTask implements Runnable
interval = Config.FS_TIME_ATTACK * 60000L;
}
manager.setChangeCoolDownTimeTask(ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeCoolDownTimeTask(), interval));
manager.setChangeCoolDownTimeTask(ThreadPoolManager.schedule(new FourSepulchersChangeCoolDownTimeTask(), interval));
final ScheduledFuture<?> changeAttackTimeTask = manager.getChangeAttackTimeTask();
if (changeAttackTimeTask != null)
@@ -54,7 +54,7 @@ public final class FourSepulchersChangeCoolDownTimeTask implements Runnable
final long interval = time.getTimeInMillis() - Calendar.getInstance().getTimeInMillis();
manager.setChangeEntryTimeTask(ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeEntryTimeTask(), interval));
manager.setChangeEntryTimeTask(ThreadPoolManager.schedule(new FourSepulchersChangeEntryTimeTask(), interval));
final ScheduledFuture<?> changeCoolDownTimeTask = manager.getChangeCoolDownTimeTask();
if (changeCoolDownTimeTask != null)
@@ -40,8 +40,8 @@ public final class FourSepulchersChangeEntryTimeTask implements Runnable
final long interval = manager.isFirstTimeRun() ? manager.getEntrytTimeEnd() - Calendar.getInstance().getTimeInMillis() : Config.FS_TIME_ENTRY * 60000L;
// launching saying process...
ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersManagerSayTask(), 0);
manager.setChangeWarmUpTimeTask(ThreadPoolManager.getInstance().scheduleEffect(new FourSepulchersChangeWarmUpTimeTask(), interval));
ThreadPoolManager.schedule(new FourSepulchersManagerSayTask(), 0);
manager.setChangeWarmUpTimeTask(ThreadPoolManager.schedule(new FourSepulchersChangeWarmUpTimeTask(), interval));
final ScheduledFuture<?> changeEntryTimeTask = manager.getChangeEntryTimeTask();
if (changeEntryTimeTask != null)
@@ -39,7 +39,7 @@ public final class FourSepulchersChangeWarmUpTimeTask implements Runnable
manager.setIsCoolDownTime(false);
final long interval = manager.isFirstTimeRun() ? manager.getWarmUpTimeEnd() - Calendar.getInstance().getTimeInMillis() : Config.FS_TIME_WARMUP * 60000L;
manager.setChangeAttackTimeTask(ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeAttackTimeTask(), interval));
manager.setChangeAttackTimeTask(ThreadPoolManager.schedule(new FourSepulchersChangeAttackTimeTask(), interval));
final ScheduledFuture<?> changeWarmUpTimeTask = manager.getChangeWarmUpTimeTask();
if (changeWarmUpTimeTask != null)
@@ -43,7 +43,7 @@ public final class FourSepulchersManagerSayTask implements Runnable
// cannot be
// more than
// 59
ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersManagerSayTask(), 5 * 60000);
ThreadPoolManager.schedule(new FourSepulchersManagerSayTask(), 5 * 60000);
}
// attack time ending chat
else if ((tmp.get(Calendar.MINUTE) + 5) >= Config.FS_TIME_ATTACK)
@@ -274,7 +274,7 @@ public class AutoSpawnHandler
if (isActive)
{
final AutoSpawner rs = new AutoSpawner(objectId);
spawnTask = spawnInst._desDelay > 0 ? ThreadPoolManager.getInstance().scheduleEffectAtFixedRate(rs, spawnInst._initDelay, spawnInst._resDelay) : ThreadPoolManager.getInstance().scheduleEffect(rs, spawnInst._initDelay);
spawnTask = spawnInst._desDelay > 0 ? ThreadPoolManager.scheduleAtFixedRate(rs, spawnInst._initDelay, spawnInst._resDelay) : ThreadPoolManager.schedule(rs, spawnInst._initDelay);
_runningSpawns.put(objectId, spawnTask);
}
else
@@ -285,7 +285,7 @@ public class AutoSpawnHandler
{
spawnTask.cancel(false);
}
ThreadPoolManager.getInstance().scheduleEffect(rd, 0);
ThreadPoolManager.schedule(rd, 0);
}
spawnInst.setSpawnActive(isActive);
}
@@ -489,7 +489,7 @@ public class AutoSpawnHandler
// If there is no despawn time, do not create a despawn task.
if (spawnInst.getDespawnDelay() > 0)
{
ThreadPoolManager.getInstance().scheduleAi(new AutoDespawner(_objectId), spawnInst.getDespawnDelay() - 1000);
ThreadPoolManager.schedule(new AutoDespawner(_objectId), spawnInst.getDespawnDelay() - 1000);
}
}
catch (Exception e)
@@ -1308,7 +1308,7 @@ public final class CharEffectList
return;
}
// Schedule the icon update packets 500miliseconds ahead, so it can gather-up most of the changes.
_effectIconsUpdate = ThreadPoolManager.getInstance().scheduleGeneral(() ->
_effectIconsUpdate = ThreadPoolManager.schedule(() ->
{
AbnormalStatusUpdate asu = null;
PartySpelled ps = null;
@@ -352,7 +352,7 @@ public class CursedWeapon implements INamable
{
_player.stopTransformation(true);
ThreadPoolManager.getInstance().scheduleGeneral(() -> TransformData.getInstance().transformPlayer(transformationId, _player), 500);
ThreadPoolManager.schedule(() -> TransformData.getInstance().transformPlayer(transformationId, _player), 500);
}
else
{
@@ -378,7 +378,7 @@ public class CursedWeapon implements INamable
}
else
{
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
_removeTask = ThreadPoolManager.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
}
}
@@ -391,7 +391,7 @@ public class CursedWeapon implements INamable
// Start the Life Task
_endTime = System.currentTimeMillis() + (_duration * 60000L);
_removeTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
_removeTask = ThreadPoolManager.scheduleAtFixedRate(new RemoveTask(), _durationLost * 12000L, _durationLost * 12000L);
return true;
}
@@ -84,6 +84,6 @@ public class DropProtection implements Runnable
throw new NullPointerException("Trying to protect dropped item to null owner");
}
_task = ThreadPoolManager.getInstance().scheduleGeneral(this, PROTECTED_MILLIS_TIME);
_task = ThreadPoolManager.schedule(this, PROTECTED_MILLIS_TIME);
}
}
@@ -359,7 +359,7 @@ public class L2Party extends AbstractPlayerGroup
if (_positionBroadcastTask == null)
{
_positionBroadcastTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(() ->
_positionBroadcastTask = ThreadPoolManager.scheduleAtFixedRate(() ->
{
if (_positionPacket == null)
{
@@ -993,7 +993,7 @@ public class L2Party extends AbstractPlayerGroup
}
_changeRequestDistributionType = partyDistributionType;
_changeDistributionTypeAnswers = new HashSet<>();
_changeDistributionTypeRequestTask = ThreadPoolManager.getInstance().scheduleGeneral(() -> finishLootRequest(false), PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT.toMillis());
_changeDistributionTypeRequestTask = ThreadPoolManager.schedule(() -> finishLootRequest(false), PARTY_DISTRIBUTION_TYPE_REQUEST_TIMEOUT.toMillis());
broadcastToPartyMembers(getLeader(), new ExAskModifyPartyLooting(getLeader().getName(), partyDistributionType));
@@ -123,7 +123,7 @@ public class L2Request
{
_isRequestor = isRequestor;
_isAnswerer = !isRequestor;
ThreadPoolManager.getInstance().scheduleGeneral(() -> clear(), REQUEST_TIMEOUT * 1000);
ThreadPoolManager.schedule(() -> clear(), REQUEST_TIMEOUT * 1000);
}
/**
@@ -446,7 +446,7 @@ public class L2Spawn implements IPositionable, IIdentifiable, INamable
// Create a new SpawnTask to launch after the respawn Delay
// ClientScheduler.getInstance().scheduleLow(new SpawnTask(npcId), _respawnDelay);
ThreadPoolManager.getInstance().scheduleGeneral(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
ThreadPoolManager.schedule(new SpawnTask(oldNpc), hasRespawnRandom() ? Rnd.get(_respawnMinDelay, _respawnMaxDelay) : _respawnMinDelay);
}
}
@@ -330,7 +330,7 @@ public final class L2WorldRegion
}
// then, set a timer to activate the neighbors
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
_neighborsTask = ThreadPoolManager.schedule(new NeighborsTask(true), 1000 * Config.GRID_NEIGHBOR_TURNON_TIME);
}
}
@@ -350,7 +350,7 @@ public final class L2WorldRegion
// start a timer to "suggest" a deactivate to self and neighbors.
// suggest means: first check if a neighbor has L2PcInstances in it. If not, deactivate.
_neighborsTask = ThreadPoolManager.getInstance().scheduleGeneral(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
_neighborsTask = ThreadPoolManager.schedule(new NeighborsTask(false), 1000 * Config.GRID_NEIGHBOR_TURNOFF_TIME);
}
}
@@ -257,7 +257,7 @@ public class L2Attackable extends L2Npc
{
_commandChannelTimer = new CommandChannelTimer(this);
_commandChannelLastAttack = System.currentTimeMillis();
ThreadPoolManager.getInstance().scheduleGeneral(_commandChannelTimer, 10000); // check for last attack
ThreadPoolManager.schedule(_commandChannelTimer, 10000); // check for last attack
_firstCommandChannelAttacked.broadcastPacket(new CreatureSay(0, ChatType.PARTYROOM_ALL, "", "You have looting rights!")); // TODO: retail msg
}
}
@@ -845,7 +845,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (getCurrentMp() < mpConsume)
{
// If L2PcInstance doesn't have enough MP, stop the attack
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(SystemMessageId.NOT_ENOUGH_MP);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
@@ -863,7 +863,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
else
{
// Cancel the action because the bow can't be re-use at this moment
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), 1000);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
@@ -1127,7 +1127,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Notify AI with EVT_READY_TO_ACT
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk + reuse);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_READY_TO_ACT), timeAtk + reuse);
}
finally
{
@@ -1193,7 +1193,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
// Calculate and set the disable delay of the bow in function of the Attack Speed
_disableBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getInstance().getGameTicks();
@@ -1263,7 +1263,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
// Calculate and set the disable delay of the bow in function of the Attack Speed
_disableBowAttackEndTime = ((sAtk + reuse) / GameTimeController.MILLIS_IN_TICK) + GameTimeController.getInstance().getGameTicks();
@@ -1333,10 +1333,10 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority for hit 1
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk / 2);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk / 2);
// Create a new hit task with Medium priority for hit 2 with a higher delay
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage2, crit2, miss2, attack.hasSoulshot(), shld2), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage2, crit2, miss2, attack.hasSoulshot(), shld2), sAtk);
// Add those hits to the Server-Client packet Attack
attack.addHit(target, damage1, miss1, crit1, shld1);
@@ -1513,7 +1513,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
// Create a new hit task with Medium priority
ThreadPoolManager.getInstance().scheduleAi(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
ThreadPoolManager.schedule(new HitTask(this, target, damage1, crit1, miss1, attack.hasSoulshot(), shld1), sAtk);
// Add this hit to the Server-Client packet Attack
attack.addHit(target, damage1, miss1, crit1, shld1);
@@ -1775,7 +1775,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// queue herbs and potions
if (isCastingSimultaneouslyNow() && simultaneously)
{
ThreadPoolManager.getInstance().scheduleAi(() -> beginCast(skill, simultaneously, target, targets), 100);
ThreadPoolManager.schedule(() -> beginCast(skill, simultaneously, target, targets), 100);
return;
}
@@ -1929,7 +1929,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Before start AI Cast Broadcast Fly Effect is Need
if (skill.getFlyType() != null)
{
ThreadPoolManager.getInstance().scheduleEffect(new FlyToLocationTask(this, target, skill), 50);
ThreadPoolManager.schedule(new FlyToLocationTask(this, target, skill), 50);
}
final MagicUseTask mut = new MagicUseTask(this, targets, skill, skillTime, simultaneously);
@@ -1959,7 +1959,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task MagicUseTask to launch the MagicSkill at the end of the casting time (skillTime)
// For client animation reasons (party buffs especially) 400 ms before!
_skillCast2 = ThreadPoolManager.getInstance().scheduleEffect(mut, skillTime - 400);
_skillCast2 = ThreadPoolManager.schedule(mut, skillTime - 400);
}
else
{
@@ -1972,7 +1972,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task MagicUseTask to launch the MagicSkill at the end of the casting time (skillTime)
// For client animation reasons (party buffs especially) 400 ms before!
_skillCast = ThreadPoolManager.getInstance().scheduleEffect(mut, skillTime - 400);
_skillCast = ThreadPoolManager.schedule(mut, skillTime - 400);
}
}
else
@@ -4093,7 +4093,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
if (distFraction > 1)
{
ThreadPoolManager.getInstance().executeAi(() ->
ThreadPoolManager.execute(() ->
{
try
{
@@ -4555,7 +4555,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task to notify the AI that L2Character arrives at a check point of the movement
if ((ticksToMove * GameTimeController.MILLIS_IN_TICK) > 3000)
{
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
}
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive
@@ -4636,7 +4636,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// Create a task to notify the AI that L2Character arrives at a check point of the movement
if ((ticksToMove * GameTimeController.MILLIS_IN_TICK) > 3000)
{
ThreadPoolManager.getInstance().scheduleAi(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
ThreadPoolManager.schedule(new NotifyAITask(this, CtrlEvent.EVT_ARRIVED_REVALIDATE), 2000);
}
// the CtrlEvent.EVT_ARRIVED will be sent when the character will actually arrive
@@ -5474,7 +5474,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
}
else
{
_skillCast = ThreadPoolManager.getInstance().scheduleEffect(mut, 400);
_skillCast = ThreadPoolManager.schedule(mut, 400);
}
}
@@ -5603,11 +5603,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
if (mut.isSimultaneous())
{
_skillCast2 = ThreadPoolManager.getInstance().scheduleEffect(mut, 0);
_skillCast2 = ThreadPoolManager.schedule(mut, 0);
}
else
{
_skillCast = ThreadPoolManager.getInstance().scheduleEffect(mut, 0);
_skillCast = ThreadPoolManager.schedule(mut, 0);
}
}
}
@@ -5674,7 +5674,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
// DON'T USE : Recursive call to useMagic() method
// currPlayer.useMagic(queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed());
ThreadPoolManager.getInstance().executeGeneral(new QueuedMagicUseTask(currPlayer, queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed()));
ThreadPoolManager.execute(new QueuedMagicUseTask(currPlayer, queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed()));
}
}
@@ -314,7 +314,7 @@ public class L2Npc extends L2Character
// Create a RandomAnimation Task that will be launched after the calculated delay
_rAniTask = new RandomAnimationTask(this);
ThreadPoolManager.getInstance().scheduleGeneral(_rAniTask, interval);
ThreadPoolManager.schedule(_rAniTask, interval);
}
/**
@@ -1498,7 +1498,7 @@ public class L2Npc extends L2Character
public L2Npc scheduleDespawn(long delay)
{
ThreadPoolManager.getInstance().scheduleGeneral(() ->
ThreadPoolManager.schedule(() ->
{
if (!isDecayed())
{

Some files were not shown because too many files have changed in this diff Show More