From 79bd6f4c55d53d694707c8bbcf6150def78feb9b Mon Sep 17 00:00:00 2001 From: Jessica James Date: Sat, 8 Aug 2020 19:33:35 -0500 Subject: [PATCH] Config file is now actually updated after delmod --- src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp | 14 +++++++++----- src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp b/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp index 3d8a34c..9349f83 100644 --- a/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp +++ b/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp @@ -257,6 +257,10 @@ bool RenX_ModSystemPlugin::set(RenX::PlayerInfo &player, RenX_ModSystemPlugin::M return r; } +bool RenX_ModSystemPlugin::removeModSection(const Jupiter::ReadableString& section) { + return config.removeSection(section) && config.write(); +} + RenX_ModSystemPlugin::ModGroup *RenX_ModSystemPlugin::getGroupByName(const Jupiter::ReadableString &name, ModGroup *defaultGroup) const { if (RenX_ModSystemPlugin::groups.size() != 0) @@ -758,14 +762,14 @@ void DelIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &chan player = server->getPlayerByPartName(parameters); if (player == nullptr) { - if (pluginInstance.modsFile.removeSection(parameters)) + if (pluginInstance.removeModSection(parameters)) source->sendNotice(nick, "Player has been removed from the moderator list."_jrs); else { - for (auto& section : pluginInstance.modsFile.getSections()) + for (auto& section : pluginInstance.getConfig().getSections()) { if (section.second.get("Name"_jrs).equalsi(parameters)) { - if (pluginInstance.modsFile.removeSection(section.first)) + if (pluginInstance.removeModSection(section.first)) source->sendNotice(nick, "Player has been removed from the moderator list."_jrs); else source->sendNotice(nick, "Error: Unknown error occurred."_jrs); @@ -779,7 +783,7 @@ void DelIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString &chan } else if (player->isBot) source->sendNotice(nick, "Error: A bot can not be a moderator."_jrs); - else if (pluginInstance.modsFile.removeSection(player->uuid)) + else if (pluginInstance.removeModSection(player->uuid)) source->sendNotice(nick, "Player has been removed from the moderator list."_jrs); else source->sendNotice(nick, "Player is not in the moderator list."_jrs); @@ -888,7 +892,7 @@ void ModListIRCCommand::trigger(IRC_Bot *source, const Jupiter::ReadableString & msg.aformat(IRCNORMAL " (Access: %d): ", node->access); msgBaseSize = msg.size(); - for (auto& section : pluginInstance.modsFile.getSections()) { + for (auto& section : pluginInstance.getConfig().getSections()) { if (section.second.get("Group"_jrs).equalsi(node->name)) { msg += section.second.get("Name"_jrs, section.second.getName()); diff --git a/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h b/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h index 2acad86..af70a8e 100644 --- a/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h +++ b/src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h @@ -76,6 +76,7 @@ public: void tempAuth(RenX::Server &server, const RenX::PlayerInfo &player, const ModGroup *group, bool notify = true) const; bool set(RenX::PlayerInfo &player, ModGroup &group); + bool removeModSection(const Jupiter::ReadableString& section); int getConfigAccess(const Jupiter::ReadableString &uuid) const; size_t getGroupCount() const; @@ -103,7 +104,6 @@ public: // RenX::Plugin public: // Jupiter::Plugin int OnRehash() override; - Jupiter::Config &modsFile = Jupiter::Plugin::config; private: bool lockSteam; bool lockIP;