Makes sure to invalidate sessions properly

Sessions are invalidated if the player leaves the NPC or if 10 seconds pass, but only if the blacksmith isn't currently reforging.
This commit is contained in:
Kristian Knarvik 2022-10-18 12:44:35 +02:00
parent 9b1480453b
commit 3c677c18cb

View File

@ -133,8 +133,8 @@ public class BlacksmithTrait extends Trait {
//If already in a session, but the player has failed to interact, and left the blacksmith, allow a new session
if (session != null) {
if (System.currentTimeMillis() > _sessionStart + 10 * 1000 &&
this.npc.getEntity().getLocation().distance(session.getPlayer().getLocation()) > 20) {
if (!session.isRunning() && (System.currentTimeMillis() > _sessionStart + 10 * 1000 ||
this.npc.getEntity().getLocation().distance(session.getPlayer().getLocation()) > 20)) {
session = null;
}
}