mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +00:00
Fixed AdventureSettings not working
This commit is contained in:
parent
0dc8362536
commit
51be88c698
@ -1330,6 +1330,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
$pk->commandPermission = ($this->isOp() ? AdventureSettingsPacket::PERMISSION_OPERATOR : AdventureSettingsPacket::PERMISSION_NORMAL);
|
||||
$pk->playerPermission = ($this->isOp() ? PlayerPermissions::OPERATOR : PlayerPermissions::MEMBER);
|
||||
$pk->entityUniqueId = $this->getId();
|
||||
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
@ -3085,6 +3086,12 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
public function handleAdventureSettings(AdventureSettingsPacket $packet) : bool{
|
||||
if($packet->entityUniqueId !== $this->getId()){
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
$handled = false;
|
||||
|
||||
$isFlying = $packet->getFlag(AdventureSettingsPacket::FLYING);
|
||||
if($isFlying and !$this->allowFlight and !$this->server->getAllowFlight()){
|
||||
$this->kick($this->server->getLanguage()->translateString("kick.reason.cheat", ["%ability.flight"]));
|
||||
@ -3096,6 +3103,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}else{
|
||||
$this->flying = $ev->isFlying();
|
||||
}
|
||||
|
||||
$handled = true;
|
||||
}
|
||||
|
||||
if($packet->getFlag(AdventureSettingsPacket::NO_CLIP) and !$this->allowMovementCheats and !$this->isSpectator()){
|
||||
@ -3105,7 +3114,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
|
||||
//TODO: check other changes
|
||||
|
||||
return true;
|
||||
return $handled;
|
||||
}
|
||||
|
||||
public function handleBlockEntityData(BlockEntityDataPacket $packet) : bool{
|
||||
|
@ -69,14 +69,14 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
public $commandPermission = self::PERMISSION_NORMAL;
|
||||
public $flags2 = -1;
|
||||
public $playerPermission = PlayerPermissions::MEMBER;
|
||||
public $long1 = 0;
|
||||
public $entityUniqueId; //This is a little-endian long, NOT a var-long. (WTF Mojang)
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->commandPermission = $this->getUnsignedVarInt();
|
||||
$this->flags2 = $this->getUnsignedVarInt();
|
||||
$this->playerPermission = $this->getUnsignedVarInt();
|
||||
$this->long1 = $this->getLLong();
|
||||
$this->entityUniqueId = $this->getLLong();
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
@ -84,7 +84,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
$this->putUnsignedVarInt($this->commandPermission);
|
||||
$this->putUnsignedVarInt($this->flags2);
|
||||
$this->putUnsignedVarInt($this->playerPermission);
|
||||
$this->putLLong($this->long1);
|
||||
$this->putLLong($this->entityUniqueId);
|
||||
}
|
||||
|
||||
public function getFlag(int $flag) : bool{
|
||||
|
Loading…
x
Reference in New Issue
Block a user