From 3c677c18cb955e0b43308bb0abf35d49dcc9bed4 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Tue, 18 Oct 2022 12:44:35 +0200 Subject: [PATCH] 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. --- .../java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java index d4aacba..b7d28ca 100644 --- a/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java +++ b/src/main/java/net/knarcraft/blacksmith/trait/BlacksmithTrait.java @@ -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; } }