mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-29 00:26:56 +00:00
Merge branch 'release/3.1'
This commit is contained in:
commit
599a64c80c
@ -1300,7 +1300,7 @@ class Server{
|
|||||||
if(($player = $this->getPlayerExact($name)) !== null){
|
if(($player = $this->getPlayerExact($name)) !== null){
|
||||||
$player->recalculatePermissions();
|
$player->recalculatePermissions();
|
||||||
}
|
}
|
||||||
$this->operators->save(true);
|
$this->operators->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1320,7 +1320,7 @@ class Server{
|
|||||||
*/
|
*/
|
||||||
public function addWhitelist(string $name){
|
public function addWhitelist(string $name){
|
||||||
$this->whitelist->set(strtolower($name), true);
|
$this->whitelist->set(strtolower($name), true);
|
||||||
$this->whitelist->save(true);
|
$this->whitelist->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1700,7 +1700,7 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->properties->hasChanged()){
|
if($this->properties->hasChanged()){
|
||||||
$this->properties->save(true);
|
$this->properties->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!($this->getDefaultLevel() instanceof Level)){
|
if(!($this->getDefaultLevel() instanceof Level)){
|
||||||
|
@ -23,6 +23,37 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\event;
|
namespace pocketmine\event;
|
||||||
|
|
||||||
|
use pocketmine\plugin\PluginManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classes implementing this interface can be registered to receive called Events.
|
||||||
|
* @see PluginManager::registerEvents()
|
||||||
|
*
|
||||||
|
* A function in a Listener class must meet the following criteria to be registered as an event handler:
|
||||||
|
*
|
||||||
|
* - MUST be public
|
||||||
|
* - MUST NOT be static
|
||||||
|
* - MUST accept EXACTLY ONE class parameter which:
|
||||||
|
* - MUST be a VALID class extending Event
|
||||||
|
* - MUST NOT be abstract, UNLESS it has an `@allowHandle` annotation
|
||||||
|
*
|
||||||
|
* Event handlers do not have to have any particular name - they are detected using reflection.
|
||||||
|
* They SHOULD NOT return any values (but this is not currently enforced).
|
||||||
|
*
|
||||||
|
* Functions which meet the criteria can have the following annotations in their doc comments:
|
||||||
|
*
|
||||||
|
* - `@notHandler`: Marks a function as NOT being an event handler. Only needed if the function meets the above criteria.
|
||||||
|
* - `@softDepend [PluginName]`: Handler WILL NOT be registered if its event doesn't exist. Useful for soft-depending
|
||||||
|
* on plugin events. Plugin name is optional.
|
||||||
|
* Example: `@softDepend SimpleAuth`
|
||||||
|
* - `@ignoreCancelled`: Cancelled events WILL NOT be passed to this handler.
|
||||||
|
* - `@priority <PRIORITY>`: Sets the priority at which this event handler will receive events.
|
||||||
|
* Example: `@priority HIGHEST`
|
||||||
|
* @see EventPriority for a list of possible options.
|
||||||
|
*
|
||||||
|
* Event handlers will receive any instanceof the Event class they have chosen to receive. For example, an
|
||||||
|
* EntityDamageEvent handler will also receive any subclass of EntityDamageEvent.
|
||||||
|
*/
|
||||||
interface Listener{
|
interface Listener{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,9 @@ abstract class PluginBase implements Plugin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function reloadConfig(){
|
public function reloadConfig(){
|
||||||
|
if(!$this->saveDefaultConfig()){
|
||||||
@mkdir($this->dataFolder);
|
@mkdir($this->dataFolder);
|
||||||
|
}
|
||||||
$this->config = new Config($this->configFile);
|
$this->config = new Config($this->configFile);
|
||||||
if(($configStream = $this->getResource("config.yml")) !== null){
|
if(($configStream = $this->getResource("config.yml")) !== null){
|
||||||
$this->config->setDefaults(yaml_parse(Config::fixYAMLIndexes(stream_get_contents($configStream))));
|
$this->config->setDefaults(yaml_parse(Config::fixYAMLIndexes(stream_get_contents($configStream))));
|
||||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\utils;
|
namespace pocketmine\utils;
|
||||||
|
|
||||||
use pocketmine\scheduler\FileWriteTask;
|
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
|
||||||
|
|
||||||
@ -187,11 +186,9 @@ class Config{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $async
|
|
||||||
*
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function save(bool $async = false) : bool{
|
public function save() : bool{
|
||||||
if($this->correct){
|
if($this->correct){
|
||||||
try{
|
try{
|
||||||
$content = null;
|
$content = null;
|
||||||
@ -216,11 +213,7 @@ class Config{
|
|||||||
throw new \InvalidStateException("Config type is unknown, has not been set or not detected");
|
throw new \InvalidStateException("Config type is unknown, has not been set or not detected");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($async){
|
|
||||||
Server::getInstance()->getAsyncPool()->submitTask(new FileWriteTask($this->file, $content));
|
|
||||||
}else{
|
|
||||||
file_put_contents($this->file, $content);
|
file_put_contents($this->file, $content);
|
||||||
}
|
|
||||||
}catch(\Throwable $e){
|
}catch(\Throwable $e){
|
||||||
$logger = Server::getInstance()->getLogger();
|
$logger = Server::getInstance()->getLogger();
|
||||||
$logger->critical("Could not save Config " . $this->file . ": " . $e->getMessage());
|
$logger->critical("Could not save Config " . $this->file . ": " . $e->getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user