-
-
Notifications
You must be signed in to change notification settings - Fork 53
Islands
GiantQuartz edited this page Mar 27, 2020
·
1 revision
Before creating an island, you should make sure that the player doesn't have an island, otherwise, this might cause unexpected behavior.
// $session must be an instance of Session in this example
// $generator contains the id of one of the generators available,
// take a look at the generators page to learn more about them
if(!$session->hasIsland()) {
IslandFactory::createIslandFor($session->getPlayer(), $generator);
}
Before disbanding an island, you should make sure that the player has an island, otherwise, this might cause unexpected behavior.
if($session->hasIsland()) {
IslandFactory::disbandIsland($session->getIsland());
}
Just like with sessions, we strongly recommend you to save the changes you have made to an island right after doing them:
// $island must be an instance of Island
$island->setLocked(true); // locks the island
$island->save(); // saves the island data to the database