diff --git a/pom.xml b/pom.xml index 7914543..6948fc1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ UTF-8 - 1.20-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT SNAPSHOT @@ -24,7 +24,6 @@ - @@ -72,7 +71,18 @@ dynmap https://repo.mikeprimm.com/ - + + + + sk89q-repo + https://maven.sk89q.com/repo/ + + false + + + false + + diff --git a/src/main/java/com/cnaude/purpleirc/PurpleBot.java b/src/main/java/com/cnaude/purpleirc/PurpleBot.java index d1b6e1c..8984199 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleBot.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleBot.java @@ -39,6 +39,7 @@ import static com.cnaude.purpleirc.IRCMessage.Type.CTCP; import static com.cnaude.purpleirc.IRCMessage.Type.MESSAGE; import static com.cnaude.purpleirc.IRCMessage.Type.NOTICE; import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap; +import com.cnaude.purpleirc.Utilities.FileHelpers; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableSortedSet; import com.massivecraft.factions.entity.Faction; @@ -132,6 +133,7 @@ public final class PurpleBot { public String botIdentPassword; public String saslUsername; public String saslPassword; + public String saslPasswordFile; public List rawMessages; public String channelCmdNotifyMode; public String partInvalidChannelsMsg; @@ -818,7 +820,14 @@ public final class PurpleBot { botServerPass = config.getString("password", ""); botIdentPassword = config.getString("ident-password", ""); saslUsername = config.getString("sasl-username", ""); - saslPassword = config.getString("sasl-password", ""); + saslPasswordFile = config.getString("sasl-password-file", ""); + if (!saslPasswordFile.isEmpty()) { + plugin.logInfo("Loading sasl password from file: " + saslPasswordFile); + saslPassword = FileHelpers.loadFirstLineFromFile(saslPasswordFile); + } else { + saslPassword = config.getString("sasl-password", ""); + } +// plugin.logDebug("saslPassword: " + saslPassword); commandPrefix = config.getString("command-prefix", "."); chatDelay = config.getLong("message-delay", 1000); finger = config.getString("finger-reply", "PurpleIRC"); diff --git a/src/main/java/com/cnaude/purpleirc/Utilities/FileHelpers.java b/src/main/java/com/cnaude/purpleirc/Utilities/FileHelpers.java new file mode 100644 index 0000000..1d103ae --- /dev/null +++ b/src/main/java/com/cnaude/purpleirc/Utilities/FileHelpers.java @@ -0,0 +1,23 @@ +package com.cnaude.purpleirc.Utilities; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +public class FileHelpers { + + public static String loadFirstLineFromFile(String filePath) throws IOException { + File file = new File(filePath); + + if (!file.exists() || !file.canRead()) { + throw new IOException("File does not exist or is not readable."); + } + + String firstLine; + try (BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath))) { + firstLine = bufferedReader.readLine(); + } + return firstLine; + } +} diff --git a/src/main/resources/SampleBot.yml b/src/main/resources/SampleBot.yml index a98e4e3..0b35f41 100644 --- a/src/main/resources/SampleBot.yml +++ b/src/main/resources/SampleBot.yml @@ -47,6 +47,8 @@ ident-password: '' sasl: false # SASL password sasl-password: '' +# Load SASL password from a file instead of this YAML file +sasl-password-file: '' # SASL username sasl-username: '' # command-prefix - The bot will listen for commands that start with this.