Fix run() with a locked SettingsManager (#755)

* Fix run() in locked SettingsManager

* Fix small security issue while I'm at it

* Notify command change
This commit is contained in:
altrisi authored and GitHub committed 2021-03-07 17:14:35 -04:00
1 parent 38458a8e35
commit b123899abd
1 file changed
+11 -5
+11 -5
View File
@@ -413,20 +413,26 @@ public class CarpetSettings
private static class ModulePermissionLevel extends Validator<String> {
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
CarpetSettings.runPermissionLevel = SettingsManager.getCommandLevel(newValue);
int permissionLevel = SettingsManager.getCommandLevel(newValue);
if (source != null && !source.hasPermissionLevel(permissionLevel))
return null;
CarpetSettings.runPermissionLevel = permissionLevel;
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
return newValue;
}
@Override
public String description() { return "Also controls permission level of commands executed via `run()`";}
public String description() { return "When changing the rule, you must at least have the permission level you are trying to give it";}
}
@Rule(
desc = "Enables restrictions for arbitrary code execution with scarpet",
extra = {
"Users that don't have this permission level",
"won't be able to load apps or /script run"
"won't be able to load apps or /script run.",
"It is also the permission level apps will",
"have when running commands with run()"
},
category = {COMMAND, SCARPET},
validate = ModulePermissionLevel.class
category = {SCARPET},
validate = {Validator._COMMAND_LEVEL_VALIDATOR.class, ModulePermissionLevel.class}
)
public static String commandScriptACE = "ops";