Made it so you can have multiple locations per NPC
This commit is contained in:
parent
e576c1cc33
commit
fb577b7b72
|
|
@ -27,7 +27,7 @@ public class NPCLocationConfig extends AbstractConfig{
|
|||
public static class NPC_LOCATION {
|
||||
private static final String prefix = "npc.";
|
||||
|
||||
public static Map<String, Location> ALL = new HashMap<>();
|
||||
public static Map<String, List<Location>> ALL = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
|
|
@ -38,9 +38,11 @@ public class NPCLocationConfig extends AbstractConfig{
|
|||
Set<String> npcKeys = configurationSection.getKeys(false);
|
||||
for (String key : npcKeys) {
|
||||
Optional<Location> location = getLocation(prefix + key + ".location.");
|
||||
if (location.isEmpty())
|
||||
if (location.isEmpty()) {
|
||||
continue;
|
||||
ALL.put(key, location.get());
|
||||
}
|
||||
String villagerId = config.getString(prefix + key + ".", "villager-id", "villager1");
|
||||
ALL.computeIfAbsent(villagerId, list -> new ArrayList<>()).add(location.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ public class NPCManager {
|
|||
private static Set<NPC> loaded = new HashSet<>();
|
||||
|
||||
public static void spawnNPCs(FishingEvent fishingEvent, Logger logger) {
|
||||
NPCLocationConfig.NPC_LOCATION.ALL.forEach((name, location) -> {
|
||||
NPCLocationConfig.NPC_LOCATION.ALL.forEach((name, locations) -> {
|
||||
NPC npc = Config.NPC_DATA.NPC_MAP.getOrDefault(name, null);
|
||||
if (npc == null) {
|
||||
logger.warning("Found npc location entry without matching npc for [%]", name);
|
||||
return;
|
||||
}
|
||||
logger.info("Spawning daily NPC " + name);
|
||||
npc.spawnNPC(fishingEvent, location);
|
||||
locations.forEach(location -> npc.spawnNPC(fishingEvent, location));
|
||||
loaded.add(npc);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user