TeaseAI.application.getSession().end() ends up being called twice when a Personality finishes. I don't think this has any discernible side effects, and I appreciate that most Personalities keep running anyway.
The two places where the call is made are here:
'80cd022:src/me/goddragon/teaseai/api/scripts/ScriptHandler.java:128'
Code: Select all
public void startPersonality(Personality personality) {
File mainScript = new File(personality.getFolder().getAbsolutePath() + File.separator + "main.js");
if (!mainScript.isFile() || !mainScript.exists()) {
TeaseLogger.getLogger().log(Level.SEVERE, "Personality '" + currentPersonality.getName() + "' is missing the main.js script");
} else {
startPersonality(personality, mainScript);
}
TeaseAI.application.getSession().end();
}
'80cd022:src/me/goddragon/teaseai/api/scripts/ScriptHandler.java:150'
Code: Select all
public void startPersonality(Personality personality, File startScript) {
//Reassign because we want to clear the catch
this.engine = new ScriptEngineManager().getEngineByName("nashorn");
ScriptHandler.getHandler().load();
this.currentPersonality = personality;
currentPersonality.getVariableHandler().setVariable("personalityVersion", currentPersonality.getVersion().getValue(), true);
VocabularyHandler.getHandler().loadVocabulariesFromPersonality(personality);
ResponseHandler.getHandler().loadResponsesFromPersonality(personality);
try {
runScript(startScript);
} catch (FileNotFoundException e) {
TeaseLogger.getLogger().log(Level.SEVERE, "Tried to run non-existent script '" + startScript.getName() + "'.");
}
TeaseAI.application.getSession().end();
}
The change (if you think it's worth it!) is to move the call to getSession().end() earlier within the first block, i.e.
Code: Select all
public void startPersonality(Personality personality) {
File mainScript = new File(personality.getFolder().getAbsolutePath() + File.separator + "main.js");
if (!mainScript.isFile() || !mainScript.exists()) {
TeaseLogger.getLogger().log(Level.SEVERE, "Personality '" + currentPersonality.getName() + "' is missing the main.js script");
+ TeaseAI.application.getSession().end();
} else {
startPersonality(personality, mainScript);
}
}