mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 22:15:30 +00:00
Load correct plugin permissions
This commit is contained in:
parent
b03ef8b61c
commit
8571796611
@ -102,7 +102,6 @@ class PermissibleBase implements Permissible{
|
||||
|
||||
if(($perm = Server::getInstance()->getPluginManager()->getPermission($name)) !== null){
|
||||
$perm = $perm->getDefault();
|
||||
|
||||
return $perm === Permission::DEFAULT_TRUE or ($this->isOp() and $perm === Permission::DEFAULT_OP) or (!$this->isOp() and $perm === Permission::DEFAULT_NOT_OP);
|
||||
}else{
|
||||
return Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_TRUE or ($this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_OP) or (!$this->isOp() and Permission::$DEFAULT_PERMISSION === Permission::DEFAULT_NOT_OP);
|
||||
|
@ -37,7 +37,19 @@ class Permission{
|
||||
|
||||
public static $DEFAULT_PERMISSION = self::DEFAULT_OP;
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getByName($value){
|
||||
if(is_bool($value)){
|
||||
if($value === true){
|
||||
return "true";
|
||||
}else{
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
switch(strtolower($value)){
|
||||
case "op":
|
||||
case "isop":
|
||||
@ -186,7 +198,7 @@ class Permission{
|
||||
*
|
||||
* @return Permission[]
|
||||
*/
|
||||
public static function loadPermissions(array $data, $default){
|
||||
public static function loadPermissions(array $data, $default = self::DEFAULT_OP){
|
||||
$result = array();
|
||||
foreach($data as $key => $entry){
|
||||
$result[] = self::loadPermission($key, $entry, $default, $result);
|
||||
|
@ -105,7 +105,16 @@ class PluginDescription{
|
||||
$this->authors = array();
|
||||
}
|
||||
|
||||
//TODO: Do permissions
|
||||
if(isset($plugin["permissions"])){
|
||||
$this->permissions = Permission::loadPermissions($plugin["permissions"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFullName(){
|
||||
return $this->name . " v" . $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -500,6 +500,10 @@ class PluginManager{
|
||||
$this->commandMap->registerAll($plugin->getDescription()->getName(), $pluginCommands);
|
||||
}
|
||||
|
||||
foreach($plugin->getDescription()->getPermisions() as $perm){
|
||||
$this->addPermission($perm);
|
||||
}
|
||||
|
||||
$plugin->getPluginLoader()->enablePlugin($plugin);
|
||||
}
|
||||
}
|
||||
@ -569,6 +573,9 @@ class PluginManager{
|
||||
$plugin->getPluginLoader()->disablePlugin($plugin);
|
||||
$this->server->getScheduler()->cancelTasks($plugin);
|
||||
HandlerList::unregisterAll($plugin);
|
||||
foreach($plugin->getDescription()->getCommands() as $perm){
|
||||
$this->removePermission($perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user