Fix failures on NullPointerExceptions

This commit is contained in:
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;
try {
Ini.Section joinFloodControlSection = channelSection.getChild("JoinFloodControl");
joinFloodControl = joinFloodControlSection.get("enable", boolean.class);
joinFloodControlEventsNumber = -1;
joinFloodControlTimeFrame = -1;
if (joinFloodControl){ if (joinFloodControl){
joinFloodControlEventsNumber = joinFloodControlSection.get("join number", int.class); joinFloodControlEventsNumber = joinFloodControlSection.get("join number", int.class);
joinFloodControlTimeFrame = joinFloodControlSection.get("time frame", int.class); joinFloodControlTimeFrame = joinFloodControlSection.get("time frame", int.class);
} }
} catch (NullPointerException ignore) {}
Ini.Section joinCloneControlSection = channelSection.getChild("JoinCloneControl"); boolean joinCloneControl = false;
boolean joinCloneControl = joinCloneControlSection.get("enable", boolean.class);
int joinCloneControlTimeFrame = -1; int joinCloneControlTimeFrame = -1;
String joinCloneControlPattern = ""; String joinCloneControlPattern = "";
try {
Ini.Section joinCloneControlSection = channelSection.getChild("JoinCloneControl");
joinCloneControl = joinCloneControlSection.get("enable", boolean.class);
joinCloneControlTimeFrame = -1;
joinCloneControlPattern = "";
if (joinCloneControl){ if (joinCloneControl){
joinCloneControlTimeFrame = joinCloneControlSection.get("time frame", int.class); joinCloneControlTimeFrame = joinCloneControlSection.get("time frame", int.class);
joinCloneControlPattern = joinCloneControlSection.getOrDefault("pattern", ""); joinCloneControlPattern = joinCloneControlSection.getOrDefault("pattern", "");
} }
} catch (NullPointerException ignore) {}
Profile.Section parseLinksTitlesSection = channelSection.getChild("ParseLinksTitles"); Profile.Section parseLinksTitlesSection = channelSection.getChild("ParseLinksTitles");