diff --git a/src/PocketMine/plugin/FolderPluginLoader.php b/src/PocketMine/plugin/FolderPluginLoader.php index 9e2a53131..33896f2f7 100644 --- a/src/PocketMine/plugin/FolderPluginLoader.php +++ b/src/PocketMine/plugin/FolderPluginLoader.php @@ -22,9 +22,9 @@ namespace PocketMine\Plugin; use PocketMine\Event\EventHandler; -use PocketMine\Server; -use PocketMine\Event\Plugin\PluginEnableEvent; use PocketMine\Event\Plugin\PluginDisableEvent; +use PocketMine\Event\Plugin\PluginEnableEvent; +use PocketMine\Server; /** * Handles different types of plugins @@ -53,6 +53,7 @@ class FolderPluginLoader implements PluginLoader{ public function loadPlugin($file){ if(is_dir($file) and file_exists($file . "/plugin.yml") and file_exists($file . "/src/")){ if(($description = $this->getPluginDescription($file)) instanceof PluginDescription){ + console("[INFO] Loading " . $description->getName()); $dataFolder = basename($file) . "/" . $description->getName(); if(file_exists($dataFolder) and !is_dir($dataFolder)){ trigger_error("Projected dataFolder '".$dataFolder."' for ".$description->getName()." exists and is not a directory", E_USER_WARNING); @@ -98,6 +99,7 @@ class FolderPluginLoader implements PluginLoader{ private function initPlugin(PluginBase $plugin, PluginDescription $description, $dataFolder, $file){ $plugin->init($this, $this->server, $description, $dataFolder, $file); + $plugin->onLoad(); } public function enablePlugin(Plugin $plugin){ diff --git a/src/PocketMine/plugin/PluginBase.php b/src/PocketMine/plugin/PluginBase.php index 24f34e354..382a4556e 100644 --- a/src/PocketMine/plugin/PluginBase.php +++ b/src/PocketMine/plugin/PluginBase.php @@ -21,11 +21,11 @@ namespace PocketMine\Plugin; +use PocketMine\Command\Command; use PocketMine\Command\CommandExecutor; +use PocketMine\Command\CommandSender; use PocketMine\Server; use PocketMine\Utils\Config; -use PocketMine\Command\CommandSender; -use PocketMine\Command\Command; abstract class PluginBase implements Plugin, CommandExecutor{ @@ -47,7 +47,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{ private $file; /** - * Called when the plugin is loaded, before calling onLoad() + * Called when the plugin is loaded, before calling onEnable() */ public function onLoad(){ @@ -57,10 +57,20 @@ abstract class PluginBase implements Plugin, CommandExecutor{ } + public function onDisable(){ + + } + + /** + * @return bool + */ public final function isEnabled(){ return $this->isEnabled === true; } + /** + * @param bool $boolean + */ public final function setEnabled($boolean = true){ if($this->isEnabled !== $boolean){ $this->isEnabled = $boolean; @@ -72,10 +82,9 @@ abstract class PluginBase implements Plugin, CommandExecutor{ } } - public function onDisable(){ - - } - + /** + * @return bool + */ public final function isDisabled(){ return $this->isEnabled === false; } @@ -121,6 +130,13 @@ abstract class PluginBase implements Plugin, CommandExecutor{ $this->get }*/ + /** + * @return bool + */ + public function isPhar(){ + return $this->description instanceof \PharFileInfo; + } + /** * Gets an embedded resource on the plugin file. * @@ -130,7 +146,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{ */ public function getResource($filename){ $filename = str_replace("\\", "/", $filename); - if(isset($this->phar) and $this->phar instanceof \Phar){ + if($this->isPhar()){ //TODO }else{ if(file_exists($this->dataFolder . "resources/" . $filename)){ @@ -189,11 +205,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{ public function saveConfig(){ if($this->getConfig()->save() === false){ console("[SEVERE] Could not save config to " . $this->configFile); - - return false; } - - return true; } public function saveDefaultConfig(){ @@ -209,10 +221,16 @@ abstract class PluginBase implements Plugin, CommandExecutor{ } } + /** + * @return Server + */ public final function getServer(){ return $this->dataFolder; } + /** + * @return string + */ public final function getName(){ return $this->description->getName(); } diff --git a/src/PocketMine/utils/Config.php b/src/PocketMine/utils/Config.php index bc61fb7d8..53a11e9c7 100644 --- a/src/PocketMine/utils/Config.php +++ b/src/PocketMine/utils/Config.php @@ -303,6 +303,13 @@ class Config{ return ($keys === true ? array_keys($this->config) : $this->config); } + /** + * @param array $defaults + */ + public function setDefaults(array $defaults){ + $this->fillDefaults($defaults, $this->config); + } + /** * @param $default * @param $data diff --git a/src/build/compile.sh b/src/build/compile.sh index bf63cd521..bd8a88442 100644 --- a/src/build/compile.sh +++ b/src/build/compile.sh @@ -8,7 +8,7 @@ CURL_VERSION="curl-7_35_0" READLINE_VERSION="6.3" NCURSES_VERSION="5.9" PHPNCURSES_VERSION="1.0.2" -PTHREADS_VERSION="2.0.2" +PTHREADS_VERSION="2.0.3" WEAKREF_VERSION="0.2.2" PHPYAML_VERSION="1.1.1" YAML_VERSION="0.1.4" @@ -515,10 +515,10 @@ mv yaml-$PHPYAML_VERSION "$DIR/install_data/php/ext/yaml" echo " done!" #bcompiler -echo -n "[bcompiler] downloading $BCOMPILER_VERSION..." -download_file "http://pecl.php.net/get/bcompiler-$BCOMPILER_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1 -mv bcompiler-$BCOMPILER_VERSION "$DIR/install_data/php/ext/bcompiler" -echo " done!" +#echo -n "[bcompiler] downloading $BCOMPILER_VERSION..." +#download_file "http://pecl.php.net/get/bcompiler-$BCOMPILER_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1 +#mv bcompiler-$BCOMPILER_VERSION "$DIR/install_data/php/ext/bcompiler" +#echo " done!" #PHP ncurses echo -n "[PHP ncurses] downloading $PHPNCURSES_VERSION..." @@ -619,7 +619,6 @@ RANLIB=$RANLIB ./configure $PHP_OPTIMIZATION --prefix="$DIR/bin/php5" \ --with-yaml="$DIR/bin/php5" \ $HAVE_NCURSES \ $HAVE_READLINE \ ---enable-bcompiler \ --enable-mbstring \ --enable-calendar \ --enable-weakref \