Minestom
Minestom copied to clipboard
implement other permission system
This PR adds the new permission system. You can register permission and verify them for specific CommandSender.
Register permission:
MinecraftServer.getPermissionManager().registerPermission(new Permission(
"some.permission", // Permission name
PermissionDefault.TRUE // Default behaviour of permission (TRUE, OP, OP(level) or create new using predicate)
));
Verify permission:
Player player;
boolean hasPermission = player.hasPermission("some.permission")
or
Player player;
boolean hasPermission = MinecraftServer.getPermissionManager().verify(player, "some.permission");
It is easy to change permission manager realisation using setter in MinecraftServer or ServerProcess
Such change should be discussed with contributors first. The current proposal add unnecessary (and unsafe) mutability, lack thread safety, expose more than required, and remove support for entity permission.
I combined old permission system and this permission system. PermissionManager in ServerProcess is final.
And maybe fix thread safety
Closed due to mass conflicts. Feel free to reopen and fix them.