Rename and clean up MaplePlayerNPCFactory
This commit is contained in:
@@ -60,7 +60,7 @@ import server.MapleSkillbookInformationProvider;
|
|||||||
import server.ThreadManager;
|
import server.ThreadManager;
|
||||||
import server.TimerManager;
|
import server.TimerManager;
|
||||||
import server.expeditions.ExpeditionBossLog;
|
import server.expeditions.ExpeditionBossLog;
|
||||||
import server.life.MaplePlayerNPCFactory;
|
import server.life.PlayerNPCFactory;
|
||||||
import server.quest.MapleQuest;
|
import server.quest.MapleQuest;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
import tools.FilePrinter;
|
import tools.FilePrinter;
|
||||||
@@ -841,7 +841,7 @@ public class Server {
|
|||||||
futures.add(initExecutor.submit(() -> CashItemFactory.loadAllCashItems()));
|
futures.add(initExecutor.submit(() -> CashItemFactory.loadAllCashItems()));
|
||||||
futures.add(initExecutor.submit(() -> MapleQuest.loadAllQuests()));
|
futures.add(initExecutor.submit(() -> MapleQuest.loadAllQuests()));
|
||||||
futures.add(initExecutor.submit(() -> MapleSkillbookInformationProvider.loadAllSkillbookInformation()));
|
futures.add(initExecutor.submit(() -> MapleSkillbookInformationProvider.loadAllSkillbookInformation()));
|
||||||
futures.add(initExecutor.submit(() -> MaplePlayerNPCFactory.loadFactoryMetadata()));
|
futures.add(initExecutor.submit(() -> PlayerNPCFactory.loadFactoryMetadata()));
|
||||||
|
|
||||||
TimeZone.setDefault(TimeZone.getTimeZone(YamlConfig.config.server.TIMEZONE));
|
TimeZone.setDefault(TimeZone.getTimeZone(YamlConfig.config.server.TIMEZONE));
|
||||||
|
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ public class PlayerNPC extends AbstractMapleMapObject {
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = branchSid; i < nextBranchSid; i++) {
|
for (int i = branchSid; i < nextBranchSid; i++) {
|
||||||
if (!usedScriptIds.contains(i)) {
|
if (!usedScriptIds.contains(i)) {
|
||||||
if (MaplePlayerNPCFactory.isExistentScriptid(i)) { // thanks Ark, Zein, geno, Ariel, JrCl0wn for noticing client crashes due to use of missing scriptids
|
if (PlayerNPCFactory.isExistentScriptid(i)) { // thanks Ark, Zein, geno, Ariel, JrCl0wn for noticing client crashes due to use of missing scriptids
|
||||||
availables.add(i);
|
availables.add(i);
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
|
|||||||
@@ -32,47 +32,45 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author RonanLana
|
* @author RonanLana
|
||||||
*/
|
*/
|
||||||
public class MaplePlayerNPCFactory {
|
public class PlayerNPCFactory {
|
||||||
|
private static final DataProvider npcData = DataProviderFactory.getDataProvider(WZFiles.NPC);
|
||||||
private static DataProvider npcData = DataProviderFactory.getDataProvider(WZFiles.NPC);
|
|
||||||
|
|
||||||
private static final Map<Integer, List<PlayerNPC>> dnpcMaps = new HashMap<>();
|
private static final Map<Integer, List<PlayerNPC>> dnpcMaps = new HashMap<>();
|
||||||
private static Integer runningDeveloperOid = 2147483000; // 647 slots, long enough
|
private static Integer runningDeveloperOid = 2147483000; // 647 slots, long enough
|
||||||
|
|
||||||
public synchronized static boolean isExistentScriptid(int scriptid) {
|
public synchronized static boolean isExistentScriptid(int scriptid) {
|
||||||
return npcData.getData(scriptid + ".img") != null;
|
return npcData.getData(scriptid + ".img") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadDeveloperRoomMetadata(DataProvider npc) {
|
private static void loadDeveloperRoomMetadata(DataProvider npc) {
|
||||||
Data thisData = npc.getData("9977777.img");
|
Data thisData = npc.getData("9977777.img");
|
||||||
if(thisData != null) {
|
if (thisData != null) {
|
||||||
DataProvider map = DataProviderFactory.getDataProvider(WZFiles.MAP);
|
DataProvider map = DataProviderFactory.getDataProvider(WZFiles.MAP);
|
||||||
|
|
||||||
thisData = map.getData("Map/Map7/777777777.img");
|
thisData = map.getData("Map/Map7/777777777.img");
|
||||||
if(thisData != null) {
|
if (thisData != null) {
|
||||||
DataProvider sound = DataProviderFactory.getDataProvider(WZFiles.SOUND);
|
DataProvider sound = DataProviderFactory.getDataProvider(WZFiles.SOUND);
|
||||||
|
|
||||||
thisData = sound.getData("Field.img");
|
thisData = sound.getData("Field.img");
|
||||||
if(thisData != null) {
|
if (thisData != null) {
|
||||||
Data md = thisData.getChildByPath("anthem/brazil");
|
Data md = thisData.getChildByPath("anthem/brazil");
|
||||||
if(md != null) {
|
if (md != null) {
|
||||||
Server.getInstance().setAvailableDeveloperRoom();
|
Server.getInstance().setAvailableDeveloperRoom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static void loadFactoryMetadata() {
|
public synchronized static void loadFactoryMetadata() {
|
||||||
DataProvider npc = npcData;
|
DataProvider npc = npcData;
|
||||||
loadDeveloperRoomMetadata(npc);
|
loadDeveloperRoomMetadata(npc);
|
||||||
|
|
||||||
DataProvider etc = DataProviderFactory.getDataProvider(WZFiles.ETC);
|
DataProvider etc = DataProviderFactory.getDataProvider(WZFiles.ETC);
|
||||||
Data dnpcData = etc.getData("DeveloperNpc.img");
|
Data dnpcData = etc.getData("DeveloperNpc.img");
|
||||||
if(dnpcData != null) {
|
if (dnpcData != null) {
|
||||||
for (Data data : dnpcData.getChildren()) {
|
for (Data data : dnpcData.getChildren()) {
|
||||||
int scriptId = Integer.parseInt(data.getName());
|
int scriptId = Integer.parseInt(data.getName());
|
||||||
|
|
||||||
@@ -98,7 +96,7 @@ public class MaplePlayerNPCFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
||||||
if(dnpcSet == null) {
|
if (dnpcSet == null) {
|
||||||
dnpcSet = new LinkedList<>();
|
dnpcSet = new LinkedList<>();
|
||||||
dnpcMaps.put(mapid, dnpcSet);
|
dnpcMaps.put(mapid, dnpcSet);
|
||||||
}
|
}
|
||||||
@@ -108,9 +106,9 @@ public class MaplePlayerNPCFactory {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Data thisData = npc.getData("9977777.img");
|
Data thisData = npc.getData("9977777.img");
|
||||||
|
|
||||||
if(thisData != null) {
|
if (thisData != null) {
|
||||||
byte[] encData = {0x52,0x6F,0x6E,0x61,0x6E};
|
byte[] encData = {0x52, 0x6F, 0x6E, 0x61, 0x6E};
|
||||||
String name = new String(encData);
|
String name = new String(encData);
|
||||||
int face = 20104, hair = 30215, gender = 0, skin = 0, dir = 0, mapid = 777777777;
|
int face = 20104, hair = 30215, gender = 0, skin = 0, dir = 0, mapid = 777777777;
|
||||||
int FH = 4, RX0 = -143, RX1 = -243, CX = -193, CY = 117, scriptId = 9977777;
|
int FH = 4, RX0 = -143, RX1 = -243, CX = -193, CY = 117, scriptId = 9977777;
|
||||||
@@ -124,7 +122,7 @@ public class MaplePlayerNPCFactory {
|
|||||||
equips.put((short) -5, 1040103);
|
equips.put((short) -5, 1040103);
|
||||||
|
|
||||||
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
||||||
if(dnpcSet == null) {
|
if (dnpcSet == null) {
|
||||||
dnpcSet = new LinkedList<>();
|
dnpcSet = new LinkedList<>();
|
||||||
dnpcMaps.put(mapid, dnpcSet);
|
dnpcMaps.put(mapid, dnpcSet);
|
||||||
}
|
}
|
||||||
@@ -134,7 +132,7 @@ public class MaplePlayerNPCFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static List<PlayerNPC> getDeveloperNpcsFromMapid(int mapid) {
|
public synchronized static List<PlayerNPC> getDeveloperNpcsFromMapid(int mapid) {
|
||||||
return dnpcMaps.get(mapid);
|
return dnpcMaps.get(mapid);
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ public class MapleMapFactory {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlayerNPC> dnpcs = MaplePlayerNPCFactory.getDeveloperNpcsFromMapid(mapid);
|
List<PlayerNPC> dnpcs = PlayerNPCFactory.getDeveloperNpcsFromMapid(mapid);
|
||||||
if (dnpcs != null) {
|
if (dnpcs != null) {
|
||||||
for (PlayerNPC dnpc : dnpcs) {
|
for (PlayerNPC dnpc : dnpcs) {
|
||||||
map.addPlayerNPCMapObject(dnpc);
|
map.addPlayerNPCMapObject(dnpc);
|
||||||
|
|||||||
Reference in New Issue
Block a user