mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +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\BlockFactory;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\event\player\PlayerBucketEmptyEvent;
|
||||
use pocketmine\event\player\PlayerBucketFillEvent;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
@ -70,7 +71,7 @@ class Bucket extends Item{
|
||||
}elseif($targetBlock instanceof Liquid){
|
||||
$result = clone $this;
|
||||
$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()){
|
||||
$player->getLevel()->setBlock($block, $targetBlock, true, true);
|
||||
if($player->isSurvival()){
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2ab4d9172eba05cb7c6b8c98639db2ba9e60472c
|
||||
Subproject commit 9868a649ad9151d9724298b4fcf3345eab9ea409
|
@ -23,12 +23,15 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\plugin;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\permission\Permission;
|
||||
|
||||
class PluginDescription{
|
||||
private $name;
|
||||
private $main;
|
||||
private $api;
|
||||
/** @var int[] */
|
||||
private $compatibleMcpeProtocols = [];
|
||||
private $extensions = [];
|
||||
private $depend = [];
|
||||
private $softDepend = [];
|
||||
@ -71,11 +74,13 @@ class PluginDescription{
|
||||
$this->name = str_replace(" ", "_", $this->name);
|
||||
$this->version = (string) $plugin["version"];
|
||||
$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){
|
||||
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"])){
|
||||
$this->commands = $plugin["commands"];
|
||||
}
|
||||
@ -94,22 +99,17 @@ class PluginDescription{
|
||||
$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->website = $plugin["website"];
|
||||
}
|
||||
if(isset($plugin["description"])){
|
||||
$this->description = $plugin["description"];
|
||||
}
|
||||
if(isset($plugin["prefix"])){
|
||||
$this->prefix = $plugin["prefix"];
|
||||
}
|
||||
$this->softDepend = (array) ($plugin["softdepend"] ?? $this->softDepend);
|
||||
|
||||
$this->loadBefore = (array) ($plugin["loadbefore"] ?? $this->loadBefore);
|
||||
|
||||
$this->website = (string) ($plugin["website"] ?? $this->website);
|
||||
|
||||
$this->description = (string) ($plugin["description"] ?? $this->description);
|
||||
|
||||
$this->prefix = (string) ($plugin["prefix"] ?? $this->prefix);
|
||||
|
||||
if(isset($plugin["load"])){
|
||||
$order = strtoupper($plugin["load"]);
|
||||
if(!defined(PluginLoadOrder::class . "::" . $order)){
|
||||
@ -147,6 +147,13 @@ class PluginDescription{
|
||||
return $this->api;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public function getCompatibleMcpeProtocols() : array{
|
||||
return $this->compatibleMcpeProtocols;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\Listener;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\event\TimingsHandler;
|
||||
use pocketmine\network\mcpe\protocol\ProtocolInfo;
|
||||
use pocketmine\permission\Permissible;
|
||||
use pocketmine\permission\Permission;
|
||||
use pocketmine\Server;
|
||||
@ -237,7 +238,7 @@ class PluginManager{
|
||||
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]));
|
||||
|
||||
if($pluginNumbers[0] !== $serverNumbers[0]){ //Completely different API version
|
||||
@ -254,10 +255,24 @@ class PluginManager{
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
$softDependencies[$name] = $description->getSoftDepend();
|
||||
@ -287,7 +302,10 @@ class PluginManager{
|
||||
if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){
|
||||
unset($dependencies[$name][$key]);
|
||||
}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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user