Added force-gamemode property

This commit is contained in:
Shoghi Cervantes 2014-06-24 12:18:51 +02:00
parent 0e679139d2
commit ecbfff9b0f
2 changed files with 12 additions and 0 deletions

View File

@ -58,6 +58,7 @@ use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte;
use pocketmine\nbt\tag\Compound;
use pocketmine\nbt\tag\Int;
use pocketmine\nbt\tag\String;
use pocketmine\network\protocol\AdventureSettingsPacket;
use pocketmine\network\protocol\AnimatePacket;
@ -1142,6 +1143,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$nbt["NameTag"] = $this->username;
}
$this->gamemode = $nbt["playerGameType"] & 0x03;
if($this->server->getForceGamemode()){
$this->gamemode = $this->server->getGamemode();
$nbt->playerGameType = new Int("playerGameType", $this->gamemode);
}
if(($level = $this->server->getLevelByName($nbt["Level"])) === null){
$this->setLevel($this->server->getDefaultLevel(), true);
$nbt["Level"] = $this->getLevel()->getName();

View File

@ -307,6 +307,13 @@ class Server{
return $this->getConfigInt("gamemode", 0) & 0b11;
}
/**
* @return bool
*/
public function getForceGamemode(){
return $this->getConfigBoolean("force-gamemode", false);
}
/**
* Returns the gamemode text name
*