Skip to content

Commit d28ee7a

Browse files
committed
fix: fix potential permission issue for LegacyCommandAPI
1 parent 0e77b20 commit d28ee7a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/legacy/api/LegacyCommandAPI.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void registerLegacyCommand(
5252
if (!singleParam) {
5353
overload.optional("§e" + description + "§r", ParamKind::Bool);
5454
}
55-
overload.execute([playerFunc, consoleFunc, engine, hasSubCommand](
55+
overload.execute([playerFunc, consoleFunc, engine, hasSubCommand, level](
5656
CommandOrigin const& origin,
5757
CommandOutput& output,
5858
RuntimeCommand const& command
@@ -67,7 +67,7 @@ void registerLegacyCommand(
6767
}
6868
}
6969
if (origin.getOriginType() == CommandOriginType::Player && playerFunc) {
70-
if (origin.getPermissionsLevel() < command.mPermissionLevel) {
70+
if (origin.getPermissionsLevel() < level) {
7171
output.error("You don't have permission to use this command."_tr());
7272
return;
7373
}
@@ -91,6 +91,9 @@ void newLegacyCommand(
9191
if (isPlayer) {
9292
if (fakeCommands.contains(name)) {
9393
fakeCommands[name].playerFunc = script::Global(func);
94+
// Override CommandPermissionLevel if command has been created as console command to ensure player has the
95+
// permission to execute the command
96+
fakeCommands[name].level = level;
9497
} else {
9598
fakeCommands[name] = {
9699
description,

0 commit comments

Comments
 (0)