mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-19 09:26:45 +00:00
Merge branch 'next-minor' into next-major
This commit is contained in:
commit
f8cc015c51
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -202,6 +202,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
php-version: 8.0
|
php-version: 8.0
|
||||||
tools: php-cs-fixer:3.11
|
tools: php-cs-fixer:3.11
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Run PHP-CS-Fixer
|
- name: Run PHP-CS-Fixer
|
||||||
run: php-cs-fixer fix --dry-run --diff --ansi
|
run: php-cs-fixer fix --dry-run --diff --ansi
|
||||||
|
12
composer.lock
generated
12
composer.lock
generated
@ -1825,16 +1825,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan-phpunit",
|
"name": "phpstan/phpstan-phpunit",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan-phpunit.git",
|
"url": "https://github.com/phpstan/phpstan-phpunit.git",
|
||||||
"reference": "cd9c6938f8bbfcb6da3ed5a3c7ea60873825d088"
|
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/cd9c6938f8bbfcb6da3ed5a3c7ea60873825d088",
|
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/54a24bd23e9e80ee918cdc24f909d376c2e273f7",
|
||||||
"reference": "cd9c6938f8bbfcb6da3ed5a3c7ea60873825d088",
|
"reference": "54a24bd23e9e80ee918cdc24f909d376c2e273f7",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1871,9 +1871,9 @@
|
|||||||
"description": "PHPUnit extensions and rules for PHPStan",
|
"description": "PHPUnit extensions and rules for PHPStan",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
|
"issues": "https://github.com/phpstan/phpstan-phpunit/issues",
|
||||||
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.2"
|
"source": "https://github.com/phpstan/phpstan-phpunit/tree/1.3.3"
|
||||||
},
|
},
|
||||||
"time": "2022-12-13T15:08:22+00:00"
|
"time": "2022-12-21T15:25:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan-strict-rules",
|
"name": "phpstan/phpstan-strict-rules",
|
||||||
|
@ -68,6 +68,11 @@ class GamemodeCommand extends VanillaCommand{
|
|||||||
throw new InvalidCommandSyntaxException();
|
throw new InvalidCommandSyntaxException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($target->getGamemode()->equals($gameMode)){
|
||||||
|
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
$target->setGamemode($gameMode);
|
$target->setGamemode($gameMode);
|
||||||
if(!$gameMode->equals($target->getGamemode())){
|
if(!$gameMode->equals($target->getGamemode())){
|
||||||
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
|
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_gamemode_failure($target->getName()));
|
||||||
|
@ -31,6 +31,10 @@ class HandlerList{
|
|||||||
/** @var RegisteredListener[][] */
|
/** @var RegisteredListener[][] */
|
||||||
private array $handlerSlots = [];
|
private array $handlerSlots = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-template TEvent of Event
|
||||||
|
* @phpstan-param class-string<TEvent> $class
|
||||||
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private string $class,
|
private string $class,
|
||||||
private ?HandlerList $parentList
|
private ?HandlerList $parentList
|
||||||
|
@ -746,9 +746,9 @@ class NetworkSession{
|
|||||||
$this->setHandler(new InGamePacketHandler($this->player, $this, $this->invManager));
|
$this->setHandler(new InGamePacketHandler($this->player, $this, $this->invManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onServerDeath() : void{
|
public function onServerDeath(Translatable|string $deathMessage) : void{
|
||||||
if($this->handler instanceof InGamePacketHandler){ //TODO: this is a bad fix for pre-spawn death, this shouldn't be reachable at all at this stage :(
|
if($this->handler instanceof InGamePacketHandler){ //TODO: this is a bad fix for pre-spawn death, this shouldn't be reachable at all at this stage :(
|
||||||
$this->setHandler(new DeathPacketHandler($this->player, $this, $this->invManager ?? throw new AssumptionFailedError()));
|
$this->setHandler(new DeathPacketHandler($this->player, $this, $this->invManager ?? throw new AssumptionFailedError(), $deathMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,15 +933,22 @@ class NetworkSession{
|
|||||||
$this->sendDataPacket(AvailableCommandsPacket::create($commandData, [], [], []));
|
$this->sendDataPacket(AvailableCommandsPacket::create($commandData, [], [], []));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRawChatMessage(string $message) : void{
|
public function onChatMessage(Translatable|string $message) : void{
|
||||||
|
if($message instanceof Translatable){
|
||||||
|
//we can't send nested translations to the client, so make sure they are always pre-translated by the server
|
||||||
|
$language = $this->player->getLanguage();
|
||||||
|
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $language->translate($p) : $p, $message->getParameters());
|
||||||
|
if(!$this->server->isLanguageForced()){
|
||||||
|
foreach($parameters as $i => $p){
|
||||||
|
$parameters[$i] = $language->translateString($p, [], "pocketmine.");
|
||||||
|
}
|
||||||
|
$this->sendDataPacket(TextPacket::translation($language->translateString($message->getText(), $parameters, "pocketmine."), $parameters));
|
||||||
|
}else{
|
||||||
|
$this->sendDataPacket(TextPacket::raw($language->translateString($message->getText(), $parameters)));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
$this->sendDataPacket(TextPacket::raw($message));
|
$this->sendDataPacket(TextPacket::raw($message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string[] $parameters
|
|
||||||
*/
|
|
||||||
public function onTranslatedChatMessage(string $key, array $parameters) : void{
|
|
||||||
$this->sendDataPacket(TextPacket::translation($key, $parameters));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,19 +23,23 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\network\mcpe\handler;
|
namespace pocketmine\network\mcpe\handler;
|
||||||
|
|
||||||
|
use pocketmine\lang\Translatable;
|
||||||
use pocketmine\network\mcpe\InventoryManager;
|
use pocketmine\network\mcpe\InventoryManager;
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
use pocketmine\network\mcpe\protocol\ContainerClosePacket;
|
||||||
|
use pocketmine\network\mcpe\protocol\DeathInfoPacket;
|
||||||
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
use pocketmine\network\mcpe\protocol\PlayerActionPacket;
|
||||||
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
use pocketmine\network\mcpe\protocol\RespawnPacket;
|
||||||
use pocketmine\network\mcpe\protocol\types\PlayerAction;
|
use pocketmine\network\mcpe\protocol\types\PlayerAction;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
|
use function array_map;
|
||||||
|
|
||||||
class DeathPacketHandler extends PacketHandler{
|
class DeathPacketHandler extends PacketHandler{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private Player $player,
|
private Player $player,
|
||||||
private NetworkSession $session,
|
private NetworkSession $session,
|
||||||
private InventoryManager $inventoryManager
|
private InventoryManager $inventoryManager,
|
||||||
|
private Translatable|string $deathMessage
|
||||||
){}
|
){}
|
||||||
|
|
||||||
public function setUp() : void{
|
public function setUp() : void{
|
||||||
@ -44,6 +48,26 @@ class DeathPacketHandler extends PacketHandler{
|
|||||||
RespawnPacket::SEARCHING_FOR_SPAWN,
|
RespawnPacket::SEARCHING_FOR_SPAWN,
|
||||||
$this->player->getId()
|
$this->player->getId()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/** @var string[] $parameters */
|
||||||
|
$parameters = [];
|
||||||
|
if($this->deathMessage instanceof Translatable){
|
||||||
|
//we can't send nested translations to the client, so make sure they are always pre-translated by the server
|
||||||
|
$language = $this->player->getLanguage();
|
||||||
|
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $language->translate($p) : $p, $this->deathMessage->getParameters());
|
||||||
|
if(!$this->player->getServer()->isLanguageForced()){
|
||||||
|
foreach($parameters as $i => $p){
|
||||||
|
$parameters[$i] = $language->translateString($p, [], "pocketmine.");
|
||||||
|
}
|
||||||
|
$message = $language->translateString($this->deathMessage->getText(), $parameters, "pocketmine.");
|
||||||
|
}else{
|
||||||
|
$message = $language->translateString($this->deathMessage->getText(), $parameters);
|
||||||
|
$parameters = [];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$message = $this->deathMessage;
|
||||||
|
}
|
||||||
|
$this->session->sendDataPacket(DeathInfoPacket::create($message, $parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
public function handlePlayerAction(PlayerActionPacket $packet) : bool{
|
||||||
|
@ -53,16 +53,16 @@ class PermissionParser{
|
|||||||
"false" => self::DEFAULT_FALSE,
|
"false" => self::DEFAULT_FALSE,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
private const KEY_DEFAULT = "default";
|
||||||
|
private const KEY_CHILDREN = "children";
|
||||||
|
private const KEY_DESCRIPTION = "description";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws PermissionParserException
|
* @throws PermissionParserException
|
||||||
*/
|
*/
|
||||||
public static function defaultFromString(bool|string $value) : string{
|
public static function defaultFromString(bool|string $value) : string{
|
||||||
if(is_bool($value)){
|
if(is_bool($value)){
|
||||||
if($value){
|
return $value ? self::DEFAULT_TRUE : self::DEFAULT_FALSE;
|
||||||
return "true";
|
|
||||||
}else{
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$lower = strtolower($value);
|
$lower = strtolower($value);
|
||||||
if(isset(self::DEFAULT_STRING_MAP[$lower])){
|
if(isset(self::DEFAULT_STRING_MAP[$lower])){
|
||||||
@ -84,16 +84,16 @@ class PermissionParser{
|
|||||||
$result = [];
|
$result = [];
|
||||||
foreach(Utils::stringifyKeys($data) as $name => $entry){
|
foreach(Utils::stringifyKeys($data) as $name => $entry){
|
||||||
$desc = null;
|
$desc = null;
|
||||||
if(isset($entry["default"])){
|
if(isset($entry[self::KEY_DEFAULT])){
|
||||||
$default = PermissionParser::defaultFromString($entry["default"]);
|
$default = PermissionParser::defaultFromString($entry[self::KEY_DEFAULT]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($entry["children"])){
|
if(isset($entry[self::KEY_CHILDREN])){
|
||||||
throw new PermissionParserException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
throw new PermissionParserException("Nested permission declarations are no longer supported. Declare each permission separately.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($entry["description"])){
|
if(isset($entry[self::KEY_DESCRIPTION])){
|
||||||
$desc = $entry["description"];
|
$desc = $entry[self::KEY_DESCRIPTION];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result[$default][] = new Permission($name, $desc);
|
$result[$default][] = new Permission($name, $desc);
|
||||||
|
@ -132,7 +132,6 @@ use pocketmine\world\World;
|
|||||||
use Ramsey\Uuid\UuidInterface;
|
use Ramsey\Uuid\UuidInterface;
|
||||||
use function abs;
|
use function abs;
|
||||||
use function array_filter;
|
use function array_filter;
|
||||||
use function array_map;
|
|
||||||
use function array_shift;
|
use function array_shift;
|
||||||
use function assert;
|
use function assert;
|
||||||
use function count;
|
use function count;
|
||||||
@ -2012,28 +2011,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
* Sends a direct chat message to a player
|
* Sends a direct chat message to a player
|
||||||
*/
|
*/
|
||||||
public function sendMessage(Translatable|string $message) : void{
|
public function sendMessage(Translatable|string $message) : void{
|
||||||
if($message instanceof Translatable){
|
$this->getNetworkSession()->onChatMessage($message);
|
||||||
$this->sendTranslation($message->getText(), $message->getParameters());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getNetworkSession()->onRawChatMessage($message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @deprecated Use {@link Player::sendMessage()} with a Translatable instead.
|
||||||
* @param string[]|Translatable[] $parameters
|
* @param string[]|Translatable[] $parameters
|
||||||
*/
|
*/
|
||||||
public function sendTranslation(string $message, array $parameters = []) : void{
|
public function sendTranslation(string $message, array $parameters = []) : void{
|
||||||
//we can't send nested translations to the client, so make sure they are always pre-translated by the server
|
$this->sendMessage(new Translatable($message, $parameters));
|
||||||
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $this->getLanguage()->translate($p) : $p, $parameters);
|
|
||||||
if(!$this->server->isLanguageForced()){
|
|
||||||
foreach($parameters as $i => $p){
|
|
||||||
$parameters[$i] = $this->getLanguage()->translateString($p, [], "pocketmine.");
|
|
||||||
}
|
|
||||||
$this->getNetworkSession()->onTranslatedChatMessage($this->getLanguage()->translateString($message, $parameters, "pocketmine."), $parameters);
|
|
||||||
}else{
|
|
||||||
$this->sendMessage($this->getLanguage()->translateString($message, $parameters));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2309,7 +2295,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
|||||||
|
|
||||||
$this->startDeathAnimation();
|
$this->startDeathAnimation();
|
||||||
|
|
||||||
$this->getNetworkSession()->onServerDeath();
|
$this->getNetworkSession()->onServerDeath($ev->getDeathMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function onDeathUpdate(int $tickDiff) : bool{
|
protected function onDeathUpdate(int $tickDiff) : bool{
|
||||||
|
@ -37,6 +37,32 @@ use function stripos;
|
|||||||
use function yaml_parse;
|
use function yaml_parse;
|
||||||
|
|
||||||
class PluginDescription{
|
class PluginDescription{
|
||||||
|
private const KEY_NAME = "name";
|
||||||
|
private const KEY_VERSION = "version";
|
||||||
|
private const KEY_MAIN = "main";
|
||||||
|
private const KEY_SRC_NAMESPACE_PREFIX = "src-namespace-prefix";
|
||||||
|
private const KEY_API = "api";
|
||||||
|
private const KEY_MCPE_PROTOCOL = "mcpe-protocol";
|
||||||
|
private const KEY_OS = "os";
|
||||||
|
private const KEY_DEPEND = "depend";
|
||||||
|
private const KEY_SOFTDEPEND = "softdepend";
|
||||||
|
private const KEY_LOADBEFORE = "loadbefore";
|
||||||
|
private const KEY_EXTENSIONS = "extensions";
|
||||||
|
private const KEY_WEBSITE = "website";
|
||||||
|
private const KEY_DESCRIPTION = "description";
|
||||||
|
private const KEY_LOGGER_PREFIX = "prefix";
|
||||||
|
private const KEY_LOAD = "load";
|
||||||
|
private const KEY_AUTHOR = "author";
|
||||||
|
private const KEY_AUTHORS = "authors";
|
||||||
|
private const KEY_PERMISSIONS = "permissions";
|
||||||
|
|
||||||
|
private const KEY_COMMANDS = "commands";
|
||||||
|
private const KEY_COMMAND_PERMISSION = "permission";
|
||||||
|
private const KEY_COMMAND_DESCRIPTION = self::KEY_DESCRIPTION;
|
||||||
|
private const KEY_COMMAND_USAGE = "usage";
|
||||||
|
private const KEY_COMMAND_ALIASES = "aliases";
|
||||||
|
private const KEY_COMMAND_PERMISSION_MESSAGE = "permission-message";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var mixed[]
|
* @var mixed[]
|
||||||
* @phpstan-var array<string, mixed>
|
* @phpstan-var array<string, mixed>
|
||||||
@ -107,49 +133,49 @@ class PluginDescription{
|
|||||||
private function loadMap(array $plugin) : void{
|
private function loadMap(array $plugin) : void{
|
||||||
$this->map = $plugin;
|
$this->map = $plugin;
|
||||||
|
|
||||||
$this->name = $plugin["name"];
|
$this->name = $plugin[self::KEY_NAME];
|
||||||
if(preg_match('/^[A-Za-z0-9 _.-]+$/', $this->name) === 0){
|
if(preg_match('/^[A-Za-z0-9 _.-]+$/', $this->name) === 0){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin name");
|
throw new PluginDescriptionParseException("Invalid Plugin name");
|
||||||
}
|
}
|
||||||
$this->name = str_replace(" ", "_", $this->name);
|
$this->name = str_replace(" ", "_", $this->name);
|
||||||
$this->version = (string) $plugin["version"];
|
$this->version = (string) $plugin[self::KEY_VERSION];
|
||||||
$this->main = $plugin["main"];
|
$this->main = $plugin[self::KEY_MAIN];
|
||||||
if(stripos($this->main, "pocketmine\\") === 0){
|
if(stripos($this->main, "pocketmine\\") === 0){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin main, cannot start within the PocketMine namespace");
|
throw new PluginDescriptionParseException("Invalid Plugin main, cannot start within the PocketMine namespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->srcNamespacePrefix = $plugin["src-namespace-prefix"] ?? "";
|
$this->srcNamespacePrefix = $plugin[self::KEY_SRC_NAMESPACE_PREFIX] ?? "";
|
||||||
|
|
||||||
$this->api = array_map("\strval", (array) ($plugin["api"] ?? []));
|
$this->api = array_map("\strval", (array) ($plugin[self::KEY_API] ?? []));
|
||||||
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin[self::KEY_MCPE_PROTOCOL] ?? []));
|
||||||
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? []));
|
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin[self::KEY_OS] ?? []));
|
||||||
|
|
||||||
if(isset($plugin["commands"]) && is_array($plugin["commands"])){
|
if(isset($plugin[self::KEY_COMMANDS]) && is_array($plugin[self::KEY_COMMANDS])){
|
||||||
foreach($plugin["commands"] as $commandName => $commandData){
|
foreach($plugin[self::KEY_COMMANDS] as $commandName => $commandData){
|
||||||
if(!is_string($commandName)){
|
if(!is_string($commandName)){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command");
|
throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command");
|
||||||
}
|
}
|
||||||
if(!is_array($commandData)){
|
if(!is_array($commandData)){
|
||||||
throw new PluginDescriptionParseException("Command $commandName has invalid properties");
|
throw new PluginDescriptionParseException("Command $commandName has invalid properties");
|
||||||
}
|
}
|
||||||
if(!isset($commandData["permission"]) || !is_string($commandData["permission"])){
|
if(!isset($commandData[self::KEY_COMMAND_PERMISSION]) || !is_string($commandData[self::KEY_COMMAND_PERMISSION])){
|
||||||
throw new PluginDescriptionParseException("Command $commandName does not have a valid permission set");
|
throw new PluginDescriptionParseException("Command $commandName does not have a valid permission set");
|
||||||
}
|
}
|
||||||
$this->commands[$commandName] = new PluginDescriptionCommandEntry(
|
$this->commands[$commandName] = new PluginDescriptionCommandEntry(
|
||||||
$commandData["description"] ?? null,
|
$commandData[self::KEY_COMMAND_DESCRIPTION] ?? null,
|
||||||
$commandData["usage"] ?? null,
|
$commandData[self::KEY_COMMAND_USAGE] ?? null,
|
||||||
$commandData["aliases"] ?? [],
|
$commandData[self::KEY_COMMAND_ALIASES] ?? [],
|
||||||
$commandData["permission"],
|
$commandData[self::KEY_COMMAND_PERMISSION],
|
||||||
$commandData["permission-message"] ?? null
|
$commandData[self::KEY_COMMAND_PERMISSION_MESSAGE] ?? null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($plugin["depend"])){
|
if(isset($plugin[self::KEY_DEPEND])){
|
||||||
$this->depend = (array) $plugin["depend"];
|
$this->depend = (array) $plugin[self::KEY_DEPEND];
|
||||||
}
|
}
|
||||||
if(isset($plugin["extensions"])){
|
if(isset($plugin[self::KEY_EXTENSIONS])){
|
||||||
$extensions = (array) $plugin["extensions"];
|
$extensions = (array) $plugin[self::KEY_EXTENSIONS];
|
||||||
$isLinear = $extensions === array_values($extensions);
|
$isLinear = $extensions === array_values($extensions);
|
||||||
foreach($extensions as $k => $v){
|
foreach($extensions as $k => $v){
|
||||||
if($isLinear){
|
if($isLinear){
|
||||||
@ -160,20 +186,20 @@ class PluginDescription{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->softDepend = (array) ($plugin["softdepend"] ?? $this->softDepend);
|
$this->softDepend = (array) ($plugin[self::KEY_SOFTDEPEND] ?? $this->softDepend);
|
||||||
|
|
||||||
$this->loadBefore = (array) ($plugin["loadbefore"] ?? $this->loadBefore);
|
$this->loadBefore = (array) ($plugin[self::KEY_LOADBEFORE] ?? $this->loadBefore);
|
||||||
|
|
||||||
$this->website = (string) ($plugin["website"] ?? $this->website);
|
$this->website = (string) ($plugin[self::KEY_WEBSITE] ?? $this->website);
|
||||||
|
|
||||||
$this->description = (string) ($plugin["description"] ?? $this->description);
|
$this->description = (string) ($plugin[self::KEY_DESCRIPTION] ?? $this->description);
|
||||||
|
|
||||||
$this->prefix = (string) ($plugin["prefix"] ?? $this->prefix);
|
$this->prefix = (string) ($plugin[self::KEY_LOGGER_PREFIX] ?? $this->prefix);
|
||||||
|
|
||||||
if(isset($plugin["load"])){
|
if(isset($plugin[self::KEY_LOAD])){
|
||||||
$order = PluginEnableOrder::fromString($plugin["load"]);
|
$order = PluginEnableOrder::fromString($plugin[self::KEY_LOAD]);
|
||||||
if($order === null){
|
if($order === null){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin \"load\"");
|
throw new PluginDescriptionParseException("Invalid Plugin \"" . self::KEY_LOAD . "\"");
|
||||||
}
|
}
|
||||||
$this->order = $order;
|
$this->order = $order;
|
||||||
}else{
|
}else{
|
||||||
@ -181,24 +207,24 @@ class PluginDescription{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->authors = [];
|
$this->authors = [];
|
||||||
if(isset($plugin["author"])){
|
if(isset($plugin[self::KEY_AUTHOR])){
|
||||||
if(is_array($plugin["author"])){
|
if(is_array($plugin[self::KEY_AUTHOR])){
|
||||||
$this->authors = $plugin["author"];
|
$this->authors = $plugin[self::KEY_AUTHOR];
|
||||||
}else{
|
}else{
|
||||||
$this->authors[] = $plugin["author"];
|
$this->authors[] = $plugin[self::KEY_AUTHOR];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($plugin["authors"])){
|
if(isset($plugin[self::KEY_AUTHORS])){
|
||||||
foreach($plugin["authors"] as $author){
|
foreach($plugin[self::KEY_AUTHORS] as $author){
|
||||||
$this->authors[] = $author;
|
$this->authors[] = $author;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($plugin["permissions"])){
|
if(isset($plugin[self::KEY_PERMISSIONS])){
|
||||||
try{
|
try{
|
||||||
$this->permissions = PermissionParser::loadPermissions($plugin["permissions"]);
|
$this->permissions = PermissionParser::loadPermissions($plugin[self::KEY_PERMISSIONS]);
|
||||||
}catch(PermissionParserException $e){
|
}catch(PermissionParserException $e){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin \"permissions\": " . $e->getMessage(), 0, $e);
|
throw new PluginDescriptionParseException("Invalid Plugin \"" . self::KEY_PERMISSIONS . "\": " . $e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1174,6 +1174,8 @@ class World implements ChunkManager{
|
|||||||
/** @var bool[] $chunkTickList chunkhash => dummy */
|
/** @var bool[] $chunkTickList chunkhash => dummy */
|
||||||
$chunkTickList = [];
|
$chunkTickList = [];
|
||||||
|
|
||||||
|
$chunkTickableCache = [];
|
||||||
|
|
||||||
$centerChunks = [];
|
$centerChunks = [];
|
||||||
|
|
||||||
$selector = new ChunkSelector();
|
$selector = new ChunkSelector();
|
||||||
@ -1193,7 +1195,7 @@ class World implements ChunkManager{
|
|||||||
$centerChunkZ
|
$centerChunkZ
|
||||||
) as $hash){
|
) as $hash){
|
||||||
World::getXZ($hash, $chunkX, $chunkZ);
|
World::getXZ($hash, $chunkX, $chunkZ);
|
||||||
if(!isset($chunkTickList[$hash]) && isset($this->chunks[$hash]) && $this->isChunkTickable($chunkX, $chunkZ)){
|
if(!isset($chunkTickList[$hash]) && isset($this->chunks[$hash]) && $this->isChunkTickable($chunkX, $chunkZ, $chunkTickableCache)){
|
||||||
$chunkTickList[$hash] = true;
|
$chunkTickList[$hash] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1208,14 +1210,29 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isChunkTickable(int $chunkX, int $chunkZ) : bool{
|
/**
|
||||||
|
* @param bool[] &$cache
|
||||||
|
*
|
||||||
|
* @phpstan-param array<int, bool> $cache
|
||||||
|
* @phpstan-param-out array<int, bool> $cache
|
||||||
|
*/
|
||||||
|
private function isChunkTickable(int $chunkX, int $chunkZ, array &$cache) : bool{
|
||||||
for($cx = -1; $cx <= 1; ++$cx){
|
for($cx = -1; $cx <= 1; ++$cx){
|
||||||
for($cz = -1; $cz <= 1; ++$cz){
|
for($cz = -1; $cz <= 1; ++$cz){
|
||||||
|
$chunkHash = World::chunkHash($chunkX + $cx, $chunkZ + $cz);
|
||||||
|
if(isset($cache[$chunkHash])){
|
||||||
|
if(!$cache[$chunkHash]){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if($this->isChunkLocked($chunkX + $cx, $chunkZ + $cz)){
|
if($this->isChunkLocked($chunkX + $cx, $chunkZ + $cz)){
|
||||||
|
$cache[$chunkHash] = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$adjacentChunk = $this->getChunk($chunkX + $cx, $chunkZ + $cz);
|
$adjacentChunk = $this->getChunk($chunkX + $cx, $chunkZ + $cz);
|
||||||
if($adjacentChunk === null || !$adjacentChunk->isPopulated()){
|
if($adjacentChunk === null || !$adjacentChunk->isPopulated()){
|
||||||
|
$cache[$chunkHash] = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$lightPopulatedState = $adjacentChunk->isLightPopulated();
|
$lightPopulatedState = $adjacentChunk->isLightPopulated();
|
||||||
@ -1223,8 +1240,11 @@ class World implements ChunkManager{
|
|||||||
if($lightPopulatedState === false){
|
if($lightPopulatedState === false){
|
||||||
$this->orderLightPopulation($chunkX + $cx, $chunkZ + $cz);
|
$this->orderLightPopulation($chunkX + $cx, $chunkZ + $cz);
|
||||||
}
|
}
|
||||||
|
$cache[$chunkHash] = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cache[$chunkHash] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1267,7 +1287,8 @@ class World implements ChunkManager{
|
|||||||
private function tickChunk(int $chunkX, int $chunkZ) : void{
|
private function tickChunk(int $chunkX, int $chunkZ) : void{
|
||||||
$chunk = $this->getChunk($chunkX, $chunkZ);
|
$chunk = $this->getChunk($chunkX, $chunkZ);
|
||||||
if($chunk === null){
|
if($chunk === null){
|
||||||
throw new \InvalidArgumentException("Chunk is not loaded");
|
//the chunk may have been unloaded during a previous chunk's update (e.g. during BlockGrowEvent)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
foreach($this->getChunkEntities($chunkX, $chunkZ) as $entity){
|
foreach($this->getChunkEntities($chunkX, $chunkZ) as $entity){
|
||||||
$entity->onRandomUpdate();
|
$entity->onRandomUpdate();
|
||||||
|
@ -617,7 +617,7 @@ parameters:
|
|||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method getLanguage\\(\\) on pocketmine\\\\player\\\\Player\\|null\\.$#"
|
message: "#^Cannot call method getLanguage\\(\\) on pocketmine\\\\player\\\\Player\\|null\\.$#"
|
||||||
count: 1
|
count: 2
|
||||||
path: ../../../src/network/mcpe/NetworkSession.php
|
path: ../../../src/network/mcpe/NetworkSession.php
|
||||||
|
|
||||||
-
|
-
|
||||||
|
Loading…
x
Reference in New Issue
Block a user