mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Permissions management cleanup (#2332)
* Added a new PermissionManager, remove ridiculous cyclic dependencies of Permissions on Server Aside from all the other ridiculous design problems with the permission system, the biggest problems are its API. This is, once again, a result of poor API design copied from Bukkit. This pull request removes all permission-related functionality from `PluginManager` and moves it to the `pocketmine\permission\PermissionManager` class. As can be observed from the removed code in the diff, the permissions system was previously entirely dependent on the Server, because it needed to get the PluginManager for registering permissions. This is utterly ridiculous. This refactor isolates _most_ permission-related functionality within the `permission` namespace. As mentioned above, this stupid API is a direct result of copying from Bukkit. If you look at the API documentation for Bukkit for `PluginManager` you will see that the methods I'm deprecating here are also in there. ## Changes - Added a new `PermissionManager` class. This can be accessed via its singleton `getInstance()` static method. - Deprecated the following `PluginManager` methods - these will be removed no later than 4.0.0: - `getPermission()` - `addPermission()` - `removePermission()` - `getDefaultPermissions()` - `recalculatePermissionDefaults()` - `subscribeToPermission()` - `unsubscribeFromPermission()` - `getPermissionSubscriptions()` - `subscribeToDefaultPerms()` - `unsubscribeFromDefaultPerms()` - `getDefaultPermSubscriptions()` - `getPermissions()`
This commit is contained in:
@ -23,8 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\permission;
|
||||
|
||||
use pocketmine\Server;
|
||||
|
||||
abstract class DefaultPermissions{
|
||||
public const ROOT = "pocketmine";
|
||||
|
||||
@ -40,9 +38,9 @@ abstract class DefaultPermissions{
|
||||
|
||||
return self::registerPermission($perm);
|
||||
}
|
||||
Server::getInstance()->getPluginManager()->addPermission($perm);
|
||||
PermissionManager::getInstance()->addPermission($perm);
|
||||
|
||||
return Server::getInstance()->getPluginManager()->getPermission($perm->getName());
|
||||
return PermissionManager::getInstance()->getPermission($perm->getName());
|
||||
}
|
||||
|
||||
public static function registerCorePermissions(){
|
||||
|
Reference in New Issue
Block a user