summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-02 19:12:35 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-02 19:12:35 +0200
commit1bb4d7941267ee55cdf7f35fa6a0055521115960 (patch)
tree38b2faa2d824bca6da9ec88c2c0c0d9bbe81f6df /src/Entities/Player.cpp
parentAdded name tag (diff)
downloadcuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar.gz
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar.bz2
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar.lz
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar.xz
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.tar.zst
cuberite-1bb4d7941267ee55cdf7f35fa6a0055521115960.zip
Diffstat (limited to '')
-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 756410989..a2934d036 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;
@@ -813,6 +814,28 @@ void cPlayer::SetCanFly(bool a_CanFly)
+void cPlayer::SetCustomName(const AString & a_CustomName)
+{
+ if (m_CustomName == a_CustomName)
+ {
+ return;
+ }
+ m_World->BroadcastPlayerListItem(GetTabListName(), false, 0); // Remove old tab-list entry
+
+ m_CustomName = a_CustomName;
+ if (m_CustomName.length() > 16)
+ {
+ m_CustomName = m_CustomName.substr(0, 16);
+ }
+
+ m_World->BroadcastSpawnEntity(*this, m_ClientHandle);
+ m_World->BroadcastPlayerListItem(GetTabListName(), true, GetClientHandle()->GetPing());
+}
+
+
+
+
+
void cPlayer::SetFlying(bool a_IsFlying)
{
if (a_IsFlying == m_IsFlying)
@@ -1443,6 +1466,28 @@ AString cPlayer::GetColor(void) const
+AString cPlayer::GetTabListName(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;