summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-28 15:16:11 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-28 15:16:11 +0200
commit63c53a8e23776cc3011fd0260857bd22274e2c62 (patch)
tree014d4498cffa77ce5bf504abe96e7d23832c9d5b
parentUpdated api documentation. (diff)
downloadcuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.gz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.bz2
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.lz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.xz
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.tar.zst
cuberite-63c53a8e23776cc3011fd0260857bd22274e2c62.zip
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua1
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp22
-rw-r--r--src/RankManager.cpp19
-rw-r--r--src/RankManager.h4
4 files changed, 46 insertions, 0 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index fbed7cc00..2250092ba 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2033,6 +2033,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
AddGroupToRank = { Params = "GroupName, RankName", Return = "bool", Notes = "Adds the specified group to the specified rank. Returns true on success, false on failure - if the group name or the rank name is not found." },
AddPermissionToGroup = { Params = "Permission, GroupName", Return = "bool", Notes = "Adds the specified permission to the specified group. Returns true on success, false on failure - if the group name is not found." },
AddRank = { Params = "RankName, MsgPrefix, MsgSuffix, MsgNameColorCode", Return = "", Notes = "Adds a new rank of the specified name and with the specified message visuals. Logs an info message and does nothing if the rank already exists." },
+ ClearPlayerRanks = { Params = "", Return = "", Notes = "Removes all player ranks from the database. Note that this doesn't change the cPlayer instances for the already connected players, you need to update all the instances manually." },
GetAllGroups = { Params = "", Return = "array-table of groups' names", Notes = "Returns an array-table containing the names of all the groups that are known to the manager." },
GetAllPermissions = { Params = "", Return = "array-table of permissions", Notes = "Returns an array-table containing all the permissions that are known to the manager." },
GetAllPlayers = { Params = "", Return = "array-table of playernames", Notes = "Returns the short uuids of all defined players." },
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
index b43cd9ef2..cddf1ec2e 100644
--- a/src/Bindings/ManualBindings_RankManager.cpp
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -129,6 +129,27 @@ static int tolua_cRankManager_AddRank(lua_State * L)
+/** Binds cRankManager::ClearPlayerRanks */
+static int tolua_cRankManager_ClearPlayerRanks(lua_State * L)
+{
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamEnd(2)
+ )
+ {
+ return 0;
+ }
+
+ // Remove all players:
+ cRoot::Get()->GetRankManager().ClearPlayerRanks();
+ return 1;
+}
+
+
+
+
+
/** Binds cRankManager::GetAllGroups */
static int tolua_cRankManager_GetAllGroups(lua_State * L)
{
@@ -1031,6 +1052,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
tolua_function(tolua_S, "AddGroupToRank", tolua_cRankManager_AddGroupToRank);
tolua_function(tolua_S, "AddPermissionToGroup", tolua_cRankManager_AddPermissionToGroup);
tolua_function(tolua_S, "AddRank", tolua_cRankManager_AddRank);
+ tolua_function(tolua_S, "ClearPlayerRanks", tolua_cRankManager_ClearPlayerRanks);
tolua_function(tolua_S, "GetAllGroups", tolua_cRankManager_GetAllGroups);
tolua_function(tolua_S, "GetAllPermissions", tolua_cRankManager_GetAllPermissions);
tolua_function(tolua_S, "GetAllPlayers", tolua_cRankManager_GetAllPlayers);
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 0f267473a..fd5e58025 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -1817,6 +1817,25 @@ bool cRankManager::SetDefaultRank(const AString & a_RankName)
+void cRankManager::ClearPlayerRanks(void)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try {
+ SQLite::Statement stmt(m_DB, "DELETE FROM PlayerRank");
+ stmt.exec();
+ }
+ catch (SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to remove/clear all players: %s", __FUNCTION__, ex.what());
+ }
+}
+
+
+
+
+
bool cRankManager::UpdatePlayerName(const AString & a_PlayerUUID, const AString & a_NewPlayerName)
{
ASSERT(m_IsInitialized);
diff --git a/src/RankManager.h b/src/RankManager.h
index b577fad05..acfcdb01d 100644
--- a/src/RankManager.h
+++ b/src/RankManager.h
@@ -217,6 +217,10 @@ public:
/** Returns the name of the default rank. */
const AString & GetDefaultRank(void) const { return m_DefaultRank; }
+
+ /** Removes all player ranks from the database. Note that this doesn't change the cPlayer instances
+ for the already connected players, you need to update all the instances manually. */
+ void ClearPlayerRanks(void);
/** Updates the playername that is saved with this uuid. Returns false if a error occurred */
bool UpdatePlayerName(const AString & a_PlayerUUID, const AString & a_NewPlayerName);