Handle blank permissions properly

This commit is contained in:
onebeastchris 2024-07-06 20:27:40 +02:00
parent 5ee0d41aab
commit b2a22505f9
7 changed files with 14 additions and 6 deletions

View file

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

View file

@ -93,7 +93,8 @@ 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 {
return super.hasPermission(source, permission);
// Handle blank permissions ourselves, as cloud only handles empty ones
return permission.isBlank() || super.hasPermission(source, permission);
} catch (PermissionNotRegisteredException e) {
return false;
}

View file

@ -36,7 +36,6 @@ import org.geysermc.geyser.command.GeyserCommandSource;
import org.geysermc.geyser.platform.spigot.PaperAdventure;
import org.geysermc.geyser.text.GeyserLocale;
import java.util.Optional;
import java.util.UUID;
public class SpigotCommandSource implements GeyserCommandSource {

View file

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

View file

@ -266,7 +266,8 @@ public class CommandRegistry implements EventRegistrar {
}
public boolean hasPermission(GeyserCommandSource source, String permission) {
return cloud.hasPermission(source, permission);
// Handle blank permissions ourselves, as cloud only handles empty ones
return permission.isBlank() || cloud.hasPermission(source, permission);
}
/**

View file

@ -91,6 +91,7 @@ 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.
permissionDefault = null;
}

View file

@ -103,11 +103,15 @@ public class StandaloneCloudCommandManager extends CommandManager<GeyserCommandS
// GeyserLogger#hasPermission always returns true
// GeyserSession#hasPermission delegates to this method,
// which is why this method doesn't just call GeyserCommandSource#hasPermission
if (sender.isConsole()) {
return true;
}
// Handle blank permissions ourselves, as cloud only handles empty ones
if (permission.isBlank()) {
return true;
}
for (PermissionChecker checker : permissionCheckers) {
Boolean result = checker.hasPermission(sender, permission).toBoolean();
if (result != null) {