mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Handle blank permissions properly
This commit is contained in:
parent
5ee0d41aab
commit
b2a22505f9
7 changed files with 14 additions and 6 deletions
|
|
@ -97,7 +97,8 @@ public class BungeeCommandSource implements GeyserCommandSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -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.
|
// 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.
|
// This works for our calls, but not for cloud's internal usage. For that case, see above.
|
||||||
try {
|
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) {
|
} catch (PermissionNotRegisteredException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ import org.geysermc.geyser.command.GeyserCommandSource;
|
||||||
import org.geysermc.geyser.platform.spigot.PaperAdventure;
|
import org.geysermc.geyser.platform.spigot.PaperAdventure;
|
||||||
import org.geysermc.geyser.text.GeyserLocale;
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SpigotCommandSource implements GeyserCommandSource {
|
public class SpigotCommandSource implements GeyserCommandSource {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ public class VelocityCommandSource implements GeyserCommandSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,8 @@ public class CommandRegistry implements EventRegistrar {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPermission(GeyserCommandSource source, String permission) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ public abstract class GeyserCommand implements org.geysermc.geyser.api.command.C
|
||||||
throw new IllegalArgumentException("Command cannot be null or blank!");
|
throw new IllegalArgumentException("Command cannot be null or blank!");
|
||||||
}
|
}
|
||||||
if (permission.isBlank()) {
|
if (permission.isBlank()) {
|
||||||
|
permission = ""; // Cloud treats empty permissions as available to everyone, but not blank permissions.
|
||||||
permissionDefault = null;
|
permissionDefault = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,11 +103,15 @@ public class StandaloneCloudCommandManager extends CommandManager<GeyserCommandS
|
||||||
// GeyserLogger#hasPermission always returns true
|
// GeyserLogger#hasPermission always returns true
|
||||||
// GeyserSession#hasPermission delegates to this method,
|
// GeyserSession#hasPermission delegates to this method,
|
||||||
// which is why this method doesn't just call GeyserCommandSource#hasPermission
|
// which is why this method doesn't just call GeyserCommandSource#hasPermission
|
||||||
|
|
||||||
if (sender.isConsole()) {
|
if (sender.isConsole()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle blank permissions ourselves, as cloud only handles empty ones
|
||||||
|
if (permission.isBlank()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
for (PermissionChecker checker : permissionCheckers) {
|
for (PermissionChecker checker : permissionCheckers) {
|
||||||
Boolean result = checker.hasPermission(sender, permission).toBoolean();
|
Boolean result = checker.hasPermission(sender, permission).toBoolean();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue