From f54ed35a096152b34edf3f97a3be897a25c52f10 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 6 Jun 2020 15:42:35 +0800 Subject: [PATCH] =?UTF-8?q?[Change]=20SettingProperties=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=BE=A4=E5=8F=B7=E6=A3=80=E6=9F=A5,=20=E9=98=B2?= =?UTF-8?q?=E6=AD=A2=E5=87=BA=E7=8E=B0=E9=9D=9E=E6=B3=95=E7=BE=A4=E5=8F=B7?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/lamgc/cgj/bot/SettingProperties.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/lamgc/cgj/bot/SettingProperties.java b/src/main/java/net/lamgc/cgj/bot/SettingProperties.java index 1520959..6625468 100644 --- a/src/main/java/net/lamgc/cgj/bot/SettingProperties.java +++ b/src/main/java/net/lamgc/cgj/bot/SettingProperties.java @@ -51,6 +51,10 @@ public final class SettingProperties { long groupId; try { groupId = Long.parseLong(name.substring(name.indexOf("group.") + 6, name.lastIndexOf(".properties"))); + if(groupId <= 0) { + log.warn("无效的群配置文件: {}", groupId); + continue; + } } catch (NumberFormatException e) { log.error("非法的配置文件名: {}", name); continue; @@ -233,7 +237,7 @@ public final class SettingProperties { * @return 如果群组存在所属Properties, 则返回群组Properties, 否则返回GlobalProperties. */ public static Properties getProperties(long groupId) { - if(groupPropMap.containsKey(groupId)) { + if(groupId > 0 && groupPropMap.containsKey(groupId)) { return groupPropMap.get(groupId); } return getGlobalProperties();