mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Updated trigger_error to Exceptions, fixed bug in Plugin task deletion
This commit is contained in:
@ -66,12 +66,12 @@ class PermissibleBase implements Permissible{
|
||||
|
||||
/**
|
||||
* @param bool $value
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function setOp($value){
|
||||
if($this->opable === null){
|
||||
trigger_error("Cannot change op value as no ServerOperator is set", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
throw new \Exception("Cannot change op value as no ServerOperator is set");
|
||||
}else{
|
||||
$this->opable->setOp($value);
|
||||
}
|
||||
@ -118,16 +118,14 @@ class PermissibleBase implements Permissible{
|
||||
* @param bool $value
|
||||
*
|
||||
* @return PermissionAttachment
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function addAttachment(Plugin $plugin, $name = null, $value = null){
|
||||
if($plugin === null){
|
||||
trigger_error("Plugin cannot be null", E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
throw new \Exception("Plugin cannot be null");
|
||||
}elseif(!$plugin->isEnabled()){
|
||||
trigger_error("Plugin " . $plugin->getDescription()->getName() . " is disabled", E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
}
|
||||
|
||||
$result = new PermissionAttachment($plugin, $this->parent);
|
||||
@ -144,13 +142,11 @@ class PermissibleBase implements Permissible{
|
||||
/**
|
||||
* @param PermissionAttachment $attachment
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function removeAttachment(PermissionAttachment $attachment){
|
||||
if($attachment === null){
|
||||
trigger_error("Attachment cannot be null", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
throw new \Exception("Attachment cannot be null");
|
||||
}
|
||||
|
||||
if(isset($this->attachments[spl_object_hash($attachment)])){
|
||||
|
@ -214,6 +214,8 @@ class Permission{
|
||||
* @param array $output
|
||||
*
|
||||
* @return Permission
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function loadPermission($name, array $data, $default = self::DEFAULT_OP, &$output = []){
|
||||
$desc = null;
|
||||
@ -223,7 +225,7 @@ class Permission{
|
||||
if($value !== null){
|
||||
$default = $value;
|
||||
}else{
|
||||
trigger_error("'default' key contained unknown value", E_USER_WARNING);
|
||||
throw new \Exception("'default' key contained unknown value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +240,7 @@ class Permission{
|
||||
$children[$k] = true;
|
||||
}
|
||||
}else{
|
||||
trigger_error("'children' key is of wrong type", E_USER_WARNING);
|
||||
throw new \Exception("'children' key is of wrong type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,12 +41,12 @@ class PermissionAttachment{
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
* @param Permissible $permissible
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Plugin $plugin, Permissible $permissible){
|
||||
if(!$plugin->isEnabled()){
|
||||
trigger_error("Plugin " . $plugin->getDescription()->getName() . " is disabled", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
}
|
||||
|
||||
$this->permissible = $permissible;
|
||||
|
@ -40,12 +40,12 @@ class PermissionAttachmentInfo{
|
||||
* @param string $permission
|
||||
* @param PermissionAttachment $attachment
|
||||
* @param bool $value
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Permissible $permissible, $permission, $attachment, $value){
|
||||
if($permission === null){
|
||||
trigger_error("Permission may not be null", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
throw new \Exception("Permission may not be null");
|
||||
}
|
||||
|
||||
$this->permissible = $permissible;
|
||||
|
Reference in New Issue
Block a user