Thanks alot for your reply! I think I have the same basic setup:
MapleMapDataFactory:
Code:
private static final Map<Integer, MapleMapData> mapdata = new HashMap<>();
private static MapleMapDataFactory instance;
private final ReentrantLock dataLoadLock;
private MapleMapDataFactory() {
this.source = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Map.wz"));
this.nameData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/String.wz")).getData("Map.img");
dataLoadLock = new ReentrantLock(false);
}
public static MapleMapDataFactory getInstance() {
if (instance == null) {
instance = new MapleMapDataFactory();
}
return instance;
}
public boolean isMapDataLoaded(int mapid) {
return mapdata.containsKey(mapid);
}
public MapleMapData getMapData(int mapid) {
if (mapdata.containsKey(mapid)) {
return mapdata.get(mapid);
} else {
dataLoadLock.lock();
try { and so on...
MapleMapData:
Code:
private final Map<Byte, MaplePortal> portals = new HashMap<>();
private Pair<Integer, String> timeMob;
private final Map<Integer, MapleMapObject> mapobjects = new HashMap<>();
private MapleFootholdTree footholds = null;
public MapleMapData(int mapid, int returnMapId, int forcedReturnId, float monsterRate, String onEnterF, String onEnter, int fieldType, int fieldLimit, int mobCapacity, short mobInterval, boolean clock, boolean town, boolean everlast, boolean boat, int decHp, int protectItem, int timeLimit) {
this.mapid = mapid;
this.returnMapId = returnMapId;
...and so on
MapleMapFactory:
Code:
public MapleMap getMap(int mapid) {
if (maps.containsKey(mapid)) {
return maps.get(mapid);
} else {
mapLoadLock.lock();
try {
if (maps.containsKey(mapid)) {
return maps.get(mapid);
}
final MapleMap map = new MapleMap(mapid, world, channel);
MapleMapData data = MapleMapDataFactory.getInstance().getMapData(mapid);
map.setTimeLimit(data.getTimeLimit());
if (AreaBossFactory.hasBoss(map.getId())) {
AreaBossData ab = AreaBossFactory.getBossData(map.getId());
map.addBossSpawn(MapleLifeFactory.getMonster(ab.getId()), data.calcBossSpawnPosition(ab.getPosition()), ab.getIntervall(), ab.getMsg());
}
data.getMapObjects().stream().forEach((mmo) -> {
if (mmo instanceof MapleMonster) {
MapleMonster mob = (MapleMonster) mmo;
if (mob.getMobtime() == -1) {
map.spawnMonster(mob);
...and so on
I'm assuming readonly = final?
Also is there a reason why mapData in maplemap is public? Can it be private + getter Method, or will that cause the memory waste?