Skip to content

Commit 81e57c2

Browse files
committed
Handle null server on dummy CommandSourceStacks for command sending checks
Questionable decision by vanilla to violate the nullability contracts when it seems they could just use server & overworld spawn like console does, but oh well...
1 parent 25d2d26 commit 81e57c2

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

cloud-fabric/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ configurations {
2929

3030
dependencies {
3131
minecraft(libs.minecraft)
32-
mappings(loom.officialMojangMappings())
32+
mappings(
33+
loom.layered {
34+
officialMojangMappings()
35+
parchment(property("neoForge.parchment.parchmentArtifact"))
36+
}
37+
)
3338
modImplementation(libs.fabricLoader)
3439

3540
api(platform(libs.cloud.bom))

cloud-fabric/common-repack/build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ plugins {
77

88
dependencies {
99
minecraft(libs.minecraft)
10-
mappings(loom.officialMojangMappings())
10+
mappings(
11+
loom.layered {
12+
officialMojangMappings()
13+
parchment(property("neoForge.parchment.parchmentArtifact"))
14+
}
15+
)
1116
compileOnly(libs.fabricLoader)
1217
}
1318

cloud-fabric/src/main/java/org/incendo/cloud/fabric/FabricServerCommandManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ public boolean hasPermission(final @NonNull C sender, final @NonNull String perm
117117
return true;
118118
}
119119
final CommandSourceStack source = this.senderMapper().reverse(sender);
120+
121+
// noinspection ConstantConditions - vanilla annotations are lying
122+
if (source.getServer() == null) {
123+
// Handle 1.21.11 quirk, this is a best effort impl. for 'restricted' checking...
124+
// If necessary we could use Mixin to allow explicitly setting the flag.
125+
return false; // Permission is implicitly not empty
126+
}
127+
120128
if (HAS_PERMISSIONS_API) {
121129
return Permissions.check(source, permission, source.getServer().operatorUserPermissions().level());
122130
}

cloud-neoforge/src/main/java/org/incendo/cloud/neoforge/NeoForgeServerCommandManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public boolean hasPermission(final @NonNull C sender, final @NonNull String perm
112112
}
113113
return PermissionAPI.getPermission(source.getPlayer(), node);
114114
}
115+
116+
// noinspection ConstantConditions - vanilla annotations are lying
117+
if (source.getServer() == null) {
118+
// Handle 1.21.11 quirk, this is a best effort impl. for 'restricted' checking...
119+
// If necessary we could use Mixin to allow explicitly setting the flag.
120+
return false; // Permission is implicitly not empty
121+
}
122+
115123
return source.permissions().hasPermission(
116124
new Permission.HasCommandLevel(source.getServer().operatorUserPermissions().level())
117125
);

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ group=org.incendo
22
version=2.0.0-SNAPSHOT
33
description=Cloud implementations for modded Minecraft
44

5+
neoForge.parchment.parchmentArtifact=io.papermc.parchment.data:parchment:1.21.11+build.2
6+
57
org.gradle.caching=true
68
org.gradle.configuration-cache=true
79
org.gradle.parallel=true

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencyResolutionManagement {
3434

3535
versionCatalogs {
3636
create("fabricApiLibs") {
37-
from("net.fabricmc.fabric-api:fabric-api-catalog:0.134.0+1.21.9")
37+
from("net.fabricmc.fabric-api:fabric-api-catalog:0.139.4+1.21.11")
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)