Rename and clean up MaplePlayerNPCFactory
This commit is contained in:
@@ -331,7 +331,7 @@ public class PlayerNPC extends AbstractMapleMapObject {
|
||||
int j = 0;
|
||||
for (int i = branchSid; i < nextBranchSid; 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);
|
||||
j++;
|
||||
|
||||
|
||||
@@ -32,47 +32,45 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class MaplePlayerNPCFactory {
|
||||
|
||||
private static DataProvider npcData = DataProviderFactory.getDataProvider(WZFiles.NPC);
|
||||
|
||||
public class PlayerNPCFactory {
|
||||
private static final DataProvider npcData = DataProviderFactory.getDataProvider(WZFiles.NPC);
|
||||
|
||||
private static final Map<Integer, List<PlayerNPC>> dnpcMaps = new HashMap<>();
|
||||
private static Integer runningDeveloperOid = 2147483000; // 647 slots, long enough
|
||||
|
||||
|
||||
public synchronized static boolean isExistentScriptid(int scriptid) {
|
||||
return npcData.getData(scriptid + ".img") != null;
|
||||
}
|
||||
|
||||
|
||||
private static void loadDeveloperRoomMetadata(DataProvider npc) {
|
||||
Data thisData = npc.getData("9977777.img");
|
||||
if(thisData != null) {
|
||||
if (thisData != null) {
|
||||
DataProvider map = DataProviderFactory.getDataProvider(WZFiles.MAP);
|
||||
|
||||
|
||||
thisData = map.getData("Map/Map7/777777777.img");
|
||||
if(thisData != null) {
|
||||
if (thisData != null) {
|
||||
DataProvider sound = DataProviderFactory.getDataProvider(WZFiles.SOUND);
|
||||
|
||||
|
||||
thisData = sound.getData("Field.img");
|
||||
if(thisData != null) {
|
||||
if (thisData != null) {
|
||||
Data md = thisData.getChildByPath("anthem/brazil");
|
||||
if(md != null) {
|
||||
if (md != null) {
|
||||
Server.getInstance().setAvailableDeveloperRoom();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized static void loadFactoryMetadata() {
|
||||
DataProvider npc = npcData;
|
||||
loadDeveloperRoomMetadata(npc);
|
||||
|
||||
DataProvider etc = DataProviderFactory.getDataProvider(WZFiles.ETC);
|
||||
Data dnpcData = etc.getData("DeveloperNpc.img");
|
||||
if(dnpcData != null) {
|
||||
if (dnpcData != null) {
|
||||
for (Data data : dnpcData.getChildren()) {
|
||||
int scriptId = Integer.parseInt(data.getName());
|
||||
|
||||
@@ -98,7 +96,7 @@ public class MaplePlayerNPCFactory {
|
||||
}
|
||||
|
||||
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
||||
if(dnpcSet == null) {
|
||||
if (dnpcSet == null) {
|
||||
dnpcSet = new LinkedList<>();
|
||||
dnpcMaps.put(mapid, dnpcSet);
|
||||
}
|
||||
@@ -108,9 +106,9 @@ public class MaplePlayerNPCFactory {
|
||||
}
|
||||
} else {
|
||||
Data thisData = npc.getData("9977777.img");
|
||||
|
||||
if(thisData != null) {
|
||||
byte[] encData = {0x52,0x6F,0x6E,0x61,0x6E};
|
||||
|
||||
if (thisData != null) {
|
||||
byte[] encData = {0x52, 0x6F, 0x6E, 0x61, 0x6E};
|
||||
String name = new String(encData);
|
||||
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;
|
||||
@@ -124,7 +122,7 @@ public class MaplePlayerNPCFactory {
|
||||
equips.put((short) -5, 1040103);
|
||||
|
||||
List<PlayerNPC> dnpcSet = dnpcMaps.get(mapid);
|
||||
if(dnpcSet == null) {
|
||||
if (dnpcSet == null) {
|
||||
dnpcSet = new LinkedList<>();
|
||||
dnpcMaps.put(mapid, dnpcSet);
|
||||
}
|
||||
@@ -134,7 +132,7 @@ public class MaplePlayerNPCFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public synchronized static List<PlayerNPC> getDeveloperNpcsFromMapid(int mapid) {
|
||||
return dnpcMaps.get(mapid);
|
||||
}
|
||||
@@ -249,7 +249,7 @@ public class MapleMapFactory {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
List<PlayerNPC> dnpcs = MaplePlayerNPCFactory.getDeveloperNpcsFromMapid(mapid);
|
||||
List<PlayerNPC> dnpcs = PlayerNPCFactory.getDeveloperNpcsFromMapid(mapid);
|
||||
if (dnpcs != null) {
|
||||
for (PlayerNPC dnpc : dnpcs) {
|
||||
map.addPlayerNPCMapObject(dnpc);
|
||||
|
||||
Reference in New Issue
Block a user