66import java .util .stream .Stream ;
77
88import me .lucko .fabric .api .permissions .v0 .Permissions ;
9+
10+ import net .minecraft .command .permission .Permission ;
11+
12+ import net .minecraft .command .permission .PermissionLevel ;
13+
914import org .jetbrains .annotations .NotNull ;
1015
1116import net .minecraft .server .command .ServerCommandSource ;
@@ -112,7 +117,7 @@ static void init() {
112117 }
113118
114119 private static boolean isSuperAdmin (ServerCommandSource source ) {
115- return source .hasPermissionLevel ( 4 );
120+ return source .getPermissions (). hasPermission ( new Permission . Level ( PermissionLevel . OWNERS ) );
116121 }
117122
118123 public static @ NotNull Predicate <ServerCommandSource > require (@ NotNull String permission , int defaultRequireLevel ) {
@@ -127,13 +132,13 @@ public static boolean check(@NotNull ServerCommandSource source, @NotNull String
127132 if (CONFIG .USE_PERMISSIONS_API ) {
128133 try {
129134 // TODO: In the future, config option for granting ops all perms.
130- return Permissions .getPermissionValue (source , permission ).orElse (source .hasPermissionLevel ( Math .max (2 , defaultRequireLevel )));
135+ return Permissions .getPermissionValue (source , permission ).orElse (source .getPermissions (). hasPermission ( new Permission . Level ( PermissionLevel . fromLevel ( Math .max (2 , defaultRequireLevel )) )));
131136 } catch (Exception e ) {
132137 EssentialCommands .LOGGER .error (e );
133138 return false ;
134139 }
135140 } else {
136- return source .hasPermissionLevel ( defaultRequireLevel );
141+ return source .getPermissions (). hasPermission ( new Permission . Level ( PermissionLevel . fromLevel ( defaultRequireLevel )) );
137142 }
138143 }
139144
@@ -195,7 +200,7 @@ public static String[] makeNumericPermissionGroup(String basePermission, Collect
195200
196201 public static Stream <String > getGrantedStatefulPlayerAbilityPermissions (ServerPlayerEntity player ) {
197202 var list = Arrays .stream (Registry .Group .stateful_player_abilities );
198- return player .hasPermissionLevel ( 2 )
203+ return player .getPermissions (). hasPermission ( new Permission . Level ( PermissionLevel . GAMEMASTERS ) )
199204 ? list // TODO: this is hacky
200205 : list .filter (permission -> check (player .getCommandSource (), permission ));
201206 }
0 commit comments