11package net.silkmc.silk.core.entity
22
3- import me.lucko.fabric.api.permissions.v0.Permissions
4- import net.fabricmc.loader.api.FabricLoader
5- import net.minecraft.server.level.ServerPlayer
63import net.minecraft.world.entity.player.Player
74import net.silkmc.silk.core.server.executeCommand
85
@@ -14,26 +11,3 @@ import net.silkmc.silk.core.server.executeCommand
1411fun Player.executeCommand (command : String ) {
1512 server?.executeCommand(command, this .createCommandSourceStack())
1613}
17-
18- /* *
19- * Checks if a player has a given permission.
20- *
21- * If
22- * [Fabric Permissions API](https://github.com/lucko/fabric-permissions-api/)
23- * is not installed, then it will fall back to the permission level and
24- * test it against the player's permission level.
25- *
26- * Operators have a permission level of 4, normal users have a permission
27- * level of 0. It is unclear what exactly 1-3 mean.
28- *
29- * @param permission The permission to check
30- * @param fallbackPermissionLevel The permission level to fall back to if
31- * the fabric permissions api is not present
32- * @return If the player has the appropriate permissions
33- */
34- fun ServerPlayer.hasPermission (permission : String , fallbackPermissionLevel : Int = 2): Boolean {
35- return if (FabricLoader .getInstance().isModLoaded(" fabric-permissions-api-v0" ))
36- Permissions .check(this , permission, fallbackPermissionLevel)
37- else
38- hasPermissions(fallbackPermissionLevel)
39- }
0 commit comments