-
-
Notifications
You must be signed in to change notification settings - Fork 53
Sessions
GiantQuartz edited this page Mar 29, 2020
·
3 revisions
When a player joins the server, a Session is created and loaded with a lot of useful information about them such as their island data or their rank. Sessions are used everywhere in SkyBlock.
There are two ways to obtain a player session, both of them are okay as long as you made sure that SkyBlock is loaded first.
// $player must be an instance of PocketMine's Player class
$session = SessionLocator::getSession($player);
$session = $skyblock->getSessionManager()->getSession($player);
If you decide to change something on a session (such as their rank) unless you know perfectly what you are doing, I strongly recommend you to save that session data, otherwise, you might end up with unexpected behaviour. Example:
// $player must be an instance of PocketMine's Player class
$session = SessionLocator::getSession($player);
$session->setRank(RankIds::OFFICER); // Updates the player rank to officer
$session->save(); // Saves the changes to the database