mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Merge remote-tracking branch 'origin/stable'
This commit is contained in:
commit
ad048f0b7f
@ -8,7 +8,7 @@
|
||||
## Custom PHP binaries
|
||||
Because PocketMine-MP requires several non-standard PHP extensions and configuration, PMMP provides scripts to build custom binaries for running PocketMine-MP, as well as prebuilt binaries.
|
||||
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.3-Aggregate)
|
||||
- [Prebuilt binaries](https://jenkins.pmmp.io/job/PHP-7.4-Aggregate)
|
||||
- [Compile scripts](https://github.com/pmmp/php-build-scripts) are provided as a submodule in the path `build/php`
|
||||
|
||||
If you use a custom binary, you'll need to replace `composer` usages in this guide with `path/to/your/php path/to/your/composer.phar`.
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
## For developers
|
||||
* [Building and running from source](BUILDING.md)
|
||||
* [Developer documentation](https://devdoc.pmmp.io) - General documentation for PocketMine-MP plugin developers
|
||||
* [Latest API documentation](https://jenkins.pmmp.io/job/PocketMine-MP-doc/doxygen/) - Doxygen documentation generated from development
|
||||
* [DevTools](https://github.com/pmmp/DevTools/) - Development tools plugin for creating plugins
|
||||
* [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
|
@ -50,7 +50,7 @@
|
||||
"respect/validation": "^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "0.12.81",
|
||||
"phpstan/phpstan": "0.12.82",
|
||||
"phpstan/phpstan-phpunit": "^0.12.6",
|
||||
"phpstan/phpstan-strict-rules": "^0.12.2",
|
||||
"phpunit/phpunit": "^9.2"
|
||||
|
@ -7,4 +7,4 @@ This site can be accessed via https://apidoc.pmmp.io.
|
||||
### Additional developer resources
|
||||
- [DevTools](https://github.com/pmmp/DevTools/) - Development tools plugin for creating plugins
|
||||
- [ExamplePlugin](https://github.com/pmmp/ExamplePlugin/) - Example plugin demonstrating some basic API features
|
||||
- [DeveloperDocs](https://github.com/pmmp/DeveloperDocs/) - Reference, guides and specifications for the PocketMine-MP API
|
||||
- [DeveloperDocs](https://devdoc.pmmp.io) - General documentation for PocketMine-MP plugin developers
|
||||
|
@ -114,37 +114,28 @@ class CommandReader extends Thread{
|
||||
* @return bool if the main execution should continue reading lines
|
||||
*/
|
||||
private function readLine() : bool{
|
||||
$line = "";
|
||||
|
||||
if(!is_resource(self::$stdin)){
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
switch($this->type){
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case self::TYPE_STREAM:
|
||||
//stream_select doesn't work on piped streams for some reason
|
||||
$r = [self::$stdin];
|
||||
$w = $e = null;
|
||||
if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds
|
||||
return true;
|
||||
}elseif($count === false){ //stream error
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
case self::TYPE_PIPED:
|
||||
if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF
|
||||
$this->initStdin();
|
||||
$this->synchronized(function() : void{
|
||||
$this->wait(200000);
|
||||
}); //prevent CPU waste if it's end of pipe
|
||||
return true; //loop back round
|
||||
}
|
||||
|
||||
$line = trim($raw);
|
||||
break;
|
||||
$r = [self::$stdin];
|
||||
$w = $e = null;
|
||||
if(($count = stream_select($r, $w, $e, 0, 200000)) === 0){ //nothing changed in 200000 microseconds
|
||||
return true;
|
||||
}elseif($count === false){ //stream error
|
||||
$this->initStdin();
|
||||
}
|
||||
|
||||
if(($raw = fgets(self::$stdin)) === false){ //broken pipe or EOF
|
||||
$this->initStdin();
|
||||
$this->synchronized(function() : void{
|
||||
$this->wait(200000);
|
||||
}); //prevent CPU waste if it's end of pipe
|
||||
return true; //loop back round
|
||||
}
|
||||
|
||||
$line = trim($raw);
|
||||
|
||||
if($line !== ""){
|
||||
$this->buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line);
|
||||
if($this->notifier !== null){
|
||||
|
@ -98,6 +98,8 @@ use function base64_encode;
|
||||
use function count;
|
||||
use function fmod;
|
||||
use function implode;
|
||||
use function is_infinite;
|
||||
use function is_nan;
|
||||
use function json_decode;
|
||||
use function json_encode;
|
||||
use function json_last_error_msg;
|
||||
@ -153,6 +155,14 @@ class InGamePacketHandler extends PacketHandler{
|
||||
}
|
||||
|
||||
public function handleMovePlayer(MovePlayerPacket $packet) : bool{
|
||||
$rawPos = $packet->position;
|
||||
foreach([$rawPos->x, $rawPos->y, $rawPos->z, $packet->yaw, $packet->headYaw, $packet->pitch] as $float){
|
||||
if(is_infinite($float) || is_nan($float)){
|
||||
$this->session->getLogger()->debug("Invalid movement received, contains NAN/INF components");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$yaw = fmod($packet->yaw, 360);
|
||||
$pitch = fmod($packet->pitch, 360);
|
||||
if($yaw < 0){
|
||||
|
@ -49,25 +49,26 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* ARG_FLAG_VALID | (type const)
|
||||
*/
|
||||
public const ARG_TYPE_INT = 0x01;
|
||||
public const ARG_TYPE_FLOAT = 0x02;
|
||||
public const ARG_TYPE_VALUE = 0x03;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x04;
|
||||
public const ARG_TYPE_OPERATOR = 0x05;
|
||||
public const ARG_TYPE_TARGET = 0x06;
|
||||
public const ARG_TYPE_FLOAT = 0x03;
|
||||
public const ARG_TYPE_VALUE = 0x04;
|
||||
public const ARG_TYPE_WILDCARD_INT = 0x05;
|
||||
public const ARG_TYPE_OPERATOR = 0x06;
|
||||
public const ARG_TYPE_TARGET = 0x07;
|
||||
public const ARG_TYPE_WILDCARD_TARGET = 0x08;
|
||||
|
||||
public const ARG_TYPE_FILEPATH = 0x0e;
|
||||
public const ARG_TYPE_FILEPATH = 0x10;
|
||||
|
||||
public const ARG_TYPE_STRING = 0x1d;
|
||||
public const ARG_TYPE_STRING = 0x20;
|
||||
|
||||
public const ARG_TYPE_POSITION = 0x25;
|
||||
public const ARG_TYPE_POSITION = 0x28;
|
||||
|
||||
public const ARG_TYPE_MESSAGE = 0x29;
|
||||
public const ARG_TYPE_MESSAGE = 0x2c;
|
||||
|
||||
public const ARG_TYPE_RAWTEXT = 0x2b;
|
||||
public const ARG_TYPE_RAWTEXT = 0x2e;
|
||||
|
||||
public const ARG_TYPE_JSON = 0x2f;
|
||||
public const ARG_TYPE_JSON = 0x32;
|
||||
|
||||
public const ARG_TYPE_COMMAND = 0x36;
|
||||
public const ARG_TYPE_COMMAND = 0x3f;
|
||||
|
||||
/**
|
||||
* Enums are a little different: they are composed as follows:
|
||||
|
@ -34,6 +34,11 @@ use function count;
|
||||
class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::COMMAND_OUTPUT_PACKET;
|
||||
|
||||
public const TYPE_LAST = 1;
|
||||
public const TYPE_SILENT = 2;
|
||||
public const TYPE_ALL = 3;
|
||||
public const TYPE_DATA_SET = 4;
|
||||
|
||||
/** @var CommandOriginData */
|
||||
public $originData;
|
||||
/** @var int */
|
||||
@ -54,7 +59,7 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
$this->messages[] = $this->getCommandMessage($in);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$this->unknownString = $in->getString();
|
||||
}
|
||||
}
|
||||
@ -85,7 +90,7 @@ class CommandOutputPacket extends DataPacket implements ClientboundPacket{
|
||||
$this->putCommandMessage($message, $out);
|
||||
}
|
||||
|
||||
if($this->outputType === 4){
|
||||
if($this->outputType === self::TYPE_DATA_SET){
|
||||
$out->putString($this->unknownString);
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,13 @@ class EventPacket extends DataPacket implements ClientboundPacket{
|
||||
public const TYPE_CAULDRON_BLOCK_USED = 15;
|
||||
public const TYPE_COMPOSTER_BLOCK_USED = 16;
|
||||
public const TYPE_BELL_BLOCK_USED = 17;
|
||||
public const TYPE_ACTOR_DEFINITION = 18;
|
||||
public const TYPE_RAID_UPDATE = 19;
|
||||
public const TYPE_PLAYER_MOVEMENT_ANOMALY = 20; //anti cheat
|
||||
public const TYPE_PLAYER_MOVEMENT_CORRECTED = 21;
|
||||
public const TYPE_HONEY_HARVESTED = 22;
|
||||
public const TYPE_TARGET_BLOCK_HIT = 23;
|
||||
public const TYPE_PIGLIN_BARTER = 24;
|
||||
|
||||
/** @var int */
|
||||
public $playerRuntimeId;
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
||||
use pocketmine\network\mcpe\protocol\types\InputMode;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayerAuthInputFlags;
|
||||
use pocketmine\network\mcpe\protocol\types\PlayMode;
|
||||
use function assert;
|
||||
|
||||
@ -60,6 +61,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
private $delta;
|
||||
|
||||
/**
|
||||
* @param int $inputFlags @see InputFlags
|
||||
* @param int $inputMode @see InputMode
|
||||
* @param int $playMode @see PlayMode
|
||||
* @param Vector3|null $vrGazeDirection only used when PlayMode::VR
|
||||
@ -111,6 +113,9 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
|
||||
return $this->moveVecZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PlayerAuthInputFlags
|
||||
*/
|
||||
public function getInputFlags() : int{
|
||||
return $this->inputFlags;
|
||||
}
|
||||
|
@ -36,6 +36,9 @@ class SetTitlePacket extends DataPacket implements ClientboundPacket{
|
||||
public const TYPE_SET_SUBTITLE = 3;
|
||||
public const TYPE_SET_ACTIONBAR_MESSAGE = 4;
|
||||
public const TYPE_SET_ANIMATION_TIMES = 5;
|
||||
public const TYPE_SET_TITLE_JSON = 6;
|
||||
public const TYPE_SET_SUBTITLE_JSON = 7;
|
||||
public const TYPE_SET_ACTIONBAR_MESSAGE_JSON = 8;
|
||||
|
||||
/** @var int */
|
||||
public $type;
|
||||
|
75
src/network/mcpe/protocol/types/PlayerAuthInputFlags.php
Normal file
75
src/network/mcpe/protocol/types/PlayerAuthInputFlags.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket;
|
||||
|
||||
/**
|
||||
* These flags are used in PlayerAuthInputPacket's inputFlags field.
|
||||
* The flags should be written as
|
||||
* `flags |= (1 << flag)`
|
||||
* and read as
|
||||
* `(flags & (1 & flag)) !== 0`
|
||||
*
|
||||
* @see PlayerAuthInputPacket
|
||||
*/
|
||||
final class PlayerAuthInputFlags{
|
||||
public const ASCEND = 0;
|
||||
public const DESCEND = 1;
|
||||
public const NORTH_JUMP = 2;
|
||||
public const JUMP_DOWN = 3;
|
||||
public const SPRINT_DOWN = 4;
|
||||
public const CHANGE_HEIGHT = 5;
|
||||
public const JUMPING = 6;
|
||||
public const AUTO_JUMPING_IN_WATER = 7;
|
||||
public const SNEAKING = 8;
|
||||
public const SNEAK_DOWN = 9;
|
||||
public const UP = 10;
|
||||
public const DOWN = 11;
|
||||
public const LEFT = 12;
|
||||
public const RIGHT = 13;
|
||||
public const UP_LEFT = 14;
|
||||
public const UP_RIGHT = 15;
|
||||
public const WANT_UP = 16;
|
||||
public const WANT_DOWN = 17;
|
||||
public const WANT_DOWN_SLOW = 18;
|
||||
public const WANT_UP_SLOW = 19;
|
||||
public const SPRINTING = 20;
|
||||
public const ASCEND_SCAFFOLDING = 21;
|
||||
public const DESCEND_SCAFFOLDING = 22;
|
||||
public const SNEAK_TOGGLE_DOWN = 23;
|
||||
public const PERSIST_SNEAK = 24;
|
||||
public const START_SPRINTING = 25;
|
||||
public const STOP_SPRINTING = 26;
|
||||
public const START_SNEAKING = 27;
|
||||
public const STOP_SNEAKING = 28;
|
||||
public const START_SWIMMING = 29;
|
||||
public const STOP_SWIMMING = 30;
|
||||
public const START_JUMPING = 31;
|
||||
public const START_GLIDING = 32;
|
||||
public const STOP_GLIDING = 33;
|
||||
public const PERFORM_ITEM_INTERACTION = 34;
|
||||
public const PERFORM_BLOCK_ACTIONS = 35;
|
||||
public const PERFORM_ITEM_STACK_REQUEST = 36;
|
||||
}
|
@ -40,16 +40,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/event/entity/EntityShootBowEvent.php
|
||||
|
||||
-
|
||||
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/WorldManager.php
|
||||
|
||||
-
|
||||
message: "#^Cannot instantiate interface pocketmine\\\\world\\\\format\\\\io\\\\WritableWorldProvider\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/FormatConverter.php
|
||||
|
||||
-
|
||||
message: "#^Variable property access on \\$this\\(pocketmine\\\\world\\\\generator\\\\PopulationTask\\)\\.$#"
|
||||
count: 4
|
||||
|
@ -5,11 +5,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/CrashDump.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$subject of function preg_replace expects array\\|string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/CrashDump.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset float\\|int on mixed\\.$#"
|
||||
count: 1
|
||||
@ -20,11 +15,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/CrashDump.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'name' on mixed\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/CrashDump.php
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to int\\.$#"
|
||||
count: 7
|
||||
@ -275,11 +265,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/utils/MainLogger.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$str of function fwrite expects string, mixed given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/utils/MainLoggerThread.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset 'status' on mixed\\.$#"
|
||||
count: 1
|
||||
@ -345,21 +330,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/world/generator/Flat.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#4 \\$q0 of static method pocketmine\\\\world\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, mixed given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/generator/noise/Noise.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#5 \\$q1 of static method pocketmine\\\\world\\\\generator\\\\noise\\\\Noise\\:\\:linearLerp\\(\\) expects float, mixed given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/generator/noise/Noise.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset int on mixed\\.$#"
|
||||
count: 6
|
||||
path: ../../../src/world/generator/noise/Noise.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess, mixed given\\.$#"
|
||||
count: 1
|
||||
|
@ -660,16 +660,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/network/mcpe/protocol/types/inventory/UseItemTransactionData.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:Add\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/network/upnp/UPnP.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:Remove\\(\\)\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/network/upnp/UPnP.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<int, pocketmine\\\\player\\\\UsedChunkStatus\\>\\) does not accept key \\(int\\|string\\)\\.$#"
|
||||
count: 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user