Fix failures on NullPointerExceptions

master
Dmitry Isaenko 2021-01-18 18:31:06 +03:00
parent dac70bfd35
commit 51fd7ef228
2 changed files with 24 additions and 15 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>loper</groupId> <groupId>loper</groupId>
<artifactId>InnaIrcBot</artifactId> <artifactId>InnaIrcBot</artifactId>
<version>0.8-SNAPSHOT</version> <version>0.9-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>InnaIrcBot</name> <name>InnaIrcBot</name>

View File

@ -104,26 +104,35 @@ public class ConfigurationFile {
if (channelRules == null) if (channelRules == null)
channelRules = new ArrayList<>(); channelRules = new ArrayList<>();
Ini.Section joinFloodControlSection = channelSection.getChild("JoinFloodControl"); boolean joinFloodControl = false;
boolean joinFloodControl = joinFloodControlSection.get("enable", boolean.class);
int joinFloodControlEventsNumber = -1; int joinFloodControlEventsNumber = -1;
int joinFloodControlTimeFrame = -1; int joinFloodControlTimeFrame = -1;
if (joinFloodControl){ try {
joinFloodControlEventsNumber = joinFloodControlSection.get("join number", int.class); Ini.Section joinFloodControlSection = channelSection.getChild("JoinFloodControl");
joinFloodControlTimeFrame = joinFloodControlSection.get("time frame", int.class);
}
Ini.Section joinCloneControlSection = channelSection.getChild("JoinCloneControl"); joinFloodControl = joinFloodControlSection.get("enable", boolean.class);
joinFloodControlEventsNumber = -1;
boolean joinCloneControl = joinCloneControlSection.get("enable", boolean.class); joinFloodControlTimeFrame = -1;
if (joinFloodControl){
joinFloodControlEventsNumber = joinFloodControlSection.get("join number", int.class);
joinFloodControlTimeFrame = joinFloodControlSection.get("time frame", int.class);
}
} catch (NullPointerException ignore) {}
boolean joinCloneControl = false;
int joinCloneControlTimeFrame = -1; int joinCloneControlTimeFrame = -1;
String joinCloneControlPattern = ""; String joinCloneControlPattern = "";
if (joinCloneControl){ try {
joinCloneControlTimeFrame = joinCloneControlSection.get("time frame", int.class); Ini.Section joinCloneControlSection = channelSection.getChild("JoinCloneControl");
joinCloneControlPattern = joinCloneControlSection.getOrDefault("pattern", "");
} joinCloneControl = joinCloneControlSection.get("enable", boolean.class);
joinCloneControlTimeFrame = -1;
joinCloneControlPattern = "";
if (joinCloneControl){
joinCloneControlTimeFrame = joinCloneControlSection.get("time frame", int.class);
joinCloneControlPattern = joinCloneControlSection.getOrDefault("pattern", "");
}
} catch (NullPointerException ignore) {}
Profile.Section parseLinksTitlesSection = channelSection.getChild("ParseLinksTitles"); Profile.Section parseLinksTitlesSection = channelSection.getChild("ParseLinksTitles");