What? How is it not better instead of filling his first click NPC packet he can just put the NPC ids in the Json file.
not very dynamic, for example if you only want NPCs to only be able to open a shop if you've completed a quest. that's why I never did it like that in the first place
not very dynamic, for example if you only want NPCs to only be able to open a shop if you've completed a quest. that's why I never did it like that in the first place
Easily dynamic. Just modify to something like such:
Code:
/**
* Gets the shop based on an npc id.
*
* @param npcId
* @return
*/
public static boolean openShopForNpc(Player player, Npc npc) {
if (shopNpcs.containsKey(npc.getNpcId())) {
//special cases
switch(npc.getNpcId()) {
case xx:
if(questrequirementnotmet)
return false;
}
getShop(shopNpcs.get(npc.getNpcId())).openShop(player);
return true;
}
return false;
}
And I'd consider it more dynamic in the long run because it's a lot easier to reload a new shop in while the server is running by parsing a JSON file.