Browse Source

Config file is now actually updated after delmod

pull/15/head
Jessica James 4 years ago
parent
commit
79bd6f4c55
  1. 14
      src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.cpp
  2. 2
      src/Plugins/RenX/RenX.ModSystem/RenX_ModSystem.h

14
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());

2
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;

Loading…
Cancel
Save