summaryrefslogtreecommitdiffstats
path: root/src/RankManager.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-08-21 20:47:52 +0200
committerMattes D <github@xoft.cz>2014-08-21 20:47:52 +0200
commit0c04bf962ed025789c1979c6d4fb122735b1a46b (patch)
tree45d95981acb121f8b14b27500489ef9d10e82fd2 /src/RankManager.cpp
parentRankMgr: Added cRankManager::RemovePlayerRank(). (diff)
downloadcuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar.gz
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar.bz2
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar.lz
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar.xz
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.tar.zst
cuberite-0c04bf962ed025789c1979c6d4fb122735b1a46b.zip
Diffstat (limited to 'src/RankManager.cpp')
-rw-r--r--src/RankManager.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 65e5d264c..349582950 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -365,7 +365,8 @@ protected:
cRankManager::cRankManager(void) :
m_DB("Ranks.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE),
- m_IsInitialized(false)
+ m_IsInitialized(false),
+ m_MojangAPI(NULL)
{
}
@@ -373,6 +374,18 @@ cRankManager::cRankManager(void) :
+cRankManager::~cRankManager()
+{
+ if (m_MojangAPI != NULL)
+ {
+ m_MojangAPI->SetRankManager(NULL);
+ }
+}
+
+
+
+
+
void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
{
ASSERT(!m_IsInitialized); // Calling Initialize for the second time?
@@ -386,6 +399,8 @@ void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
m_IsInitialized = true;
+ a_MojangAPI.SetRankManager(this);
+
// Check if tables empty, migrate from ini files then
if (AreDBTablesEmpty())
{
@@ -1655,6 +1670,28 @@ bool cRankManager::IsPermissionInGroup(const AString & a_Permission, const AStri
+void cRankManager::NotifyNameUUID(const AString & a_PlayerName, const AString & a_UUID)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try
+ {
+ SQLite::Statement stmt(m_DB, "UPDATE PlayerRank SET PlayerName = ? WHERE PlayerUUID = ?");
+ stmt.bind(1, a_PlayerName);
+ stmt.bind(2, a_UUID);
+ stmt.exec();
+ }
+ catch (const SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to update DB: %s", __FUNCTION__, ex.what());
+ }
+}
+
+
+
+
+
bool cRankManager::AreDBTablesEmpty(void)
{
return (