Load developer room async on startup
This commit is contained in:
@@ -139,7 +139,7 @@ public class Server {
|
||||
private final AtomicLong currentTime = new AtomicLong(0);
|
||||
private long serverCurrentTime = 0;
|
||||
|
||||
private boolean availableDeveloperRoom = false;
|
||||
private volatile boolean availableDeveloperRoom = false;
|
||||
private boolean online = false;
|
||||
public static long uptime = System.currentTimeMillis();
|
||||
|
||||
@@ -827,7 +827,6 @@ public class Server {
|
||||
public void init() {
|
||||
Instant beforeInit = Instant.now();
|
||||
log.info("Cosmic v{} starting up.", ServerConstants.VERSION);
|
||||
final ExecutorService initExecutor = Executors.newFixedThreadPool(10);
|
||||
|
||||
if (YamlConfig.config.server.SHUTDOWNHOOK) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdown(false)));
|
||||
@@ -853,12 +852,14 @@ public class Server {
|
||||
throw new IllegalStateException(sqle);
|
||||
}
|
||||
|
||||
final ExecutorService initExecutor = Executors.newFixedThreadPool(10);
|
||||
// Run slow operations asynchronously to make startup faster
|
||||
final List<Future<?>> futures = new ArrayList<>();
|
||||
futures.add(initExecutor.submit(() -> SkillFactory.loadAllSkills()));
|
||||
futures.add(initExecutor.submit(() -> CashItemFactory.loadAllCashItems()));
|
||||
futures.add(initExecutor.submit(() -> MapleQuest.loadAllQuests()));
|
||||
futures.add(initExecutor.submit(() -> MapleSkillbookInformationProvider.loadAllSkillbookInformation()));
|
||||
futures.add(initExecutor.submit(() -> MaplePlayerNPCFactory.loadFactoryMetadata()));
|
||||
|
||||
ThreadManager.getInstance().start();
|
||||
initializeTimelyTasks(); // aggregated method for timely tasks thanks to lxconan
|
||||
@@ -877,7 +878,6 @@ public class Server {
|
||||
}
|
||||
initWorldPlayerRanking();
|
||||
|
||||
MaplePlayerNPCFactory.loadFactoryMetadata();
|
||||
loadPlayerNpcMapStepFromDb();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();//For those who get errors
|
||||
|
||||
@@ -19,17 +19,18 @@
|
||||
*/
|
||||
package server.life;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import net.server.Server;
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataProvider;
|
||||
import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
@@ -41,11 +42,11 @@ public class MaplePlayerNPCFactory {
|
||||
private static final Map<Integer, List<MaplePlayerNPC>> dnpcMaps = new HashMap<>();
|
||||
private static Integer runningDeveloperOid = 2147483000; // 647 slots, long enough
|
||||
|
||||
public static boolean isExistentScriptid(int scriptid) {
|
||||
public synchronized static boolean isExistentScriptid(int scriptid) {
|
||||
return npcData.getData(scriptid + ".img") != null;
|
||||
}
|
||||
|
||||
public static void loadDeveloperRoomMetadata(MapleDataProvider npc) {
|
||||
private static void loadDeveloperRoomMetadata(MapleDataProvider npc) {
|
||||
MapleData thisData = npc.getData("9977777.img");
|
||||
if(thisData != null) {
|
||||
MapleDataProvider map = MapleDataProviderFactory.getDataProvider(new File("wz/Map.wz"));
|
||||
@@ -65,7 +66,7 @@ public class MaplePlayerNPCFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadFactoryMetadata() {
|
||||
public synchronized static void loadFactoryMetadata() {
|
||||
MapleDataProvider npc = npcData;
|
||||
loadDeveloperRoomMetadata(npc);
|
||||
|
||||
@@ -134,7 +135,7 @@ public class MaplePlayerNPCFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<MaplePlayerNPC> getDeveloperNpcsFromMapid(int mapid) {
|
||||
public synchronized static List<MaplePlayerNPC> getDeveloperNpcsFromMapid(int mapid) {
|
||||
return dnpcMaps.get(mapid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user