summaryrefslogtreecommitdiffstats
path: root/src/RankManager.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-28 02:17:32 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-28 02:17:32 +0200
commit2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d (patch)
tree1243615638ca28edc20ba62b8272d814f685aaa4 /src/RankManager.cpp
parent1.8: Fixed plugin messages. (diff)
downloadcuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar.gz
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar.bz2
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar.lz
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar.xz
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.tar.zst
cuberite-2fb3eb3532c2c40e21def269cb9d5ca6eb11ef6d.zip
Diffstat (limited to '')
-rw-r--r--src/RankManager.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index e5896f8f3..0f267473a 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -496,6 +496,33 @@ AString cRankManager::GetPlayerRankName(const AString & a_PlayerUUID)
+AString cRankManager::GetPlayerName(const AString & a_PlayerUUID)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try
+ {
+ // Prepare the DB statement:
+ SQLite::Statement stmt(m_DB, "SELECT PlayerName FROM PlayerRank WHERE PlayerUUID = ?");
+ stmt.bind(1, a_PlayerUUID);
+
+ if (stmt.executeStep())
+ {
+ return stmt.getColumn(0).getText();
+ }
+ }
+ catch (SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Cannot get player name: %s", __FUNCTION__, ex.what());
+ }
+ return AString();
+}
+
+
+
+
+
AStringVector cRankManager::GetPlayerGroups(const AString & a_PlayerUUID)
{
ASSERT(m_IsInitialized);
@@ -636,6 +663,32 @@ AStringVector cRankManager::GetRankPermissions(const AString & a_RankName)
+AStringVector cRankManager::GetAllPlayers(void)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ AStringVector res;
+ try
+ {
+ SQLite::Statement stmt(m_DB, "SELECT PlayerUUID FROM PlayerRank");
+ while (stmt.executeStep())
+ {
+ res.push_back(stmt.getColumn(0).getText());
+ }
+ }
+ catch (const SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to get players from DB: %s", __FUNCTION__, ex.what());
+ }
+ return res;
+}
+
+
+
+
+
+
AStringVector cRankManager::GetAllRanks(void)
{
ASSERT(m_IsInitialized);
@@ -1764,6 +1817,34 @@ bool cRankManager::SetDefaultRank(const AString & a_RankName)
+bool cRankManager::UpdatePlayerName(const AString & a_PlayerUUID, const AString & a_NewPlayerName)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try
+ {
+ SQLite::Statement stmt(m_DB, "UPDATE PlayerRank SET PlayerName = ? WHERE PlayerUUID = ?");
+ stmt.bind(1, a_NewPlayerName);
+ stmt.bind(2, a_PlayerUUID);
+ if (stmt.exec() > 0)
+ {
+ // The player name was changed, returns true
+ return true;
+ }
+ }
+ catch (const SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to update player name from UUID %s: %s", __FUNCTION__, a_PlayerUUID.c_str(), ex.what());
+ }
+ return false;
+}
+
+
+
+
+
+
bool cRankManager::AreDBTablesEmpty(void)
{
return (