Some more blank permission handling/comments

This commit is contained in:
Konicai 2024-07-07 22:49:59 -05:00
parent b891023f1a
commit 568cbc8b21
6 changed files with 10 additions and 7 deletions

View file

@ -97,7 +97,7 @@ public class BungeeCommandSource implements GeyserCommandSource {
@Override
public boolean hasPermission(String permission) {
// Handle blank permissions ourselves, as cloud only handles empty ones
// Handle blank permissions ourselves, as bungeecord only handles empty ones
return permission.isBlank() || handle.hasPermission(permission);
}

View file

@ -93,8 +93,7 @@ public class GeyserNeoForgeCommandRegistry extends CommandRegistry {
// We can't realistically ensure that every permission is registered (calls by API users), so we catch this.
// This works for our calls, but not for cloud's internal usage. For that case, see above.
try {
// Handle blank permissions ourselves, as cloud only handles empty ones
return permission.isBlank() || super.hasPermission(source, permission);
return super.hasPermission(source, permission);
} catch (PermissionNotRegisteredException e) {
return false;
}

View file

@ -100,6 +100,7 @@ public class SpigotCommandSource implements GeyserCommandSource {
@Override
public boolean hasPermission(String permission) {
return handle.hasPermission(permission);
// Don't trust Spigot to handle blank permissions
return permission.isBlank() || handle.hasPermission(permission);
}
}

View file

@ -93,7 +93,7 @@ public class VelocityCommandSource implements GeyserCommandSource {
@Override
public boolean hasPermission(String permission) {
// Handle blank permissions ourselves, as cloud only handles empty ones
// Handle blank permissions ourselves, as velocity only handles empty ones
return permission.isBlank() || handle.hasPermission(permission);
}

View file

@ -91,7 +91,10 @@ public abstract class GeyserCommand implements org.geysermc.geyser.api.command.C
throw new IllegalArgumentException("Command cannot be null or blank!");
}
if (permission.isBlank()) {
permission = ""; // Cloud treats empty permissions as available to everyone, but not blank permissions.
// Cloud treats empty permissions as available to everyone, but not blank permissions.
// When registering commands, we must convert ALL whitespace permissions into empty ones,
// because we cannot override permission checks that Cloud itself performs
permission = "";
permissionDefault = null;
}

View file

@ -107,7 +107,7 @@ public class StandaloneCloudCommandManager extends CommandManager<GeyserCommandS
return true;
}
// Handle blank permissions ourselves, as cloud only handles empty ones
// An empty or blank permission is treated as a lack of permission requirement
if (permission.isBlank()) {
return true;
}