mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Fire plugin onLoad()
This commit is contained in:
parent
1c7be84703
commit
605231251a
@ -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){
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user