summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorFranz Reiter <franzi.moos@googlemail.com>2014-09-23 15:54:07 +0200
committerFranz Reiter <franzi.moos@googlemail.com>2014-09-23 15:54:07 +0200
commit33f8091d5f550a91b1fbe24f07a397aa5a336093 (patch)
tree4fe1be83dd4212e010fed749cd444c4deecc64e6 /src/Entities/Player.cpp
parentQtBiomeVisualiser: Fixed confusion about Globals.h. (diff)
parentFixed SQLiteCpp downgrade (diff)
downloadcuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.gz
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.bz2
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.lz
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.xz
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.tar.zst
cuberite-33f8091d5f550a91b1fbe24f07a397aa5a336093.zip
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r--src/Entities/Player.cpp47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 871311e86..1bdb752c5 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -81,7 +81,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) :
m_Team(NULL),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
m_bIsTeleporting(false),
- m_UUID((a_Client != NULL) ? a_Client->GetUUID() : "")
+ m_UUID((a_Client != NULL) ? a_Client->GetUUID() : ""),
+ m_CustomName("")
{
m_InventoryWindow = new cInventoryWindow(*this);
m_CurrentWindow = m_InventoryWindow;
@@ -809,6 +810,28 @@ void cPlayer::SetCanFly(bool a_CanFly)
+void cPlayer::SetCustomName(const AString & a_CustomName)
+{
+ if (m_CustomName == a_CustomName)
+ {
+ return;
+ }
+ AString OldCustomName = m_CustomName;
+
+ m_CustomName = a_CustomName;
+ if (m_CustomName.length() > 16)
+ {
+ m_CustomName = m_CustomName.substr(0, 16);
+ }
+
+ m_World->BroadcastPlayerListUpdateDisplayName(*this, m_CustomName);
+ m_World->BroadcastSpawnEntity(*this, m_ClientHandle);
+}
+
+
+
+
+
void cPlayer::SetFlying(bool a_IsFlying)
{
if (a_IsFlying == m_IsFlying)
@@ -1450,6 +1473,28 @@ AString cPlayer::GetColor(void) const
+AString cPlayer::GetPlayerListName(void) const
+{
+ const AString & Color = GetColor();
+
+ if (HasCustomName())
+ {
+ return m_CustomName;
+ }
+ else if ((GetName().length() <= 14) && !Color.empty())
+ {
+ return Printf("%s%s", Color.c_str(), GetName().c_str());
+ }
+ else
+ {
+ return GetName();
+ }
+}
+
+
+
+
+
void cPlayer::TossEquippedItem(char a_Amount)
{
cItems Drops;