Releases: presentkim-pm/session-utils
Releases · presentkim-pm/session-utils
v1.1.0
What's new
SessionSequence — ordered session progression
Multi-step flows like tutorials can now be expressed as a sequence of SequenceSession subclasses.
Each step calls next() to advance, and an onComplete callback fires when the last step finishes.
$sequence = new SessionSequence($plugin,
TutorialStep1Session::class,
TutorialStep2Session::class,
TutorialStep3Session::class,
);
$sequence->onComplete(fn(Player $p) => $p->sendMessage("Tutorial complete!"));
// Start from the beginning, or resume from a saved step
$sequence->start($player);
$sequence->startFrom($player, $savedStep); // int index or class-stringSession self-termination
The Session interface and AbstractSession have been merged into a single Session abstract class
that holds the SessionManager reference directly. Sessions can now terminate themselves with a single call.
// Inside any Session subclass
$this->terminate(SessionTerminateReasons::COMPLETED);New SessionManager conveniences
// Throw if no session exists
$manager->getSessionOrThrow($player);
// Create if none exists
$manager->getOrCreateSession($player);
// React to session lifecycle from outside the session class
$manager
->onSessionCreated(fn(MySession $s) => $this->log("created"))
->onSessionTerminated(fn(MySession $s, string $reason) => $this->save($s));Reduced PMMP listener registrations
PlayerJoinEvent and PlayerQuitEvent are now routed through SessionEventListenerRegistry,
so only one PMMP listener is registered per event regardless of how many SessionManager instances exist.
Bug fixes
- Fixed a re-entry issue in
SessionManager::removeSession()whereSession::terminate()calling back
intoremoveSession()could cause a double-removal. Sessions are now removed from the internal map
beforeterminate()is invoked.
Breaking changes
Sessioninterface andAbstractSessionhave been replaced by theSessionabstract class.
Subclasses must extendSessiondirectly instead ofAbstractSession.SessionEventDispatcherhas been renamed toBaseSessionEventDispatcherand is now abstract.
The concrete implementation isSessionMethodDispatcher.- File paths under
listener/have changed —SessionEventDispatcher.phpis removed and replaced by
dispatcher/BaseSessionEventDispatcher.php,dispatcher/SessionMethodDispatcher.php, and
dispatcher/ManagerMethodDispatcher.php.