mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Added extra Exceptions
This commit is contained in:
@ -24,6 +24,7 @@ namespace pocketmine\permission;
|
||||
use pocketmine\event\Timings;
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\PluginException;
|
||||
|
||||
class PermissibleBase implements Permissible{
|
||||
/** @var ServerOperator */
|
||||
@ -72,7 +73,7 @@ class PermissibleBase implements Permissible{
|
||||
*/
|
||||
public function setOp($value){
|
||||
if($this->opable === null){
|
||||
throw new \Exception("Cannot change op value as no ServerOperator is set");
|
||||
throw new \LogicException("Cannot change op value as no ServerOperator is set");
|
||||
}else{
|
||||
$this->opable->setOp($value);
|
||||
}
|
||||
@ -120,13 +121,13 @@ class PermissibleBase implements Permissible{
|
||||
*
|
||||
* @return PermissionAttachment
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws PluginException
|
||||
*/
|
||||
public function addAttachment(Plugin $plugin, $name = null, $value = null){
|
||||
if($plugin === null){
|
||||
throw new \Exception("Plugin cannot be null");
|
||||
throw new PluginException("Plugin cannot be null");
|
||||
}elseif(!$plugin->isEnabled()){
|
||||
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
}
|
||||
|
||||
$result = new PermissionAttachment($plugin, $this->parent);
|
||||
@ -147,7 +148,7 @@ class PermissibleBase implements Permissible{
|
||||
*/
|
||||
public function removeAttachment(PermissionAttachment $attachment){
|
||||
if($attachment === null){
|
||||
throw new \Exception("Attachment cannot be null");
|
||||
throw new \InvalidStateException("Attachment cannot be null");
|
||||
}
|
||||
|
||||
if(isset($this->attachments[spl_object_hash($attachment)])){
|
||||
|
@ -225,7 +225,7 @@ class Permission{
|
||||
if($value !== null){
|
||||
$default = $value;
|
||||
}else{
|
||||
throw new \Exception("'default' key contained unknown value");
|
||||
throw new \InvalidStateException("'default' key contained unknown value");
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ class Permission{
|
||||
$children[$k] = true;
|
||||
}
|
||||
}else{
|
||||
throw new \Exception("'children' key is of wrong type");
|
||||
throw new \InvalidStateException("'children' key is of wrong type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace pocketmine\permission;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
use pocketmine\utils\PluginException;
|
||||
|
||||
class PermissionAttachment{
|
||||
/** @var PermissionRemovedExecutor */
|
||||
@ -42,11 +43,11 @@ class PermissionAttachment{
|
||||
* @param Plugin $plugin
|
||||
* @param Permissible $permissible
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws PluginException
|
||||
*/
|
||||
public function __construct(Plugin $plugin, Permissible $permissible){
|
||||
if(!$plugin->isEnabled()){
|
||||
throw new \Exception("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
|
||||
}
|
||||
|
||||
$this->permissible = $permissible;
|
||||
|
@ -41,11 +41,11 @@ class PermissionAttachmentInfo{
|
||||
* @param PermissionAttachment $attachment
|
||||
* @param bool $value
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \InvalidStateException
|
||||
*/
|
||||
public function __construct(Permissible $permissible, $permission, $attachment, $value){
|
||||
if($permission === null){
|
||||
throw new \Exception("Permission may not be null");
|
||||
throw new \InvalidStateException("Permission may not be null");
|
||||
}
|
||||
|
||||
$this->permissible = $permissible;
|
||||
|
Reference in New Issue
Block a user