Store properties as Json::Value
This commit is contained in:
@@ -115,7 +115,8 @@ void cAuthenticator::Authenticate(int a_ClientID, const AString & a_UserName, co
|
||||
{
|
||||
if (!m_ShouldAuthenticate)
|
||||
{
|
||||
cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName));
|
||||
Json::Value Value;
|
||||
cRoot::Get()->AuthenticateUser(a_ClientID, a_UserName, cClientHandle::GenerateOfflineUUID(a_UserName), Value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +178,7 @@ void cAuthenticator::Execute(void)
|
||||
AString UUID;
|
||||
if (AuthWithYggdrasil(NewUserName, ServerID, UUID))
|
||||
{
|
||||
AString Properties;
|
||||
Json::Value Properties;
|
||||
if (!GetPlayerProperties(UUID, Properties))
|
||||
{
|
||||
LOGINFO("User %s authenticated with UUID %s but property getting failed", NewUserName.c_str(), UUID.c_str());
|
||||
@@ -329,7 +330,7 @@ bool cAuthenticator::AuthWithYggdrasil(AString & a_UserName, const AString & a_S
|
||||
|
||||
|
||||
|
||||
bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Properties)
|
||||
bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties)
|
||||
{
|
||||
LOGD("Trying to get properties for user %s", a_UUID.c_str());
|
||||
|
||||
@@ -383,6 +384,10 @@ bool cAuthenticator::GetPlayerProperties(const AString & a_UUID, AString & a_Pro
|
||||
return false;
|
||||
}
|
||||
|
||||
a_Properties = root["properties"].toStyledString();
|
||||
a_Properties = root["properties"];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
// fwd: "cRoot.h"
|
||||
class cRoot;
|
||||
|
||||
namespace Json
|
||||
{
|
||||
class Value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -79,12 +84,14 @@ private:
|
||||
/** cIsThread override: */
|
||||
virtual void Execute(void) override;
|
||||
|
||||
/** Connects to a hostname using SSL, sends given data, and sets the response, returning whether all was successful or not */
|
||||
bool ConnectSecurelyToAddress(const AString & a_CACerts, const AString & a_ExpectedPeerName, const AString & a_Data, AString & a_Response);
|
||||
|
||||
/** Returns true if the user authenticated okay, false on error; iLevel is the recursion deptht (bails out if too deep) */
|
||||
bool AuthWithYggdrasil(AString & a_UserName, const AString & a_ServerId, AString & a_UUID);
|
||||
|
||||
bool GetPlayerProperties(const AString & a_UUID, AString & a_Properties);
|
||||
/** Gets the properties, such as skin, of a player based on their UUID via Mojang's API */
|
||||
bool GetPlayerProperties(const AString & a_UUID, Json::Value & a_Properties);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -3016,12 +3016,8 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player)
|
||||
Pkt.WriteString(a_Player.GetClientHandle()->GetUUID());
|
||||
Pkt.WriteString(a_Player.GetName());
|
||||
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
reader.parse(m_Client->GetProperties(), root);
|
||||
|
||||
Pkt.WriteVarInt(root.size());
|
||||
for (Json::Value::iterator itr = root.begin(); itr != root.end(); ++itr)
|
||||
Pkt.WriteVarInt(m_Client->GetProperties().size());
|
||||
for (Json::Value::iterator itr = m_Client->GetProperties().begin(); itr != m_Client->GetProperties().end(); ++itr)
|
||||
{
|
||||
Pkt.WriteString(((Json::Value)*itr).get("name", "").toStyledString());
|
||||
Pkt.WriteString(((Json::Value)*itr).get("value", "").toStyledString());
|
||||
|
||||
Reference in New Issue
Block a user