diff options
author | Alexander Harkness <me@bearbin.net> | 2015-06-13 12:59:07 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2015-06-13 12:59:07 +0200 |
commit | ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537 (patch) | |
tree | ade44b9828d0146d673901fb2a7e40b026c1fd9e /src/Entities/Player.cpp | |
parent | NetherPortalScanner: Fixed type conversion warnings. (diff) | |
parent | Added documentation for HOOK_KILLED (diff) | |
download | cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar.gz cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar.bz2 cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar.lz cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar.xz cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.tar.zst cuberite-ce93cfc34c85ef34e7a7d52b65fccfe9dcaf7537.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Player.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 0ca560d75..97e2eca3a 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -920,11 +920,11 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) { Pickups.Add(cItem(E_ITEM_RED_APPLE)); } - m_Stats.AddValue(statItemsDropped, (StatValue)Pickups.Size()); m_World->SpawnItemPickups(Pickups, GetPosX(), GetPosY(), GetPosZ(), 10); SaveToDisk(); // Save it, yeah the world is a tough place ! + cPluginManager * PluginManager = cRoot::Get()->GetPluginManager(); if ((a_TDI.Attacker == nullptr) && m_World->ShouldBroadcastDeathMessages()) { @@ -950,7 +950,12 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) case dtExplosion: DamageText = "blew up"; break; default: DamageText = "died, somehow; we've no idea how though"; break; } - GetWorld()->BroadcastChatDeath(Printf("%s %s", GetName().c_str(), DamageText.c_str())); + AString DeathMessage = Printf("%s %s", GetName().c_str(), DamageText.c_str()); + PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); + if (DeathMessage != AString("")) + { + GetWorld()->BroadcastChatDeath(DeathMessage); + } } else if (a_TDI.Attacker == nullptr) // && !m_World->ShouldBroadcastDeathMessages() by fallthrough { @@ -959,15 +964,23 @@ void cPlayer::KilledBy(TakeDamageInfo & a_TDI) else if (a_TDI.Attacker->IsPlayer()) { cPlayer * Killer = (cPlayer *)a_TDI.Attacker; - - GetWorld()->BroadcastChatDeath(Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str())); + AString DeathMessage = Printf("%s was killed by %s", GetName().c_str(), Killer->GetName().c_str()); + PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); + if (DeathMessage != AString("")) + { + GetWorld()->BroadcastChatDeath(DeathMessage); + } } else { AString KillerClass = a_TDI.Attacker->GetClass(); KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") - - GetWorld()->BroadcastChatDeath(Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str())); + AString DeathMessage = Printf("%s was killed by a %s", GetName().c_str(), KillerClass.c_str()); + PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); + if (DeathMessage != AString("")) + { + GetWorld()->BroadcastChatDeath(DeathMessage); + } } m_Stats.AddValue(statDeaths); |