diff options
author | TheHyper45 <dawid.priv@o2.pl> | 2021-06-20 11:20:42 +0200 |
---|---|---|
committer | Alexander Harkness <me@bearbin.net> | 2022-04-12 01:06:40 +0200 |
commit | 3cb1450ff1c40f97a11181a74bfff2134690af32 (patch) | |
tree | 86e93ea9e433d19d948a01fec3e9a53879df9b03 /src | |
parent | Add Prettify method to get player-friendly names of mobs (diff) | |
download | cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar.gz cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar.bz2 cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar.lz cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar.xz cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.tar.zst cuberite-3cb1450ff1c40f97a11181a74bfff2134690af32.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Entities/Entity.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index c4f61ad1e..858f9e0de 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -2420,11 +2420,22 @@ void cEntity::BroadcastDeathMessage(TakeDamageInfo & a_TDI) GetWorld()->BroadcastChatDeath(DeathMessage); } } - else + // This will trigger if a player/tamed pet has been killed by another mob/tamed pet. + else if (a_TDI.Attacker->IsMob()) { - AString KillerClass = a_TDI.Attacker->GetClass(); - KillerClass.erase(KillerClass.begin()); // Erase the 'c' of the class (e.g. "cWitch" -> "Witch") - AString DeathMessage = Printf("%s was killed by a %s", Name.c_str(), KillerClass.c_str()); + cMonster * Monster = static_cast<cMonster *>(a_TDI.Attacker); + + AString DeathMessage; + if (Monster->HasCustomName()) + { + DeathMessage = Printf("%s was killed by %s", Name.c_str(), Monster->GetCustomName().c_str()); + } + else + { + AString KillerName = AString(NamespaceSerializer::Prettify(Monster->GetMobType(), Monster->IsTame())); + DeathMessage = Printf("%s was killed by a %s", Name.c_str(), KillerName.c_str()); + } + PluginManager->CallHookKilled(*this, a_TDI, DeathMessage); if (DeathMessage != AString("")) { |