summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorSimon Pribylski <66266021+Persson-dev@users.noreply.github.com>2022-01-24 21:24:55 +0100
committerGitHub <noreply@github.com>2022-01-24 21:24:55 +0100
commitf4c04299961a96e153bf50e2e1fb92c8f9db77f5 (patch)
treedf60ba3390281971920c1a1a2baf3a2f91ab55e9 /src/Entities/Player.cpp
parentAdd aarch64 to easyinstall. Fixes #5386 (diff)
downloadcuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar.gz
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar.bz2
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar.lz
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar.xz
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.tar.zst
cuberite-f4c04299961a96e153bf50e2e1fb92c8f9db77f5.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp81
1 files changed, 47 insertions, 34 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index de4acc806..30650a6d0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1567,7 +1567,7 @@ void cPlayer::PermuteEnchantmentSeed()
-bool cPlayer::HasPermission(const AString & a_Permission)
+bool cPlayer::HasPermission(const AString & a_Permission) const
{
if (a_Permission.empty())
{
@@ -1786,7 +1786,7 @@ void cPlayer::TossPickup(const cItem & a_Item)
void cPlayer::LoadFromDisk()
{
- LoadRank();
+ RefreshRank();
Json::Value Root;
const auto & UUID = GetUUID();
@@ -2295,39 +2295,11 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos, bool a_PreviousIs
void cPlayer::LoadRank(void)
{
- const auto & UUID = GetUUID();
- cRankManager * RankMgr = cRoot::Get()->GetRankManager();
-
- // Load the values from cRankManager:
- m_Rank = RankMgr->GetPlayerRankName(UUID);
- if (m_Rank.empty())
- {
- m_Rank = RankMgr->GetDefaultRank();
- }
- else
- {
- // Update the name:
- RankMgr->UpdatePlayerName(UUID, GetName());
- }
- m_Permissions = RankMgr->GetPlayerPermissions(UUID);
- m_Restrictions = RankMgr->GetPlayerRestrictions(UUID);
- RankMgr->GetRankVisuals(m_Rank, m_MsgPrefix, m_MsgSuffix, m_MsgNameColorCode);
+ // Update our permissions:
+ RefreshRank();
- // Break up the individual permissions on each dot, into m_SplitPermissions:
- m_SplitPermissions.clear();
- m_SplitPermissions.reserve(m_Permissions.size());
- for (auto & Permission: m_Permissions)
- {
- m_SplitPermissions.push_back(StringSplit(Permission, "."));
- } // for Permission - m_Permissions[]
-
- // Break up the individual restrictions on each dot, into m_SplitRestrictions:
- m_SplitRestrictions.clear();
- m_SplitRestrictions.reserve(m_Restrictions.size());
- for (auto & Restriction: m_Restrictions)
- {
- m_SplitRestrictions.push_back(StringSplit(Restriction, "."));
- } // for itr - m_Restrictions[]
+ // Send a permission level update:
+ m_ClientHandle->SendPlayerPermissionLevel();
}
@@ -2808,6 +2780,47 @@ void cPlayer::TickFreezeCode()
+void cPlayer::RefreshRank()
+{
+ const auto & UUID = GetUUID();
+ cRankManager * RankMgr = cRoot::Get()->GetRankManager();
+
+ // Load the values from cRankManager:
+ m_Rank = RankMgr->GetPlayerRankName(UUID);
+ if (m_Rank.empty())
+ {
+ m_Rank = RankMgr->GetDefaultRank();
+ }
+ else
+ {
+ // Update the name:
+ RankMgr->UpdatePlayerName(UUID, GetName());
+ }
+ m_Permissions = RankMgr->GetPlayerPermissions(UUID);
+ m_Restrictions = RankMgr->GetPlayerRestrictions(UUID);
+ RankMgr->GetRankVisuals(m_Rank, m_MsgPrefix, m_MsgSuffix, m_MsgNameColorCode);
+
+ // Break up the individual permissions on each dot, into m_SplitPermissions:
+ m_SplitPermissions.clear();
+ m_SplitPermissions.reserve(m_Permissions.size());
+ for (auto & Permission : m_Permissions)
+ {
+ m_SplitPermissions.push_back(StringSplit(Permission, "."));
+ }
+
+ // Break up the individual restrictions on each dot, into m_SplitRestrictions:
+ m_SplitRestrictions.clear();
+ m_SplitRestrictions.reserve(m_Restrictions.size());
+ for (auto & Restriction : m_Restrictions)
+ {
+ m_SplitRestrictions.push_back(StringSplit(Restriction, "."));
+ }
+}
+
+
+
+
+
void cPlayer::ApplyArmorDamage(int a_DamageBlocked)
{
short ArmorDamage = static_cast<short>(std::max(a_DamageBlocked / 4, 1));