[Fix] SettingProperties 修复在初次设置群组配置时未创建该群组所属Properties导致NPE的问题;

[Update] BotAdminCommandProcess 更新日志内容及命令返回信息;
[Change] BotCommandProcess 调整配置项key格式;
This commit is contained in:
2020-05-06 10:55:32 +08:00
parent b969bb29b2
commit cb42aadb15
3 changed files with 16 additions and 6 deletions

View File

@ -186,7 +186,13 @@ public final class SettingProperties {
*/
public static String setProperty(long groupId, String key, String value) {
Objects.requireNonNull(key);
Properties targetProperties = groupId <= 0 ? globalProp : getGroupProperties(groupId);
Properties targetProperties;
if(groupId <= 0) {
changeList.add(groupId);
targetProperties = getGroupProperties(groupId);
} else {
targetProperties = globalProp;
}
String lastValue = targetProperties.getProperty(key);
if(value != null) {
targetProperties.setProperty(key, value);
@ -214,6 +220,9 @@ public final class SettingProperties {
if (groupId <= 0) {
throw new IllegalArgumentException("Group number cannot be 0 or negative: " + groupId);
}
if(!groupPropMap.containsKey(groupId)) {
groupPropMap.put(groupId, new Properties(globalProp));
}
return groupPropMap.get(groupId);
}