mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-28 16:22:18 +00:00
Fix NPE when loading mcfunctions
CommandSourceStack.getServer can be null, despite being marked as non-nullable. Mojang!!! *shakes fist* Fixes #2235.
This commit is contained in:
parent
180156ff1c
commit
3cf914cb4c
@ -50,6 +50,12 @@ public enum UserLevel implements Predicate<CommandSourceStack> {
|
|||||||
|
|
||||||
public static boolean isOwner(CommandSourceStack source) {
|
public static boolean isOwner(CommandSourceStack source) {
|
||||||
var server = source.getServer();
|
var server = source.getServer();
|
||||||
|
|
||||||
|
// While CommandSourceStack.getServer is non-nullable, that's a lie for permission checks. When loading
|
||||||
|
// .mcfunction files, ServerFunctionLibrary constructs an instance with an empty server. In that case, return
|
||||||
|
// false — we don't want to treat functions as an owner!
|
||||||
|
if (server == null) return false;
|
||||||
|
|
||||||
var player = source.getPlayer();
|
var player = source.getPlayer();
|
||||||
return server.isDedicatedServer()
|
return server.isDedicatedServer()
|
||||||
? source.getEntity() == null && source.hasPermission(4) && source.getTextName().equals("Server")
|
? source.getEntity() == null && source.hasPermission(4) && source.getTextName().equals("Server")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user