Skip to content

Islands

GiantQuartz edited this page Mar 27, 2020 · 1 revision

Disband/creating an island

Creating an island

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);
}

Disbanding an island

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());
}

Updating island data

Saving island data

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
Clone this wiki locally