mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 15:35:31 +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){
|
if(($perm = Server::getInstance()->getPluginManager()->getPermission($name)) !== null){
|
||||||
$perm = $perm->getDefault();
|
$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);
|
return $perm === Permission::DEFAULT_TRUE or ($this->isOp() and $perm === Permission::DEFAULT_OP) or (!$this->isOp() and $perm === Permission::DEFAULT_NOT_OP);
|
||||||
}else{
|
}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);
|
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;
|
public static $DEFAULT_PERMISSION = self::DEFAULT_OP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public static function getByName($value){
|
public static function getByName($value){
|
||||||
|
if(is_bool($value)){
|
||||||
|
if($value === true){
|
||||||
|
return "true";
|
||||||
|
}else{
|
||||||
|
return "false";
|
||||||
|
}
|
||||||
|
}
|
||||||
switch(strtolower($value)){
|
switch(strtolower($value)){
|
||||||
case "op":
|
case "op":
|
||||||
case "isop":
|
case "isop":
|
||||||
@ -186,7 +198,7 @@ class Permission{
|
|||||||
*
|
*
|
||||||
* @return Permission[]
|
* @return Permission[]
|
||||||
*/
|
*/
|
||||||
public static function loadPermissions(array $data, $default){
|
public static function loadPermissions(array $data, $default = self::DEFAULT_OP){
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach($data as $key => $entry){
|
foreach($data as $key => $entry){
|
||||||
$result[] = self::loadPermission($key, $entry, $default, $result);
|
$result[] = self::loadPermission($key, $entry, $default, $result);
|
||||||
|
@ -105,7 +105,16 @@ class PluginDescription{
|
|||||||
$this->authors = array();
|
$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);
|
$this->commandMap->registerAll($plugin->getDescription()->getName(), $pluginCommands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($plugin->getDescription()->getPermisions() as $perm){
|
||||||
|
$this->addPermission($perm);
|
||||||
|
}
|
||||||
|
|
||||||
$plugin->getPluginLoader()->enablePlugin($plugin);
|
$plugin->getPluginLoader()->enablePlugin($plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -569,6 +573,9 @@ class PluginManager{
|
|||||||
$plugin->getPluginLoader()->disablePlugin($plugin);
|
$plugin->getPluginLoader()->disablePlugin($plugin);
|
||||||
$this->server->getScheduler()->cancelTasks($plugin);
|
$this->server->getScheduler()->cancelTasks($plugin);
|
||||||
HandlerList::unregisterAll($plugin);
|
HandlerList::unregisterAll($plugin);
|
||||||
|
foreach($plugin->getDescription()->getCommands() as $perm){
|
||||||
|
$this->removePermission($perm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user