mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 23:59:53 +00:00
Merge branch 'php/7.0'
This commit is contained in:
commit
a06c934f4d
@ -27,6 +27,7 @@ use pocketmine\block\Air;
|
|||||||
use pocketmine\block\Block;
|
use pocketmine\block\Block;
|
||||||
use pocketmine\block\BlockFactory;
|
use pocketmine\block\BlockFactory;
|
||||||
use pocketmine\block\Liquid;
|
use pocketmine\block\Liquid;
|
||||||
|
use pocketmine\event\player\PlayerBucketEmptyEvent;
|
||||||
use pocketmine\event\player\PlayerBucketFillEvent;
|
use pocketmine\event\player\PlayerBucketFillEvent;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
@ -70,7 +71,7 @@ class Bucket extends Item{
|
|||||||
}elseif($targetBlock instanceof Liquid){
|
}elseif($targetBlock instanceof Liquid){
|
||||||
$result = clone $this;
|
$result = clone $this;
|
||||||
$result->setDamage(0);
|
$result->setDamage(0);
|
||||||
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
|
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $block, $face, $this, $result));
|
||||||
if(!$ev->isCancelled()){
|
if(!$ev->isCancelled()){
|
||||||
$player->getLevel()->setBlock($block, $targetBlock, true, true);
|
$player->getLevel()->setBlock($block, $targetBlock, true, true);
|
||||||
if($player->isSurvival()){
|
if($player->isSurvival()){
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2ab4d9172eba05cb7c6b8c98639db2ba9e60472c
|
Subproject commit 9868a649ad9151d9724298b4fcf3345eab9ea409
|
@ -23,12 +23,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\plugin;
|
namespace pocketmine\plugin;
|
||||||
|
|
||||||
|
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||||
use pocketmine\permission\Permission;
|
use pocketmine\permission\Permission;
|
||||||
|
|
||||||
class PluginDescription{
|
class PluginDescription{
|
||||||
private $name;
|
private $name;
|
||||||
private $main;
|
private $main;
|
||||||
private $api;
|
private $api;
|
||||||
|
/** @var int[] */
|
||||||
|
private $compatibleMcpeProtocols = [];
|
||||||
private $extensions = [];
|
private $extensions = [];
|
||||||
private $depend = [];
|
private $depend = [];
|
||||||
private $softDepend = [];
|
private $softDepend = [];
|
||||||
@ -71,11 +74,13 @@ class PluginDescription{
|
|||||||
$this->name = str_replace(" ", "_", $this->name);
|
$this->name = str_replace(" ", "_", $this->name);
|
||||||
$this->version = (string) $plugin["version"];
|
$this->version = (string) $plugin["version"];
|
||||||
$this->main = $plugin["main"];
|
$this->main = $plugin["main"];
|
||||||
$this->api = array_map(function($v){ return (string) $v; }, !is_array($plugin["api"]) ? [$plugin["api"]] : $plugin["api"]);
|
|
||||||
if(stripos($this->main, "pocketmine\\") === 0){
|
if(stripos($this->main, "pocketmine\\") === 0){
|
||||||
throw new PluginException("Invalid PluginDescription main, cannot start within the PocketMine namespace");
|
throw new PluginException("Invalid PluginDescription main, cannot start within the PocketMine namespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->api = array_map("strval", (array) $plugin["api"] ?? []);
|
||||||
|
$this->compatibleMcpeProtocols = array_map("intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
||||||
|
|
||||||
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
||||||
$this->commands = $plugin["commands"];
|
$this->commands = $plugin["commands"];
|
||||||
}
|
}
|
||||||
@ -94,22 +99,17 @@ class PluginDescription{
|
|||||||
$this->extensions[$k] = is_array($v) ? $v : [$v];
|
$this->extensions[$k] = is_array($v) ? $v : [$v];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($plugin["softdepend"])){
|
|
||||||
$this->softDepend = (array) $plugin["softdepend"];
|
|
||||||
}
|
|
||||||
if(isset($plugin["loadbefore"])){
|
|
||||||
$this->loadBefore = (array) $plugin["loadbefore"];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($plugin["website"])){
|
$this->softDepend = (array) ($plugin["softdepend"] ?? $this->softDepend);
|
||||||
$this->website = $plugin["website"];
|
|
||||||
}
|
$this->loadBefore = (array) ($plugin["loadbefore"] ?? $this->loadBefore);
|
||||||
if(isset($plugin["description"])){
|
|
||||||
$this->description = $plugin["description"];
|
$this->website = (string) ($plugin["website"] ?? $this->website);
|
||||||
}
|
|
||||||
if(isset($plugin["prefix"])){
|
$this->description = (string) ($plugin["description"] ?? $this->description);
|
||||||
$this->prefix = $plugin["prefix"];
|
|
||||||
}
|
$this->prefix = (string) ($plugin["prefix"] ?? $this->prefix);
|
||||||
|
|
||||||
if(isset($plugin["load"])){
|
if(isset($plugin["load"])){
|
||||||
$order = strtoupper($plugin["load"]);
|
$order = strtoupper($plugin["load"]);
|
||||||
if(!defined(PluginLoadOrder::class . "::" . $order)){
|
if(!defined(PluginLoadOrder::class . "::" . $order)){
|
||||||
@ -147,6 +147,13 @@ class PluginDescription{
|
|||||||
return $this->api;
|
return $this->api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int[]
|
||||||
|
*/
|
||||||
|
public function getCompatibleMcpeProtocols() : array{
|
||||||
|
return $this->compatibleMcpeProtocols;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
|
@ -32,6 +32,7 @@ use pocketmine\event\HandlerList;
|
|||||||
use pocketmine\event\Listener;
|
use pocketmine\event\Listener;
|
||||||
use pocketmine\event\Timings;
|
use pocketmine\event\Timings;
|
||||||
use pocketmine\event\TimingsHandler;
|
use pocketmine\event\TimingsHandler;
|
||||||
|
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||||
use pocketmine\permission\Permissible;
|
use pocketmine\permission\Permissible;
|
||||||
use pocketmine\permission\Permission;
|
use pocketmine\permission\Permission;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
@ -237,7 +238,7 @@ class PluginManager{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pluginNumbers = array_map("intval", explode(".", $pluginApi[0]));
|
$pluginNumbers = array_map("intval", array_pad(explode(".", $pluginApi[0]), 3, "0")); //plugins might specify API like "3.0" or "3"
|
||||||
$serverNumbers = array_map("intval", explode(".", $serverApi[0]));
|
$serverNumbers = array_map("intval", explode(".", $serverApi[0]));
|
||||||
|
|
||||||
if($pluginNumbers[0] !== $serverNumbers[0]){ //Completely different API version
|
if($pluginNumbers[0] !== $serverNumbers[0]){ //Completely different API version
|
||||||
@ -254,10 +255,24 @@ class PluginManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($compatible === false){
|
if($compatible === false){
|
||||||
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.incompatibleAPI"]));
|
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [
|
||||||
|
$name,
|
||||||
|
$this->server->getLanguage()->translateString("%pocketmine.plugin.incompatibleAPI", [implode(", ", $description->getCompatibleApis())])
|
||||||
|
]));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($pluginMcpeProtocols = $description->getCompatibleMcpeProtocols()) > 0){
|
||||||
|
$serverMcpeProtocols = [ProtocolInfo::CURRENT_PROTOCOL];
|
||||||
|
if(count(array_intersect($pluginMcpeProtocols, $serverMcpeProtocols)) === 0){
|
||||||
|
$this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [
|
||||||
|
$name,
|
||||||
|
$this->server->getLanguage()->translateString("%pocketmine.plugin.incompatibleProtocol", [implode(", ", $pluginMcpeProtocols)])
|
||||||
|
]));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$plugins[$name] = $file;
|
$plugins[$name] = $file;
|
||||||
|
|
||||||
$softDependencies[$name] = $description->getSoftDepend();
|
$softDependencies[$name] = $description->getSoftDepend();
|
||||||
@ -287,7 +302,10 @@ class PluginManager{
|
|||||||
if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){
|
if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){
|
||||||
unset($dependencies[$name][$key]);
|
unset($dependencies[$name][$key]);
|
||||||
}elseif(!isset($plugins[$dependency])){
|
}elseif(!isset($plugins[$dependency])){
|
||||||
$this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [$name, "%pocketmine.plugin.unknownDependency"]));
|
$this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.loadError", [
|
||||||
|
$name,
|
||||||
|
$this->server->getLanguage()->translateString("%pocketmine.plugin.unknownDependency", [$dependency])
|
||||||
|
]));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user