Skip to content

Commit e598b39

Browse files
committed
Fixed support for servers who don't use permissions
1 parent b56760f commit e598b39

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ The mod uses the Fabric Permissions API and supports any permissions plugin that
5858
- `oldschooljail.time` - Allows using `/jail time` (granted to all by default)
5959
- `oldschooljail.jail` - Also allows using `/jail time <player>` to check other players' jail time
6060

61-
**Note**: If no permissions plugin is installed, the mod falls back to OP level 2 for admin commands.
61+
**Note**: If no permissions plugin is installed, the mod automatically falls back to OP level 2 for admin commands. The mod works perfectly on vanilla servers without any permissions plugins!
6262

6363
## Configuration
6464

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ dependencies {
3333
// Fabric API
3434
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
3535

36-
// Fabric Permissions API (for LuckPerms integration)
36+
// Fabric Permissions API (for LuckPerms integration) - Optional dependency
3737
modImplementation "me.lucko:fabric-permissions-api:0.3.1"
38-
include "me.lucko:fabric-permissions-api:0.3.1"
38+
// Don't include it - let it be optional
3939

4040
// TOML parser for config files
4141
implementation "com.electronwill.night-config:toml:3.6.7"

src/main/java/com/oldschooljail/util/PermissionUtil.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.oldschooljail.util;
22

3-
import me.lucko.fabric.api.permissions.v0.Permissions;
43
import net.minecraft.server.command.ServerCommandSource;
54
import net.minecraft.server.network.ServerPlayerEntity;
65

@@ -19,13 +18,23 @@ public static boolean hasPermission(ServerCommandSource source, String permissio
1918
return true;
2019
}
2120

22-
// Use Fabric Permissions API (works with LuckPerms, etc.)
23-
// Falls back to OP level 2 if no permission plugin is installed
24-
return Permissions.check(source, permission, 2);
21+
// Try to use Fabric Permissions API if available
22+
try {
23+
return me.lucko.fabric.api.permissions.v0.Permissions.check(source, permission, 2);
24+
} catch (NoClassDefFoundError | Exception e) {
25+
// Permissions API not available, fall back to OP level 2
26+
return source.hasPermissionLevel(2);
27+
}
2528
}
2629

2730
public static boolean hasPermission(ServerPlayerEntity player, String permission) {
28-
return Permissions.check(player, permission, 2);
31+
// Try to use Fabric Permissions API if available
32+
try {
33+
return me.lucko.fabric.api.permissions.v0.Permissions.check(player, permission, 2);
34+
} catch (NoClassDefFoundError | Exception e) {
35+
// Permissions API not available, fall back to OP level 2
36+
return player.hasPermissionLevel(2);
37+
}
2938
}
3039

3140
public static boolean isImmune(ServerPlayerEntity player) {

0 commit comments

Comments
 (0)