}
@EventHandler
public void playerJoin(PlayerJoinEvent event) {
Denizen denizen = DenizenAPI.getCurrentInstance();
dPlayer player = new dPlayer(event.getPlayer());
// Any saves quest listeners in progress?
if (!denizen.getSaves().contains("Listeners." + player.getSaveName())) return;
Set<String> inProgress = denizen.getSaves().getConfigurationSection("Listeners." + player.getSaveName()).getKeys(false);
// If empty, no quest listeners to load.
if (inProgress.isEmpty()) return;
// TODO: Players.SAVENAME.Listeners?
String path = "Listeners." + player.getSaveName() + ".";
// If not empty, let's do the loading process for each.
for (String listenerId : inProgress) {
// People tend to worry when they see long-ass stacktraces.. let's catch them.
try {
String type = denizen.getSaves().getString(path + listenerId + ".Listener Type");
dNPC npc = null;
if (denizen.getSaves().contains(path + listenerId + ".Linked NPCID"))
npc = DenizenAPI.getDenizenNPC(CitizensAPI.getNPCRegistry().getById(denizen.getSaves().getInt(path + listenerId + ".Linked NPCID")));
if (get(type) == null) return;
dB.log(event.getPlayer().getName() + " has a LISTENER in progress. Loading '" + listenerId + "'.");
get(type).createInstance(dPlayer.mirrorBukkitPlayer(event.getPlayer()), listenerId).load(dPlayer.mirrorBukkitPlayer(event.getPlayer()), npc, listenerId, type);
} catch (Exception e) {
dB.log(event.getPlayer() + " has a saved listener named '" + listenerId + "' that may be corrupt. Skipping for now, but perhaps check the contents of your saves.yml for problems?");