mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
hotbar will save in creative mode
This commit is contained in:
parent
92e1411ed3
commit
a61d4936c5
3 changed files with 87 additions and 28 deletions
|
|
@ -429,7 +429,6 @@ class PlayerAPI{
|
|||
"z" => $this->server->spawn->z,
|
||||
],
|
||||
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, [AIR, 0, 0]),
|
||||
"hotbar" => [0, 1, 2, 3, 4, 5, 6, 7, 8],
|
||||
"armor" => array_fill(0, 4, [AIR, 0]),
|
||||
"gamemode" => $this->server->gamemode,
|
||||
"health" => 20,
|
||||
|
|
@ -439,23 +438,32 @@ class PlayerAPI{
|
|||
"slot-count" => 7,
|
||||
"bed-position" => null,
|
||||
];
|
||||
|
||||
if(!file_exists(DATA_PATH . "players/" . $iname . ".yml")){
|
||||
$ev = true;
|
||||
$sav = false;
|
||||
if(!file_exists(DATA_PATH . "players/$iname.yml")){
|
||||
if(PocketMinecraftServer::$SAVE_PLAYER_DATA && $create){
|
||||
console("[NOTICE] Player data not found for \"" . $iname . "\", creating new profile");
|
||||
$data = new Config(DATA_PATH . "players/" . $iname . ".yml", CONFIG_YAML, $default);
|
||||
$data->save();
|
||||
console("[NOTICE] Player data not found for \"$iname\", creating new profile");
|
||||
$data = new Config(DATA_PATH . "players/$iname.yml", CONFIG_YAML, $default);
|
||||
$sav = true;
|
||||
}else{
|
||||
return new Config(DATA_PATH . "players/$iname.yml", CONFIG_YAML, $default);
|
||||
$data = new Config(DATA_PATH . "players/$iname.yml", CONFIG_YAML, $default);
|
||||
$ev = false;
|
||||
}
|
||||
}else{
|
||||
$data = new Config(DATA_PATH . "players/$iname.yml", CONFIG_YAML, $default);
|
||||
}
|
||||
|
||||
$data = new Config(DATA_PATH . "players/" . $iname . ".yml", CONFIG_YAML, $default);
|
||||
|
||||
|
||||
if(($data->get("gamemode") & 0x01) === 1){
|
||||
$data->set("health", 20);
|
||||
}
|
||||
$this->server->handle("player.offline.get", $data);
|
||||
if(!$data->exists("hotbar")){
|
||||
if(($data->get("gamemode") & 1) == CREATIVE) $hb = BlockAPI::$creativeHotbarSlots;
|
||||
else $hb = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
||||
$data->set("hotbar", $hb);
|
||||
}
|
||||
if($ev) $this->server->handle("player.offline.get", $data);
|
||||
if($sav) $data->save();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue