mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Merge branch 'master' into mcpe-1.2
This commit is contained in:
commit
09c53552c1
@ -1051,43 +1051,13 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an ordered DataPacket to the send buffer
|
||||
*
|
||||
* @param DataPacket $packet
|
||||
* @param bool $needACK
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function dataPacket(DataPacket $packet, bool $needACK = false){
|
||||
if(!$this->connected){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Basic safety restriction. TODO: improve this
|
||||
if(!$this->loggedIn and !$packet->canBeSentBeforeLogin()){
|
||||
throw new \InvalidArgumentException("Attempted to send " . get_class($packet) . " to " . $this->getName() . " too early");
|
||||
}
|
||||
|
||||
$timings = Timings::getSendDataPacketTimings($packet);
|
||||
$timings->startTiming();
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
|
||||
if($ev->isCancelled()){
|
||||
$timings->stopTiming();
|
||||
return false;
|
||||
}
|
||||
|
||||
$identifier = $this->interface->putPacket($this, $packet, $needACK, false);
|
||||
|
||||
if($needACK and $identifier !== null){
|
||||
$this->needACK[$identifier] = false;
|
||||
|
||||
$timings->stopTiming();
|
||||
return $identifier;
|
||||
}
|
||||
|
||||
$timings->stopTiming();
|
||||
return true;
|
||||
return $this->sendDataPacket($packet, $needACK, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1097,6 +1067,17 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @return bool|int
|
||||
*/
|
||||
public function directDataPacket(DataPacket $packet, bool $needACK = false){
|
||||
return $this->sendDataPacket($packet, $needACK, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataPacket $packet
|
||||
* @param bool $needACK
|
||||
* @param bool $immediate
|
||||
*
|
||||
* @return bool|int
|
||||
*/
|
||||
public function sendDataPacket(DataPacket $packet, bool $needACK = false, bool $immediate = false){
|
||||
if($this->connected === false){
|
||||
return false;
|
||||
}
|
||||
@ -1114,7 +1095,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
$identifier = $this->interface->putPacket($this, $packet, $needACK, true);
|
||||
$identifier = $this->interface->putPacket($this, $packet, $needACK, $immediate);
|
||||
|
||||
if($needACK and $identifier !== null){
|
||||
$this->needACK[$identifier] = false;
|
||||
|
@ -119,9 +119,9 @@ interface ChunkManager{
|
||||
public function getChunk(int $chunkX, int $chunkZ);
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk $chunk
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null);
|
||||
|
||||
|
@ -2263,10 +2263,10 @@ class Level implements ChunkManager, Metadatable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk $chunk
|
||||
* @param bool $unload
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
* @param bool $unload
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null, bool $unload = true){
|
||||
if($chunk === null){
|
||||
|
@ -143,9 +143,9 @@ class SimpleChunkManager implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk $chunk
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, Chunk $chunk = null){
|
||||
if($chunk === null){
|
||||
|
Loading…
x
Reference in New Issue
Block a user