summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua1
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp30
-rw-r--r--src/RankManager.cpp23
-rw-r--r--src/RankManager.h6
4 files changed, 60 insertions, 0 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index c474b5eb0..6138f945a 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2030,6 +2030,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
RemoveGroup = { Params = "GroupName", Return = "", Notes = "Removes the specified group completely. The group will be removed from all the ranks using it and then erased from the manager. Logs an info message and does nothing if the group doesn't exist." },
RemoveGroupFromRank = { Params = "GroupName, RankName", Return = "", Notes = "Removes the specified group from the specified rank. The group will still exist, even if it isn't assigned to any rank. Logs an info message and does nothing if the group or rank doesn't exist." },
RemovePermissionFromGroup = { Params = "Permission, GroupName", Return = "", Notes = "Removes the specified permission from the specified group. Logs an info message and does nothing if the group doesn't exist." },
+ RemovePlayerRank = { Params = "PlayerUUID", Return = "", Notes = "Removes the player's rank; the player's left without a rank. Note that this doesn't change the {{cPlayer}} instances for the already connected players, you need to update all the instances manually. No action if the player has no rank assigned to them already." },
RemoveRank = { Params = "RankName, [ReplacementRankName]", Return = "", Notes = "Removes the specified rank. If ReplacementRankName is given, the players that have RankName will get their rank set to ReplacementRankName. If it isn't given, or is an invalid rank, the players will be removed from the manager, their ranks will be unset completely. Logs an info message and does nothing if the rank is not found." },
RenameGroup = { Params = "OldName, NewName", Return = "", Notes = "Renames the specified group. Logs an info message and does nothing if the group is not found." },
RenameRank = { Params = "OldName, NewName", Return = "", Notes = "Renames the specified rank. Logs an info message and does nothing if the rank is not found." },
diff --git a/src/Bindings/ManualBindings_RankManager.cpp b/src/Bindings/ManualBindings_RankManager.cpp
index bc31ea687..5351c028d 100644
--- a/src/Bindings/ManualBindings_RankManager.cpp
+++ b/src/Bindings/ManualBindings_RankManager.cpp
@@ -717,6 +717,35 @@ static int tolua_cRankManager_RemovePermissionFromGroup(lua_State * L)
+/** Binds cRankManager::RemovePlayerRank */
+static int tolua_cRankManager_RemovePlayerRank(lua_State * L)
+{
+ // function signature:
+ // cRankManager:RemovePlayerRank(PlayerUUID)
+
+ cLuaState S(L);
+ if (
+ !S.CheckParamUserTable(1, "cRankManager") ||
+ !S.CheckParamString(2) ||
+ !S.CheckParamEnd(3)
+ )
+ {
+ return 0;
+ }
+
+ // Get the params:
+ AString PlayerUUID;
+ S.GetStackValue(2, PlayerUUID);
+
+ // Remove the player's rank:
+ cRoot::Get()->GetRankManager().RemovePlayerRank(PlayerUUID);
+ return 0;
+}
+
+
+
+
+
/** Binds cRankManager::RemoveRank */
static int tolua_cRankManager_RemoveRank(lua_State * L)
{
@@ -900,6 +929,7 @@ void ManualBindings::BindRankManager(lua_State * tolua_S)
tolua_function(tolua_S, "RemoveGroup", tolua_cRankManager_RemoveGroup);
tolua_function(tolua_S, "RemoveGroupFromRank", tolua_cRankManager_RemoveGroupFromRank);
tolua_function(tolua_S, "RemovePermissionFromGroup", tolua_cRankManager_RemovePermissionFromGroup);
+ tolua_function(tolua_S, "RemovePlayerRank", tolua_cRankManager_RemovePlayerRank);
tolua_function(tolua_S, "RemoveRank", tolua_cRankManager_RemoveRank);
tolua_function(tolua_S, "RenameGroup", tolua_cRankManager_RenameGroup);
tolua_function(tolua_S, "RenameRank", tolua_cRankManager_RenameRank);
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 96c4baa56..65e5d264c 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -1424,6 +1424,29 @@ void cRankManager::SetPlayerRank(const AString & a_PlayerUUID, const AString & a
+void cRankManager::RemovePlayerRank(const AString & a_PlayerUUID)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try
+ {
+ SQLite::Statement stmt(m_DB, "DELETE FROM PlayerRank WHERE PlayerUUID = ?");
+ stmt.bind(1, a_PlayerUUID);
+ stmt.exec();
+ }
+ catch(const SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to remove rank from player UUID %s: %s",
+ __FUNCTION__, a_PlayerUUID.c_str(), ex.what()
+ );
+ }
+}
+
+
+
+
+
void cRankManager::SetRankVisuals(
const AString & a_RankName,
const AString & a_MsgPrefix,
diff --git a/src/RankManager.h b/src/RankManager.h
index 3ccbd2fd4..532b4cd83 100644
--- a/src/RankManager.h
+++ b/src/RankManager.h
@@ -155,6 +155,12 @@ public:
cPlayer instances manually.
The PlayerName is provided for reference, so that GetRankPlayerNames() can work. */
void SetPlayerRank(const AString & a_PlayerUUID, const AString & a_PlayerName, const AString & a_RankName);
+
+ /** Removes the player's rank assignment. The player is left without a rank.
+ Note that this doesn't change the cPlayer instances for the already connected players, you need to update
+ all the instances manually.
+ No action if the player has no rank assigned to them already. */
+ void RemovePlayerRank(const AString & a_PlayerUUID);
/** Sets the message visuals of an existing rank. No action if the rank name is not found. */
void SetRankVisuals(