summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-21 16:55:39 +0200
committerMattes D <github@xoft.cz>2014-08-21 16:55:39 +0200
commit326dd7e4c6baa6070d35a2a46ca20404c623c8e1 (patch)
treec87ad1a554656a97f706c067ee23956849be55a3 /src
parentRemoved last remnant of cGroup. (diff)
downloadcuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar.gz
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar.bz2
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar.lz
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar.xz
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.tar.zst
cuberite-326dd7e4c6baa6070d35a2a46ca20404c623c8e1.zip
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/ManualBindings_RankManager.cpp30
-rw-r--r--src/RankManager.cpp23
-rw-r--r--src/RankManager.h6
3 files changed, 59 insertions, 0 deletions
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(