diff --git a/changelogs/3.9.md b/changelogs/3.9.md index 8e2591f72..9e91d7c04 100644 --- a/changelogs/3.9.md +++ b/changelogs/3.9.md @@ -69,3 +69,8 @@ Plugin developers should **only** update their required API to this version if y - `Entity->despawnFromAll()` - Fixed plugin `softdepend` not influencing load order when a soft-depended plugin had an unresolved soft dependency of its own. - Fixed endless falling of sand on top of fences. + +# 3.9.5 +- Fixed some issues with multiple consecutive commas inside quotes in form responses. +- Fixed server crash when the manifest json does not contain a json object in a resource pack. +- Ender pearls no longer collide with blocks that do not have any collision boxes. diff --git a/src/Server.php b/src/Server.php index e33f943d6..62b98bc5a 100644 --- a/src/Server.php +++ b/src/Server.php @@ -430,7 +430,7 @@ class Server{ * @return int */ public function getDifficulty() : int{ - return $this->getConfigInt("difficulty", 1); + return $this->getConfigInt("difficulty", World::DIFFICULTY_NORMAL); } /** @@ -1022,7 +1022,7 @@ class Server{ "force-gamemode" => false, "hardcore" => false, "pvp" => true, - "difficulty" => 1, + "difficulty" => World::DIFFICULTY_NORMAL, "generator-settings" => "", "level-name" => "world", "level-seed" => "", diff --git a/src/command/defaults/TransferServerCommand.php b/src/command/defaults/TransferServerCommand.php index ebf1a4af1..9f102cb47 100644 --- a/src/command/defaults/TransferServerCommand.php +++ b/src/command/defaults/TransferServerCommand.php @@ -42,6 +42,10 @@ class TransferServerCommand extends VanillaCommand{ } public function execute(CommandSender $sender, string $commandLabel, array $args){ + if(!$this->testPermission($sender)){ + return true; + } + if(count($args) < 1){ throw new InvalidCommandSyntaxException(); }elseif(!($sender instanceof Player)){ diff --git a/src/inventory/CreativeInventory.php b/src/inventory/CreativeInventory.php index 2c2597c11..cf45cf786 100644 --- a/src/inventory/CreativeInventory.php +++ b/src/inventory/CreativeInventory.php @@ -52,6 +52,10 @@ final class CreativeInventory{ } } + /** + * Removes all previously added items from the creative menu. + * Note: Players who are already online when this is called will not see this change. + */ public static function clear(){ self::$creative = []; } @@ -82,10 +86,22 @@ final class CreativeInventory{ return -1; } + /** + * Adds an item to the creative menu. + * Note: Players who are already online when this is called will not see this change. + * + * @param Item $item + */ public static function add(Item $item){ self::$creative[] = clone $item; } + /** + * Removes an item from the creative menu. + * Note: Players who are already online when this is called will not see this change. + * + * @param Item $item + */ public static function remove(Item $item){ $index = self::getItemIndex($item); if($index !== -1){ diff --git a/src/network/mcpe/protocol/BossEventPacket.php b/src/network/mcpe/protocol/BossEventPacket.php index 01e9c2f73..3a504c695 100644 --- a/src/network/mcpe/protocol/BossEventPacket.php +++ b/src/network/mcpe/protocol/BossEventPacket.php @@ -39,9 +39,9 @@ class BossEventPacket extends DataPacket implements ClientboundPacket, Serverbou public const TYPE_HIDE = 2; /* C2S: Unregisters a player from a boss fight. */ public const TYPE_UNREGISTER_PLAYER = 3; - /* S2C: Appears not to be implemented. Currently bar percentage only appears to change in response to the target entity's health. */ + /* S2C: Sets the bar percentage. */ public const TYPE_HEALTH_PERCENT = 4; - /* S2C: Also appears to not be implemented. Title client-side sticks as the target entity's nametag, or their entity type name if not set. */ + /* S2C: Sets title of the bar. */ public const TYPE_TITLE = 5; /* S2C: Not sure on this. Includes color and overlay fields, plus an unknown short. TODO: check this */ public const TYPE_UNKNOWN_6 = 6; diff --git a/src/network/mcpe/protocol/EventPacket.php b/src/network/mcpe/protocol/EventPacket.php index 56786952d..d44edecd2 100644 --- a/src/network/mcpe/protocol/EventPacket.php +++ b/src/network/mcpe/protocol/EventPacket.php @@ -43,6 +43,11 @@ class EventPacket extends DataPacket implements ClientboundPacket{ public const TYPE_PATTERN_REMOVED = 10; //??? public const TYPE_COMMANED_EXECUTED = 11; public const TYPE_FISH_BUCKETED = 12; + public const TYPE_MOB_BORN = 13; + public const TYPE_PET_DIED = 14; + public const TYPE_CAULDRON_BLOCK_USED = 15; + public const TYPE_COMPOSTER_BLOCK_USED = 16; + public const TYPE_BELL_BLOCK_USED = 17; /** @var int */ public $playerRuntimeId; diff --git a/src/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php b/src/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php index e3816a454..1c11a57d4 100644 --- a/src/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php +++ b/src/network/mcpe/protocol/StructureTemplateDataExportRequestPacket.php @@ -26,16 +26,39 @@ namespace pocketmine\network\mcpe\protocol; #include use pocketmine\network\mcpe\handler\PacketHandler; +use pocketmine\network\mcpe\protocol\types\StructureSettings; class StructureTemplateDataExportRequestPacket extends DataPacket implements ServerboundPacket{ public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_EXPORT_REQUEST_PACKET; + public const TYPE_ALWAYS_LOAD = 1; + public const TYPE_CREATE_AND_LOAD = 2; + + /** @var string */ + public $structureTemplateName; + /** @var int */ + public $structureBlockX; + /** @var int */ + public $structureBlockY; + /** @var int */ + public $structureBlockZ; + /** @var StructureSettings */ + public $structureSettings; + /** @var int */ + public $structureTemplateResponseType; + protected function decodePayload() : void{ - //TODO + $this->structureTemplateName = $this->getString(); + $this->getBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); + $this->structureSettings = $this->getStructureSettings(); + $this->structureTemplateResponseType = $this->getByte(); } protected function encodePayload() : void{ - //TODO + $this->putString($this->structureTemplateName); + $this->putBlockPosition($this->structureBlockX, $this->structureBlockY, $this->structureBlockZ); + $this->putStructureSettings($this->structureSettings); + $this->putByte($this->structureTemplateResponseType); } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php b/src/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php index baeac7673..8336bfa63 100644 --- a/src/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php +++ b/src/network/mcpe/protocol/StructureTemplateDataExportResponsePacket.php @@ -30,12 +30,24 @@ use pocketmine\network\mcpe\handler\PacketHandler; class StructureTemplateDataExportResponsePacket extends DataPacket implements ClientboundPacket{ public const NETWORK_ID = ProtocolInfo::STRUCTURE_TEMPLATE_DATA_EXPORT_RESPONSE_PACKET; + /** @var string */ + public $structureTemplateName; + /** @var string|null */ + public $namedtag; + protected function decodePayload() : void{ - //TODO + $this->structureTemplateName = $this->getString(); + if($this->getBool()){ + $this->namedtag = $this->getRemaining(); + } } protected function encodePayload() : void{ - //TODO + $this->putString($this->structureTemplateName); + $this->putBool($this->namedtag !== null); + if($this->namedtag !== null){ + $this->put($this->namedtag); + } } public function handle(PacketHandler $handler) : bool{ diff --git a/src/network/mcpe/protocol/types/StructureSettings.php b/src/network/mcpe/protocol/types/StructureSettings.php new file mode 100644 index 000000000..465e643cc --- /dev/null +++ b/src/network/mcpe/protocol/types/StructureSettings.php @@ -0,0 +1,55 @@ +putVarLong($data->varlong1); } } + + protected function getStructureSettings() : StructureSettings{ + $result = new StructureSettings(); + + $result->paletteName = $this->getString(); + + $result->ignoreEntities = $this->getBool(); + $result->ignoreBlocks = $this->getBool(); + + $this->getBlockPosition($result->structureSizeX, $result->structureSizeY, $result->structureSizeZ); + $this->getBlockPosition($result->structureOffsetX, $result->structureOffsetY, $result->structureOffsetZ); + + $result->lastTouchedByPlayerID = $this->getEntityUniqueId(); + $result->rotation = $this->getByte(); + $result->mirror = $this->getByte(); + $result->integrityValue = $this->getFloat(); + $result->integritySeed = $this->getInt(); + + return $result; + } + + protected function putStructureSettings(StructureSettings $structureSettings) : void{ + $this->putString($structureSettings->paletteName); + + $this->putBool($structureSettings->ignoreEntities); + $this->putBool($structureSettings->ignoreBlocks); + + $this->putBlockPosition($structureSettings->structureSizeX, $structureSettings->structureSizeY, $structureSettings->structureSizeZ); + $this->putBlockPosition($structureSettings->structureOffsetX, $structureSettings->structureOffsetY, $structureSettings->structureOffsetZ); + + $this->putEntityUniqueId($structureSettings->lastTouchedByPlayerID); + $this->putByte($structureSettings->rotation); + $this->putByte($structureSettings->mirror); + $this->putFloat($structureSettings->integrityValue); + $this->putInt($structureSettings->integritySeed); + } } diff --git a/src/utils/Internet.php b/src/utils/Internet.php index bd56cb9d4..9d7f5777f 100644 --- a/src/utils/Internet.php +++ b/src/utils/Internet.php @@ -210,7 +210,7 @@ class Internet{ CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT_MS => (int) ($timeout * 1000), CURLOPT_TIMEOUT_MS => (int) ($timeout * 1000), - CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . \pocketmine\NAME], $extraHeaders), + CURLOPT_HTTPHEADER => array_merge(["User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0 " . \pocketmine\NAME . "/" . \pocketmine\VERSION], $extraHeaders), CURLOPT_HEADER => true ]); try{ diff --git a/src/wizard/SetupWizard.php b/src/wizard/SetupWizard.php index a0c6f67be..86d49b554 100644 --- a/src/wizard/SetupWizard.php +++ b/src/wizard/SetupWizard.php @@ -29,6 +29,7 @@ namespace pocketmine\wizard; use pocketmine\lang\Language; use pocketmine\lang\LanguageNotFoundException; +use pocketmine\player\GameMode; use pocketmine\utils\Config; use pocketmine\utils\Internet; use pocketmine\utils\InternetException; @@ -43,7 +44,6 @@ class SetupWizard{ public const DEFAULT_NAME = \pocketmine\NAME . " Server"; public const DEFAULT_PORT = 19132; public const DEFAULT_PLAYERS = 20; - public const DEFAULT_GAMEMODE = 0; /** @var Language */ private $lang; @@ -155,7 +155,7 @@ LICENSE; $this->message($this->lang->get("gamemode_info")); do{ - $gamemode = (int) $this->getInput($this->lang->get("default_gamemode"), (string) self::DEFAULT_GAMEMODE); + $gamemode = (int) $this->getInput($this->lang->get("default_gamemode"), (string) GameMode::SURVIVAL()->getMagicNumber()); }while($gamemode < 0 or $gamemode > 3); $config->set("gamemode", $gamemode); diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 5805c6d46..3e3a95a68 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -87,6 +87,9 @@ class Explosion{ } /** + * Calculates which blocks will be destroyed by this explosion. If explodeB() is called without calling this, no blocks + * will be destroyed. + * * @return bool */ public function explodeA() : bool{ @@ -147,6 +150,12 @@ class Explosion{ return true; } + /** + * Executes the explosion's effects on the world. This includes destroying blocks (if any), harming and knocking back entities, + * and creating sounds and particles. + * + * @return bool + */ public function explodeB() : bool{ $send = []; $updateBlocks = [];