@Override public void applyEffect(Effect effect) { Creature effector = effect.getEffector(); SpawnEngine spawnEngine = SpawnEngine.getInstance(); float x = effector.getX(); float y = effector.getY(); float z = effector.getZ(); byte heading = effector.getHeading(); int worldId = effector.getWorldId(); int instanceId = effector.getInstanceId(); SpawnTemplate spawn = spawnEngine.addNewSpawn(worldId, instanceId, npcId, x, y, z, heading, 0, 0, true, true); final Servant servant = spawnEngine.spawnServant(spawn, instanceId, effector, skillId, hpRatio); Future<?> task = ThreadPoolManager.getInstance() .schedule( new Runnable() { @Override public void run() { servant.getController().onDespawn(true); } }, 60 * 1000); servant.getController().addTask(TaskId.DESPAWN, task); }
/** * @param worldId * @param destroyTime * @return */ public static synchronized WorldMapInstance getNextAvailableInstance(int worldId) { WorldMap map = World.getInstance().getWorldMap(worldId); if (!map.isInstanceType()) throw new UnsupportedOperationException( "Invalid call for next available instance of " + worldId); int nextInstanceId = map.getNextInstanceId(); log.info("Creating new instance: " + worldId + " " + nextInstanceId); WorldMapInstance worldMapInstance = new WorldMapInstance(map, nextInstanceId); startInstanceChecker(worldMapInstance); map.addInstance(nextInstanceId, worldMapInstance); SpawnEngine.getInstance().spawnInstance(worldId, worldMapInstance.getInstanceId()); return worldMapInstance; }