mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
Merge branch 'api3/network' into api3/network_mcpe-1.0.5
This commit is contained in:
commit
36cda5de61
@ -2133,12 +2133,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
$vector = new Vector3($packet->x, $packet->y, $packet->z);
|
$vector = new Vector3($packet->x, $packet->y, $packet->z);
|
||||||
|
|
||||||
if($this->isCreative()){
|
$item = $this->inventory->getItemInHand();
|
||||||
$item = $this->inventory->getItemInHand();
|
|
||||||
}else{
|
|
||||||
$item = $this->inventory->getItemInHand();
|
|
||||||
}
|
|
||||||
|
|
||||||
$oldItem = clone $item;
|
$oldItem = clone $item;
|
||||||
|
|
||||||
if($this->canInteract($vector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 6) and $this->level->useBreakOn($vector, $item, $this, true)){
|
if($this->canInteract($vector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 6) and $this->level->useBreakOn($vector, $item, $this, true)){
|
||||||
@ -3314,7 +3309,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: get rid of these remains, fix DataPacketReceiveEvent, fix timings
|
* Called when a packet is received from the client. This method will call DataPacketReceiveEvent.
|
||||||
*
|
*
|
||||||
* @param DataPacket $packet
|
* @param DataPacket $packet
|
||||||
*/
|
*/
|
||||||
@ -3323,18 +3318,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$timings = Timings::getReceiveDataPacketTimings($packet);
|
$timings = Timings::getReceiveDataPacketTimings($packet);
|
||||||
|
|
||||||
$timings->startTiming();
|
$timings->startTiming();
|
||||||
|
|
||||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
||||||
if($ev->isCancelled()){
|
if(!$ev->isCancelled() and !$packet->handle($this)){
|
||||||
$timings->stopTiming();
|
$this->server->getLogger()->debug("Unhandled " . get_class($packet) . " received from " . $this->getName());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$timings->stopTiming();
|
$timings->stopTiming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +431,6 @@ namespace pocketmine {
|
|||||||
"json" => "JSON",
|
"json" => "JSON",
|
||||||
"mbstring" => "Multibyte String",
|
"mbstring" => "Multibyte String",
|
||||||
"yaml" => "YAML",
|
"yaml" => "YAML",
|
||||||
"openssl" => "OpenSSL",
|
|
||||||
"sockets" => "Sockets",
|
"sockets" => "Sockets",
|
||||||
"zip" => "Zip",
|
"zip" => "Zip",
|
||||||
"zlib" => "Zlib"
|
"zlib" => "Zlib"
|
||||||
|
@ -237,10 +237,22 @@ class Network{
|
|||||||
return $this->server;
|
return $this->server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decodes a batch packet and does handling for it.
|
||||||
|
*
|
||||||
|
* TODO: Move this out of here
|
||||||
|
*
|
||||||
|
* @param BatchPacket $packet
|
||||||
|
* @param Player $player
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException|\InvalidStateException
|
||||||
|
*/
|
||||||
public function processBatch(BatchPacket $packet, Player $p){
|
public function processBatch(BatchPacket $packet, Player $p){
|
||||||
if(strlen($packet->payload) === 0){
|
$rawLen = strlen($packet->payload);
|
||||||
//prevent zlib_decode errors for incorrectly-decoded packets
|
if($rawLen === 0){
|
||||||
throw new \InvalidArgumentException("BatchPacket payload is empty or packet decode error");
|
throw new \InvalidArgumentException("BatchPacket payload is empty or packet decode error");
|
||||||
|
}elseif($rawLen < 3){
|
||||||
|
throw new \InvalidArgumentException("Not enough bytes, expected zlib header");
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB
|
$str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB
|
||||||
@ -264,10 +276,7 @@ class Network{
|
|||||||
|
|
||||||
$pk->decode();
|
$pk->decode();
|
||||||
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread in " . get_class($pk));
|
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread in " . get_class($pk));
|
||||||
if(!$pk->handle($p)){
|
$p->handleDataPacket($pk);
|
||||||
$logger = $this->server->getLogger();
|
|
||||||
$logger->debug("Unhandled " . get_class($pk) . " received from " . $p->getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,10 +135,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
|||||||
if($pk !== null){
|
if($pk !== null){
|
||||||
$pk->decode();
|
$pk->decode();
|
||||||
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread!");
|
assert($pk->feof(), "Still " . strlen(substr($pk->buffer, $pk->offset)) . " bytes unread!");
|
||||||
if(!$pk->handle($this->players[$identifier])){
|
$this->players[$identifier]->handleDataPacket($pk);
|
||||||
$logger = $this->server->getLogger();
|
|
||||||
$logger->debug("Unhandled " . get_class($pk) . " received from " . $this->players[$identifier]->getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
|
@ -111,7 +111,7 @@ class ZippedResourcePack implements ResourcePack{
|
|||||||
|
|
||||||
public function getSha256(bool $cached = true) : string{
|
public function getSha256(bool $cached = true) : string{
|
||||||
if($this->sha256 === null or !$cached){
|
if($this->sha256 === null or !$cached){
|
||||||
$this->sha256 = openssl_digest(file_get_contents($this->path), "sha256", true);
|
$this->sha256 = hash_file("sha256", $this->path, true);
|
||||||
}
|
}
|
||||||
return $this->sha256;
|
return $this->sha256;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user