From 4e11095441fc98e59611008735949900d72d7465 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 14 Dec 2013 02:02:26 +0000 Subject: Groups.ini and Users.ini are now generated --- MCServer/banned.example.ini | 3 --- MCServer/groups.example.ini | 17 ----------------- MCServer/users.example.ini | 23 ----------------------- MCServer/whitelist.example.ini | 6 ------ src/Entities/Player.cpp | 7 ++++++- src/GroupManager.cpp | 21 +++++++++++++++++++-- 6 files changed, 25 insertions(+), 52 deletions(-) delete mode 100644 MCServer/banned.example.ini delete mode 100644 MCServer/groups.example.ini delete mode 100644 MCServer/users.example.ini delete mode 100644 MCServer/whitelist.example.ini diff --git a/MCServer/banned.example.ini b/MCServer/banned.example.ini deleted file mode 100644 index ceb71fe0b..000000000 --- a/MCServer/banned.example.ini +++ /dev/null @@ -1,3 +0,0 @@ -[Banned] -;PlayerName=1 - diff --git a/MCServer/groups.example.ini b/MCServer/groups.example.ini deleted file mode 100644 index 2e4b5ebee..000000000 --- a/MCServer/groups.example.ini +++ /dev/null @@ -1,17 +0,0 @@ -[Admins] -Permissions=* -Color=c - -[Mods] -Color=5 -Inherits=Vips -Permissions=core.time,core.item - -[Vips] -Permissions=core.teleport -Color=2 -Inherits=Default - -[Default] -Permissions=core.build,core.help,core.playerlist,core.pluginlist,core.spawn,transapi.setlang,core.tell,core.me -Color=7 diff --git a/MCServer/users.example.ini b/MCServer/users.example.ini deleted file mode 100644 index 6726c0bf8..000000000 --- a/MCServer/users.example.ini +++ /dev/null @@ -1,23 +0,0 @@ -[FakeTruth] -Groups=Admins - -[Duralex] -Groups=Admins - -[Luthrandel] -Groups=Admins - -[cruisecho] -Groups=Admins - -[Kwen] -Groups=Admins - -[aloe_vera] -Groups=Admins - -[xoft] -Groups=Admins - -[Player] -Groups=Admins \ No newline at end of file diff --git a/MCServer/whitelist.example.ini b/MCServer/whitelist.example.ini deleted file mode 100644 index a89c148c9..000000000 --- a/MCServer/whitelist.example.ini +++ /dev/null @@ -1,6 +0,0 @@ -[WhiteListSettings] -WhiteListOn=0 - -[WhiteList] -;PlayerName=1 - diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7a5ff5696..ff519f890 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1393,7 +1393,12 @@ void cPlayer::LoadPermissionsFromDisk() } else { - LOGWARN("Failed to read the users.ini file. The player will be added only to the Default group."); + LOGWARN("Regenerating users.ini, player %s will be added to the \"Default\" group", m_PlayerName.c_str()); + IniFile.AddHeaderComment(" This is the file in which the group the player belongs to is stored"); + IniFile.AddHeaderComment(" The format is: [PlayerName] | Groups=GroupName"); + + IniFile.SetValue(m_PlayerName, "Groups", "Default"); + IniFile.WriteFile("users.ini"); AddToGroup("Default"); } ResolvePermissions(); diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index df609f05b..1ffe3812f 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -47,8 +47,25 @@ cGroupManager::cGroupManager() cIniFile IniFile; if (!IniFile.ReadFile("groups.ini")) { - LOGWARNING("groups.ini inaccessible, no groups are defined"); - return; + LOGWARNING("Regenerating groups.ini, all groups will be reset"); + IniFile.AddHeaderComment(" This is the MCServer permissions manager groups file"); + IniFile.AddHeaderComment(" It stores all defined groups such as Administrators, Players, or Moderators"); + + IniFile.SetValue("Owner", "Permissions", "*", true); + IniFile.SetValue("Owner", "Color", "2", true); + + IniFile.SetValue("Moderator", "Permissions", "core.time,core.item,core.teleport,core.ban,core.unban,core.save-all,core.toggledownfall"); + IniFile.SetValue("Moderator", "Color", "2", true); + IniFile.SetValue("Moderator", "Inherits", "Player", true); + + IniFile.SetValue("Player", "Permissions", "core.build", true); + IniFile.SetValue("Player", "Color", "f", true); + IniFile.SetValue("Player", "Inherits", "Default", true); + + IniFile.SetValue("Default", "Permissions", "core.help,core.playerlist,core.pluginlist,core.spawn,core.listworlds,core.back,core.motd,core.gotoworld,core.coords,core.viewdistance", true); + IniFile.SetValue("Default", "Color", "f", true); + + IniFile.WriteFile("groups.ini"); } unsigned int NumKeys = IniFile.GetNumKeys(); -- cgit v1.2.3