Перейти к содержанию
Авторизация  
shadowcat

Проход На Хб

Рекомендуемые сообщения

Доброго времени суток, и это снова я со своими проблемами=)

При прохождении квеста на открытие хб, возникает такая проблема. Когда уже все сделано и настает время телепорта к Байлору игроков телепортирует в комнату и они там могут бесконечно стоять, но босс так и не появляется. Двигаться игроки тоже не могут. Гугл сказал только что такая проблема была частая, а вот как решать никто не знает.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

ai комнаты/квеста/рб смотреть, править если он вообще есть.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Вообще там в комнате ZoneListner должен быть, и при входе и выполнении всех условий запускать механизм инстанса

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Вообще там в комнате ZoneListner должен быть, и при входе и выполнении всех условий запускать механизм инстанса

Насчет ZoneListen вообще не вкурсе если честно что такое.

Как думаете ошибку искать тут?=)

 

 

 

package bosses;

import bosses.EpicBossState.State;

import l2p.Config;

import l2p.common.ThreadPoolManager;

import l2p.extensions.scripts.Functions;

import l2p.extensions.scripts.ScriptFile;

import l2p.gameserver.geodata.GeoEngine;

import l2p.gameserver.instancemanager.ZoneManager;

import l2p.gameserver.model.L2Character;

import l2p.gameserver.model.L2Player;

import l2p.gameserver.model.L2Zone;

import l2p.gameserver.model.L2Zone.ZoneType;

import l2p.gameserver.model.Reflection;

import l2p.gameserver.model.instances.L2NpcInstance;

import l2p.gameserver.serverpackets.FlyToLocation;

import l2p.gameserver.serverpackets.SocialAction;

import l2p.gameserver.serverpackets.FlyToLocation.FlyType;

import l2p.gameserver.tables.NpcTable;

import l2p.gameserver.tables.ReflectionTable;

import l2p.gameserver.templates.L2NpcTemplate;

import l2p.util.GArray;

import l2p.util.Location;

import l2p.util.Log;

import l2p.util.Rnd;

import l2p.util.Util;

import java.util.Date;

import java.util.concurrent.ScheduledFuture;

public class BaylorManager extends Functions implements ScriptFile

{

public static L2NpcInstance spawn(Location loc, int npcId)

{

L2NpcTemplate template = NpcTable.getTemplate(loc.id);

L2NpcInstance npc = template.getNewInstance();

npc.setSpawnedLoc(loc);

npc.onSpawn();

npc.setHeading(loc.h);

npc.setXYZInvisible(loc);

npc.setReflection(currentReflection);

npc.spawnMe();

return npc;

}

private static class ActivityTimeEnd implements Runnable

{

public void run()

{

setIntervalEndTask();

}

}

private static class BaylorSpawn implements Runnable

{

private int _npcId;

private Location _pos = new Location(153569, 142075, -12711, 44732);

public BaylorSpawn(int npcId)

{

_npcId = npcId;

}

public void run()

{

switch(_npcId)

{

case CrystalPrisonGuard:

Reflection ref = ReflectionTable.getInstance().get(currentReflection);

for(int doorId : doors)

{

ref.openDoor(doorId);

}

for(int i = 0; i < _crystalineLocation.length; i++)

{

_crystaline = spawn(_crystalineLocation, CrystalPrisonGuard);

_crystaline.setRunning();

_crystaline.moveToLocation(_pos, 300, false);

ThreadPoolManager.getInstance().scheduleGeneral(new Social(_crystaline, 2), 15000);

}

break;

case Baylor:

Dying = false;

_baylor = spawn(new Location(153569, 142075, -12732, 59864), Baylor);

_state.setRespawnDate(getRespawnInterval() + FWBA_ACTIVITYTIMEOFMOBS);

_state.setState(EpicBossState.State.ALIVE);

_state.update();

if(_socialTask != null)

{

_socialTask.cancel(true);

_socialTask = null;

}

_socialTask = ThreadPoolManager.getInstance().scheduleGeneral(new Social(_baylor, 1), 500);

if(_endSceneTask != null)

{

_endSceneTask.cancel(true);

_endSceneTask = null;

}

_endSceneTask = ThreadPoolManager.getInstance().scheduleGeneral(new EndScene(), 23000);

if(_activityTimeEndTask != null)

{

_activityTimeEndTask.cancel(true);

_activityTimeEndTask = null;

}

_activityTimeEndTask = ThreadPoolManager.getInstance().scheduleGeneral(new ActivityTimeEnd(), FWBA_ACTIVITYTIMEOFMOBS);

break;

}

}

}

// Interval end.

private static class IntervalEnd implements Runnable

{

public void run()

{

_state.setState(EpicBossState.State.NOTSPAWN);

_state.update();

}

}

private static class Social implements Runnable

{

private int _action;

private L2NpcInstance _npc;

public Social(L2NpcInstance npc, int actionId)

{

_npc = npc;

_action = actionId;

}

public void run()

{

_npc.broadcastPacket(new SocialAction(_npc.getObjectId(), _action));

}

}

private static class EndScene implements Runnable

{

public void run()

{

for(L2Player player : getPlayersInside())

{

player.unblock();

if(_baylor != null)

{

double angle = Util.convertHeadingToDegree(_baylor.getHeading());

double radian = Math.toRadians(angle - 90);

int x1 = -(int) (Math.sin(radian) * 600);

int y1 = (int) (Math.cos(radian) * 600);

Location flyLoc = GeoEngine.moveCheck(player.getX(), player.getY(), player.getZ(), player.getX() + x1, player.getY() + y1, player.getReflection().getGeoIndex());

player.setLoc(flyLoc);

player.broadcastPacket(new FlyToLocation(player, flyLoc, FlyType.THROW_HORIZONTAL));

}

}

for(int i = 0; i < _crystaline.length; i++)

{

L2NpcInstance npc = _crystaline;

if(npc != null)

{

npc.reduceCurrentHp(npc.getMaxHp() + 1, npc, null, true, true, false, false);

}

}

}

}

private static final int Baylor = 29099;

private static final int CrystalPrisonGuard = 29100;

private static final int Parme = 32271;

private static final int Oracle = 32273;

private static final Location _crystalineLocation[] = {new Location(154404, 140596, -12711, 44732),

new Location(153574, 140402, -12711, 44732), new Location(152105, 141230, -12711, 44732),

new Location(151877, 142095, -12711, 44732), new Location(152109, 142920, -12711, 44732),

new Location(152730, 143555, -12711, 44732), new Location(154439, 143538, -12711, 44732),

new Location(155246, 142068, -12711, 44732)};

private static final Location _baylorChestLocation[] = {new Location(153763, 142075, -12741, 64792),

new Location(153701, 141942, -12741, 57739), new Location(153573, 141894, -12741, 49471),

new Location(153445, 141945, -12741, 41113), new Location(153381, 142076, -12741, 32767),

new Location(153441, 142211, -12741, 25730), new Location(153573, 142260, -12741, 16185),

new Location(153706, 142212, -12741, 7579), new Location(153571, 142860, -12741, 16716),

new Location(152783, 142077, -12741, 32176), new Location(153571, 141274, -12741, 49072),

new Location(154365, 142073, -12741, 64149), new Location(154192, 142697, -12741, 7894),

new Location(152924, 142677, -12741, 25072), new Location(152907, 141428, -12741, 39590),

new Location(154243, 141411, -12741, 55500)};

private static final int[] doors = {24220009, 24220011, 24220012, 24220014, 24220015, 24220016, 24220017, 24220019};

// Instance of monsters

private static L2NpcInstance[] _crystaline = new L2NpcInstance[8];

private static L2NpcInstance _baylor;

// Tasks

private static ScheduledFuture<?> _intervalEndTask = null;

private static ScheduledFuture<?> _activityTimeEndTask = null;

private static ScheduledFuture<?> _socialTask = null;

private static ScheduledFuture<?> _endSceneTask = null;

// State of baylor's lair.

private static boolean _isAlreadyEnteredOtherParty = false;

private static EpicBossState _state;

private static L2Zone _zone;

private static final int FWBA_ACTIVITYTIMEOFMOBS = 120 * 60000;

private static final int FWBA_FIXINTERVALOFBAYLORSPAWN = 1440 * 60000;

private static final int FWBA_RANDOMINTERVALOFBAYLORSPAWN = 1440 * 60000;

private static final boolean FWBA_ENABLESINGLEPLAYER = false;

private static boolean Dying = false;

private static long currentReflection;

// Whether it is permitted to enter the baylor's lair is confirmed.

public static int canIntoBaylorLair(L2Player pc)

{

if(pc.isGM())

{

return 0;

}

if(!FWBA_ENABLESINGLEPLAYER && !pc.isInParty())

{

return 4;

}

else if(_isAlreadyEnteredOtherParty)

{

return 2;

}

else if(_state.getState().equals(EpicBossState.State.NOTSPAWN))

{

return 0;

}

else if(_state.getState().equals(EpicBossState.State.ALIVE) || _state.getState().equals(EpicBossState.State.DEAD))

{

return 1;

}

else if(_state.getState().equals(EpicBossState.State.INTERVAL))

{

return 3;

}

else

{

return 0;

}

}

private synchronized static void checkAnnihilated()

{

if(isPlayersAnnihilated())

{

setIntervalEndTask();

}

}

// Teleporting player to baylor's lair.

public synchronized static void entryToBaylorLair(L2Player pc)

{

currentReflection = pc.getReflection().getId();

ReflectionTable.getInstance().get(currentReflection).closeDoor(24220008);

ThreadPoolManager.getInstance().scheduleGeneral(new BaylorSpawn(CrystalPrisonGuard), 20000);

ThreadPoolManager.getInstance().scheduleGeneral(new BaylorSpawn(Baylor), 40000);

if(pc.getParty() == null)

{

pc.teleToLocation(153569 + Rnd.get(-80, 80), 142075 + Rnd.get(-80, 80), -12732);

pc.block();

}

else

{

GArray<L2Player> members = new GArray<L2Player>(); // list of member of teleport candidate.

for(L2Player mem : pc.getParty().getPartyMembers())

// teleporting it within alive and the range of recognition of the leader of the party.

{

if(!mem.isDead() && mem.isInRange(pc, 1500))

{

members.add(mem);

}

}

for(L2Player mem : members)

{

mem.teleToLocation(153569 + Rnd.get(-80, 80), 142075 + Rnd.get(-80, 80), -12732);

mem.block();

}

}

_isAlreadyEnteredOtherParty = true;

}

private static GArray<L2Player> getPlayersInside()

{

GArray<L2Player> result = new GArray<L2Player>();

for(L2Player player : getZone().getInsidePlayers())

{

if(player.getReflection().getId() == currentReflection)

{

result.add(player);

}

}

return result;

}

private static int getRespawnInterval()

{

return (int) (Config.ALT_EPIC_RESPAWN_MULTIPLIER * (FWBA_FIXINTERVALOFBAYLORSPAWN + Rnd.get(0, FWBA_RANDOMINTERVALOFBAYLORSPAWN)));

}

public static L2Zone getZone()

{

return _zone;

}

private static void init()

{

_state = new EpicBossState(Baylor);

_zone = ZoneManager.getInstance().getZoneById(ZoneType.epic, 702101, false);

_isAlreadyEnteredOtherParty = false;

Log.add("BaylorManager : State of Baylor is " + _state.getState() + ".", "bosses");

if(!_state.getState().equals(EpicBossState.State.NOTSPAWN))

{

setIntervalEndTask();

}

Date dt = new Date(_state.getRespawnDate());

Log.add("BaylorManager : Next spawn date of Baylor is " + dt + ".", "bosses");

Log.add("BaylorManager : Init BaylorManager.", "bosses");

}

private static boolean isPlayersAnnihilated()

{

for(L2Player pc : getPlayersInside())

{

if(!pc.isDead())

{

return false;

}

}

return true;

}

private static void onBaylorDie()

{

if(Dying)

{

return;

}

Dying = true;

_state.setRespawnDate(getRespawnInterval());

_state.setState(EpicBossState.State.INTERVAL);

_state.update();

Log.add("Baylor died", "bosses");

for(Location loc : _baylorChestLocation)

{

spawn(loc, 29116 + Rnd.get(2));

}

spawn(new Location(153570, 142067, -9727, 55500), Parme);

spawn(new Location(153569, 142075, -12732, 55500), Oracle);

startCollapse();

}

public static void OnDie(L2Character self, L2Character killer)

{

if(self == null || !_isAlreadyEnteredOtherParty || self.getReflection().getId() != currentReflection)

{

return;

}

if(self.isPlayer() && _state != null && _state.getState() == State.ALIVE && _zone != null && _zone.checkIfInZone(self.getX(), self.getY()))

{

checkAnnihilated();

}

else if(self.isNpc() && self.getNpcId() == Baylor)

{

onBaylorDie();

}

}

// Task of interval of baylor spawn.

private static void setIntervalEndTask()

{

setUnspawn();

if(_state.getState().equals(EpicBossState.State.ALIVE))

{

_state.setState(EpicBossState.State.NOTSPAWN);

_state.update();

return;

}

if(!_state.getState().equals(EpicBossState.State.INTERVAL))

{

_state.setRespawnDate(getRespawnInterval());

_state.setState(EpicBossState.State.INTERVAL);

_state.update();

}

_intervalEndTask = ThreadPoolManager.getInstance().scheduleGeneral(new IntervalEnd(), _state.getInterval());

}

// Clean up Baylor's lair.

private static void setUnspawn()

{

if(!_isAlreadyEnteredOtherParty)

{

return;

}

_isAlreadyEnteredOtherParty = false;

startCollapse();

if(_baylor != null)

{

_baylor.deleteMe();

}

_baylor = null;

for(L2NpcInstance npc : _crystaline)

{

if(npc != null)

{

npc.deleteMe();

}

}

if(_intervalEndTask != null)

{

_intervalEndTask.cancel(false);

_intervalEndTask = null;

}

if(_activityTimeEndTask != null)

{

_activityTimeEndTask.cancel(false);

_activityTimeEndTask = null;

}

}

private static void startCollapse()

{

if(currentReflection > 0)

{

Reflection reflection = ReflectionTable.getInstance().get(currentReflection);

if(reflection != null)

{

reflection.startCollapseTimer(300000);

}

currentReflection = 0;

}

}

public void onLoad()

{

init();

}

public void onReload()

{

setUnspawn();

}

public void onShutdown()

{

}

}

 

 

 

Изменено пользователем shadowcat

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

ThreadPoolManager.getInstance().scheduleGeneral(new BaylorSpawn(CrystalPrisonGuard), 20000);

ThreadPoolManager.getInstance().scheduleGeneral(new BaylorSpawn(Baylor), 40000);

 

2 строки запускающие 2 runable метода. В месте где это находится и надо смотреть

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Посмотрел, но толкового ничего не нашел=(

package l2p.common;

 

import java.util.concurrent.LinkedBlockingQueue;

import java.util.concurrent.RejectedExecutionException;

import java.util.concurrent.ScheduledFuture;

import java.util.concurrent.ScheduledThreadPoolExecutor;

import java.util.concurrent.SynchronousQueue;

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.Logger;

 

import l2p.Config;

import l2p.Server;

import l2p.extensions.network.MMOConnection;

import l2p.extensions.network.ReceivablePacket;

import l2p.gameserver.network.L2GameClient;

 

public class ThreadPoolManager

{

private static final Logger _log = Logger.getLogger(ThreadPoolManager.class.getName());

private static ThreadPoolManager _instance;

private final ScheduledThreadPoolExecutor _generalScheduledThreadPool;

private ScheduledThreadPoolExecutor _moveScheduledThreadPool, _npcAiScheduledThreadPool, _playerAiScheduledThreadPool;

private ThreadPoolExecutor _pathfindThreadPool, _ioPacketsThreadPool;

private final ThreadPoolExecutor _LsGsExecutor;

public ThreadPoolExecutor _generalPacketsThreadPool;

private boolean _shutdown;

 

public static ThreadPoolManager getInstance()

{

if(_instance == null)

{

_instance = new ThreadPoolManager();

}

return _instance;

}

 

private ThreadPoolManager()

{

_generalScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_GENERAL, new PriorityThreadFactory("GerenalSTPool", Thread.NORM_PRIORITY + 1));

_generalScheduledThreadPool.setKeepAliveTime(1, TimeUnit.SECONDS);

_generalScheduledThreadPool.allowCoreThreadTimeOut(true);

if(Server.SERVER_MODE == Server.MODE_GAMESERVER || Server.SERVER_MODE == Server.MODE_COMBOSERVER)

{

_moveScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_MOVE, new PriorityThreadFactory("MoveSTPool", Thread.NORM_PRIORITY + 3));

_npcAiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.NPC_AI_MAX_THREAD, new PriorityThreadFactory("NpcAISTPool", Thread.NORM_PRIORITY - 2));

_playerAiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.PLAYER_AI_MAX_THREAD, new PriorityThreadFactory("PlayerAISTPool", Thread.NORM_PRIORITY + 2));

_pathfindThreadPool = new ThreadPoolExecutor(Config.THREAD_P_PATHFIND, Config.THREAD_P_PATHFIND, 1, TimeUnit.SECONDS, new LinkedBlockingQueue(), new PriorityThreadFactory("Pathfind Pool", Thread.NORM_PRIORITY));

_moveScheduledThreadPool.setKeepAliveTime(1, TimeUnit.SECONDS);

_npcAiScheduledThreadPool.setKeepAliveTime(1, TimeUnit.SECONDS);

_playerAiScheduledThreadPool.setKeepAliveTime(1, TimeUnit.SECONDS);

_moveScheduledThreadPool.allowCoreThreadTimeOut(true);

_npcAiScheduledThreadPool.allowCoreThreadTimeOut(true);

_playerAiScheduledThreadPool.allowCoreThreadTimeOut(true);

_pathfindThreadPool.allowCoreThreadTimeOut(true);

_ioPacketsThreadPool = new ThreadPoolExecutor(Config.URGENT_PACKET_THREAD_CORE_SIZE, Integer.MAX_VALUE, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new PriorityThreadFactory("High Packet Pool", Thread.NORM_PRIORITY + 3));

if(Config.GENERAL_PACKET_THREAD_CORE_SIZE == -1)

{

_generalPacketsThreadPool = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 15L, TimeUnit.SECONDS, new SynchronousQueue(), new PriorityThreadFactory("Normal Packet Pool", Thread.NORM_PRIORITY + 3));

}

else

{

_generalPacketsThreadPool = new ThreadPoolExecutor(Config.GENERAL_PACKET_THREAD_CORE_SIZE, Config.GENERAL_PACKET_THREAD_CORE_SIZE * 2, 120L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new PriorityThreadFactory("Normal Packet Pool", Thread.NORM_PRIORITY + 3));

}

}

_LsGsExecutor = new ThreadPoolExecutor(1, 5, 5L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new PriorityThreadFactory("LS/GS Communications", Thread.NORM_PRIORITY + 3));

}

 

public ScheduledFuturescheduleGeneral(Runnable r, long delay)

{

try

{

if(delay < 0)

{

delay = 0;

}

return _generalScheduledThreadPool.schedule(r, delay, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("GeneralThreadPool: Failed schedule task!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

public ScheduledFuturescheduleMove(Runnable r, long delay)

{

try

{

return _moveScheduledThreadPool.schedule(r, delay > 0 ? delay : 1, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("MoveThreadPool: Failed schedule task!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

public ScheduledFuturescheduleGeneralAtFixedRate(Runnable r, long initial, long delay)

{

try

{

if(delay <= 0)

{

delay = 1;

}

return _generalScheduledThreadPool.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("GeneralThreadPool: Failed schedule task at fixed rate!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

public ScheduledFuturescheduleAi(Runnable r, long delay, boolean isPlayer)

{

try

{

if(delay < 0)

{

delay = 0;

}

if(isPlayer)

{

return _playerAiScheduledThreadPool.schedule(r, delay, TimeUnit.MILLISECONDS);

}

return _npcAiScheduledThreadPool.schedule(r, delay, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("AiThreadPool: Failed schedule task!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

public ScheduledFuturescheduleAiAtFixedRate(Runnable r, long initial, long delay, boolean isPlayer)

{

try

{

if(delay < 0)

{

delay = 0;

}

if(initial < 0)

{

initial = 0;

}

if(isPlayer)

{

return _playerAiScheduledThreadPool.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS);

}

return _npcAiScheduledThreadPool.scheduleAtFixedRate(r, initial, delay, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("AiThreadPool: Failed schedule task at fixed rate!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

public void executePacket(ReceivablePacket pkt)

{

_generalPacketsThreadPool.execute(pkt);

}

 

public void executeIOPacket(ReceivablePacket pkt)

{

_ioPacketsThreadPool.execute(pkt);

}

 

public void executeLSGSPacket(Runnable r)

{

_LsGsExecutor.execute®;

}

 

public void executeGeneral(Runnable r)

{

_generalScheduledThreadPool.execute®;

}

 

public void executeAi(Runnable r, boolean isPlayer)

{

if(isPlayer)

{

_playerAiScheduledThreadPool.execute®;

}

else

{

_npcAiScheduledThreadPool.execute®;

}

}

 

public void executeMove(Runnable r)

{

_moveScheduledThreadPool.execute®;

}

 

public void executePathfind(Runnable r)

{

_pathfindThreadPool.execute®;

}

 

public String[] getStats()

{

return new String[]

{

" ╒══ General:",

" │ ActiveThreads: " + _generalScheduledThreadPool.getActiveCount(),

" │ CorePoolSize: " + _generalScheduledThreadPool.getCorePoolSize(),

" │ CompletedTasks: " + _generalScheduledThreadPool.getCompletedTaskCount(),

" │ ScheduledTasks: " + (_generalScheduledThreadPool.getTaskCount() - _generalScheduledThreadPool.getCompletedTaskCount()),

" ╞══ Move:",

" │ ActiveThreads: " + _moveScheduledThreadPool.getActiveCount(),

" │ CorePoolSize: " + _moveScheduledThreadPool.getCorePoolSize(),

" │ CompletedTasks: " + _moveScheduledThreadPool.getCompletedTaskCount(),

" │ ScheduledTasks: " + (_moveScheduledThreadPool.getTaskCount() - _moveScheduledThreadPool.getCompletedTaskCount()),

" ╞══ Pathfind:",

" │ ActiveThreads: " + _pathfindThreadPool.getActiveCount(),

" │ CorePoolSize: " + _pathfindThreadPool.getCorePoolSize(),

" │ CompletedTasks: " + _pathfindThreadPool.getCompletedTaskCount(),

" │ ScheduledTasks: " + (_pathfindThreadPool.getTaskCount() - _pathfindThreadPool.getCompletedTaskCount()),

" ╞══ Npc AI:",

" │ ActiveThreads: " + _npcAiScheduledThreadPool.getActiveCount(),

" │ CorePoolSize: " + _npcAiScheduledThreadPool.getCorePoolSize(),

" │ CompletedTasks: " + _npcAiScheduledThreadPool.getCompletedTaskCount(),

" │ ScheduledTasks: " + (_npcAiScheduledThreadPool.getTaskCount() - _npcAiScheduledThreadPool.getCompletedTaskCount()),

" ╞══ Player AI:",

" │ ActiveThreads: " + _playerAiScheduledThreadPool.getActiveCount(),

" │ CorePoolSize: " + _playerAiScheduledThreadPool.getCorePoolSize(),

" │ CompletedTasks: " + _playerAiScheduledThreadPool.getCompletedTaskCount(),

" │ ScheduledTasks: " + (_playerAiScheduledThreadPool.getTaskCount() - _playerAiScheduledThreadPool.getCompletedTaskCount()),

" ╞══ Interest",

" │ ActiveThreads: " + MMOConnection.getPool().getActiveCount(),

" │ CorePoolSize: " + MMOConnection.getPool().getCorePoolSize(),

" │ CompletedTasks: " + MMOConnection.getPool().getCompletedTaskCount(),

" │ ScheduledTasks: " + (MMOConnection.getPool().getTaskCount() - MMOConnection.getPool().getCompletedTaskCount()),

" ╞══ Packets:", " │ ActiveThreads: " + _generalPacketsThreadPool.getActiveCount(),

" │ CorePoolSize: " + _generalPacketsThreadPool.getCorePoolSize(),

" │ MaximumPoolSize: " + _generalPacketsThreadPool.getMaximumPoolSize(),

" │ LargestPoolSize: " + _generalPacketsThreadPool.getLargestPoolSize(),

" │ PoolSize: " + _generalPacketsThreadPool.getPoolSize(),

" │ CompletedTasks: " + _generalPacketsThreadPool.getCompletedTaskCount(),

" │ QueuedTasks: " + _generalPacketsThreadPool.getQueue().size(), " ╞══ IO Packets:",

" │ ActiveThreads: " + _ioPacketsThreadPool.getActiveCount(),

" │ CorePoolSize: " + _ioPacketsThreadPool.getCorePoolSize(),

" │ LargestPoolSize: " + _ioPacketsThreadPool.getLargestPoolSize(),

" │ PoolSize: " + _ioPacketsThreadPool.getPoolSize(),

" │ CompletedTasks: " + _ioPacketsThreadPool.getCompletedTaskCount(),

" │ QueuedTasks: " + _ioPacketsThreadPool.getQueue().size(), " ╞══ LS/GS Packets:",

" │ ActiveThreads: " + _LsGsExecutor.getActiveCount(),

" │ CorePoolSize: " + _LsGsExecutor.getCorePoolSize(),

" │ MaximumPoolSize: " + _LsGsExecutor.getMaximumPoolSize(),

" │ LargestPoolSize: " + _LsGsExecutor.getLargestPoolSize(),

" │ PoolSize: " + _LsGsExecutor.getPoolSize(),

" │ CompletedTasks: " + _LsGsExecutor.getCompletedTaskCount(),

" │ QueuedTasks: " + _LsGsExecutor.getQueue().size(), " ╘══════════════════",

};

}

 

public static class PriorityThreadFactory implements ThreadFactory

{

private int _prio;

private String _name;

private AtomicInteger _threadNumber = new AtomicInteger(1);

private ThreadGroup _group;

 

public PriorityThreadFactory(String name, int prio)

{

_prio = prio;

_name = name;

_group = new ThreadGroup(_name);

}

 

public Thread newThread(Runnable r)

{

Thread t = new Thread(_group, r);

t.setName(_name + "-" + _threadNumber.getAndIncrement());

t.setPriority(_prio);

return t;

}

 

public ThreadGroup getGroup()

{

return _group;

}

}

 

/**

*

*/

public void shutdown()

{

_shutdown = true;

try

{

// в обратном порядке шатдауним потоки

if(_LsGsExecutor != null)

{

_LsGsExecutor.shutdown();

}

if(_npcAiScheduledThreadPool != null)

{

_npcAiScheduledThreadPool.shutdown();

}

if(_playerAiScheduledThreadPool != null)

{

_playerAiScheduledThreadPool.shutdown();

}

if(_ioPacketsThreadPool != null)

{

_ioPacketsThreadPool.shutdown();

}

if(_generalPacketsThreadPool != null)

{

_generalPacketsThreadPool.shutdown();

}

if(_pathfindThreadPool != null)

{

_pathfindThreadPool.shutdown();

}

if(_moveScheduledThreadPool != null)

{

_moveScheduledThreadPool.shutdown();

}

if(_generalScheduledThreadPool != null)

{

_generalScheduledThreadPool.shutdown();

}

// и ждем их завершения

if(_LsGsExecutor != null)

{

_LsGsExecutor.awaitTermination(1, TimeUnit.SECONDS);

}

if(_npcAiScheduledThreadPool != null)

{

_npcAiScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_playerAiScheduledThreadPool != null)

{

_playerAiScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_ioPacketsThreadPool != null)

{

_ioPacketsThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_generalPacketsThreadPool != null)

{

_generalPacketsThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_pathfindThreadPool != null)

{

_pathfindThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_moveScheduledThreadPool != null)

{

_moveScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

if(_generalScheduledThreadPool != null)

{

_generalScheduledThreadPool.awaitTermination(1, TimeUnit.SECONDS);

}

System.out.println("All ThreadPools are now stoped.");

}

catch(InterruptedException e)

{

e.printStackTrace();

}

}

 

public String getGPacketStats()

{

return getThreadPoolStats(_generalPacketsThreadPool, "general packets");

}

 

public String getIOPacketStats()

{

return getThreadPoolStats(_ioPacketsThreadPool, "IO packets");

}

 

public String getGeneralPoolStats()

{

return getThreadPoolStats(_generalScheduledThreadPool, "general");

}

 

public String getMovePoolStats()

{

return getThreadPoolStats(_moveScheduledThreadPool, "move");

}

 

public String getPathfindPoolStats()

{

return getThreadPoolStats(_pathfindThreadPool, "pathfind");

}

 

public String getNpcAIPoolStats()

{

return getThreadPoolStats(_npcAiScheduledThreadPool, "npcAi");

}

 

public String getPlayerAIPoolStats()

{

return getThreadPoolStats(_playerAiScheduledThreadPool, "playerAi");

}

 

public static String getThreadPoolStats(ThreadPoolExecutor pool, String poolname)

{

ThreadFactory tf = pool.getThreadFactory();

if(!(tf instanceof PriorityThreadFactory))

{

return "This should not be seen, pool " + poolname;

}

StringBuilder res = new StringBuilder();

PriorityThreadFactory ptf = (PriorityThreadFactory) tf;

int count = ptf.getGroup().activeCount();

Thread[] threads = new Thread[count + 2];

ptf.getGroup().enumerate(threads);

res.append("\r\nThread Pool: ").append(poolname);

res.append("\r\nTasks in the queue: ").append(pool.getQueue().size());

res.append("\r\nThreads stack trace:");

res.append("\r\nThere should be ").append(count).append(" threads\r\n");

for(Thread t : threads)

{

if(t == null)

{

continue;

}

res.append("\r\n").append(t.getName());

//StackTraceElement[] trace = t.getStackTrace();

//if(trace.length == 0 || trace[0] == null || trace[0].toString().contains("sun.misc.Unsafe.park"))

// continue; // Пропускаем пустые

for(StackTraceElement ste : t.getStackTrace())

{

res.append("\r\n\t").append(ste);

}

}

return res.toString();

}

 

public boolean isShutdown()

{

return _shutdown;

}

 

public ThreadPoolExecutor getPathfindScheduledThreadPool()

{

return _pathfindThreadPool;

}

 

public ScheduledThreadPoolExecutor getGeneralScheduledThreadPool()

{

return _generalScheduledThreadPool;

}

 

public ScheduledThreadPoolExecutor getMoveScheduledThreadPool()

{

return _moveScheduledThreadPool;

}

 

public ScheduledThreadPoolExecutor getNpcAiScheduledThreadPool()

{

return _npcAiScheduledThreadPool;

}

 

public ScheduledThreadPoolExecutor getPlayerAiScheduledThreadPool()

{

return _playerAiScheduledThreadPool;

}

 

public ThreadPoolExecutor getIoPacketsThreadPool()

{

return _ioPacketsThreadPool;

}

 

public ThreadPoolExecutor getGeneralPacketsThreadPool()

{

return _generalPacketsThreadPool;

}

}

 

И по методам(если правильно понял)

 

public static ThreadPoolManager getInstance()

{

if(_instance == null)

{

_instance = new ThreadPoolManager();

}

return _instance;

}

 

 

public ScheduledFuture<?> scheduleGeneral(Runnable r, long delay)

{

try

{

if(delay < 0)

{

delay = 0;

}

return _generalScheduledThreadPool.schedule(r, delay, TimeUnit.MILLISECONDS);

}

catch(RejectedExecutionException e)

{

if(!isShutdown())

{

_log.warning("GeneralThreadPool: Failed schedule task!");

Thread.dumpStack();

}

return null; /* shutdown, ignore */

}

}

 

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Не туда смотриш. Смотреть именно в байлор менеджере, почему не запускаются. ThreadPoolManager - не более чем таймер - задачник для Runnable методов.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Весь день пытался разобраться так и не получается=((( вроде бы все так просто, а косяк найти не могу.

Может аналог спавна можно посмотреть где нибудь? Например с другим босом? Вот только каким?

Изменено пользователем shadowcat

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

позже скину

Изменено пользователем dislike

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Упс, извиняюсь, думал нужна помощь с белефом*

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Вот и я подумал что я туплю, когда ты скинул=)

Посмотрел еще в нескольких сборках, включая некстген, везде одинаковый. Вот теперь и думаю, метод спавна сильно должен отличаться?

Забыл уточнить что у меня сборка Ворона хроник эпилог.

Поделиться сообщением


Ссылка на сообщение
Поделиться на другие сайты

Для публикации сообщений создайте учётную запись или авторизуйтесь

Вы должны быть пользователем, чтобы оставить комментарий

Создать учетную запись

Зарегистрируйте новую учётную запись в нашем сообществе. Это очень просто!

Регистрация нового пользователя

Войти

Уже есть аккаунт? Войти в систему.

Войти
Авторизация  

  • Последние посетители   0 пользователей онлайн

    Ни одного зарегистрированного пользователя не просматривает данную страницу

×
×
  • Создать...