diff --git a/BedrockServer.cpp b/BedrockServer.cpp index 0a2075ad1..0a9841ac8 100644 --- a/BedrockServer.cpp +++ b/BedrockServer.cpp @@ -64,6 +64,10 @@ void BedrockServer::syncWrapper() SINFO("Exiting syncWrapper"); } +shared_ptr BedrockServer::getDBPool() { + return _dbPool; +} + void BedrockServer::sync() { // Parse out the number of worker threads we'll use. The DB needs to know this because it will expect a diff --git a/BedrockServer.h b/BedrockServer.h index c71d702c9..9807552b8 100644 --- a/BedrockServer.h +++ b/BedrockServer.h @@ -236,6 +236,9 @@ class BedrockServer : public SQLiteServer { // else. In the future, when all command queues are removed, this will not be the case, but right now, you can not rely on the command having completed when this returns. void runCommand(unique_ptr&& command, bool isBlocking = false, bool hasDedicatedThread = true); + // Expose the DB pool to plugins. + shared_ptr getDBPool(); + private: // The name of the sync thread. static constexpr auto _syncThreadName = "sync"; diff --git a/libstuff/libstuff.cpp b/libstuff/libstuff.cpp index b3b1527f6..a7f842cb3 100644 --- a/libstuff/libstuff.cpp +++ b/libstuff/libstuff.cpp @@ -701,6 +701,16 @@ bool SParseList(const char* ptr, list& valueList, char separator) { return (!component.empty()); } +// -------------------------------------------------------------------------- +set SParseSet(const string& value, char separator) { + set valueSet; + list strings = SParseList(value, separator); + for (const string& str : strings) { + valueSet.insert(str); + } + return valueSet; +} + STable SParseCommandLine(int argc, char* argv[]) { // Just walk across and find the pairs, then put the remainder on a list in the method STable results; diff --git a/libstuff/libstuff.h b/libstuff/libstuff.h index 631e4162c..b29ff3e44 100644 --- a/libstuff/libstuff.h +++ b/libstuff/libstuff.h @@ -448,6 +448,7 @@ list SParseIntegerList(const string& value, char separator = ','); set SParseIntegerSet(const string& value, char separator = ','); bool SParseList(const char* value, list& valueList, char separator = ','); bool SParseList(const string& value, list& valueList, char separator = ','); +set SParseSet(const string& value, char separator = ','); list SParseList(const string& value, char separator = ','); // Concatenates things into a string. "Things" can mean essentially any