reflect: format includes
This commit is contained in:
+16
-27
@@ -1,43 +1,30 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "ll/api/memory/Hook.h"
|
|
||||||
#include "ll/api/chrono/GameChrono.h"
|
#include "ll/api/chrono/GameChrono.h"
|
||||||
#include "mc/world/actor/Mob.h"
|
#include "ll/api/memory/Hook.h"
|
||||||
|
#include "ll/api/service/Bedrock.h"
|
||||||
|
|
||||||
#include "mc/world/actor/ActorDamageSource.h"
|
#include "mc/world/actor/ActorDamageSource.h"
|
||||||
#include "mc/world/actor/ActorDamageByActorSource.h"
|
#include "mc/world/actor/ActorDamageByActorSource.h"
|
||||||
|
#include "mc/world/actor/Actor.h"
|
||||||
#include "ll/api/service/Bedrock.h"
|
#include "mc/world/actor/Mob.h"
|
||||||
#include "mc/world/level/Level.h"
|
#include "mc/world/level/Level.h"
|
||||||
|
|
||||||
|
//===============GMLIB 0.13.5 ActorDamageCause.cc===============
|
||||||
|
|
||||||
#include "mc/world/actor/Actor.h"
|
|
||||||
phmap::flat_hash_map<int64, float> mFallHeightMap;
|
phmap::flat_hash_map<int64, float> mFallHeightMap;
|
||||||
phmap::flat_hash_map<int64, ActorUniqueID> mHurtByEntityMap;
|
phmap::flat_hash_map<int64, ActorUniqueID> mHurtByEntityMap;
|
||||||
std::vector<std::pair<std::string, int>> mCustomCauseMap;
|
|
||||||
phmap::flat_hash_map<int, std::string_view> mVanillaCauseMessage;
|
phmap::flat_hash_map<int, std::string_view> mVanillaCauseMessage;
|
||||||
|
|
||||||
phmap::flat_hash_map<SharedTypes::Legacy::ActorDamageCause, phmap::flat_hash_map<std::string_view, std::string_view>> mHardCodedDeathMessage;
|
phmap::flat_hash_map<SharedTypes::Legacy::ActorDamageCause, phmap::flat_hash_map<std::string_view, std::string_view>> mHardCodedDeathMessage;
|
||||||
bool isCrystal = false;
|
bool isCrystal = false;
|
||||||
|
|
||||||
std::string getCause(SharedTypes::Legacy::ActorDamageCause cause) {
|
std::string getCause(SharedTypes::Legacy::ActorDamageCause cause) {
|
||||||
auto id = (int)cause;
|
auto id = (int)cause;
|
||||||
for (auto& key : mCustomCauseMap) {
|
if (mVanillaCauseMessage.count(id))
|
||||||
if (key.second == id) {
|
|
||||||
for (auto& key1 : mCustomCauseMap) {
|
|
||||||
if ((SharedTypes::Legacy::ActorDamageCause)key1.second == cause) {
|
|
||||||
return key1.first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mVanillaCauseMessage.count(id)) {
|
|
||||||
return std::string(mVanillaCauseMessage[id]);
|
return std::string(mVanillaCauseMessage[id]);
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Actor* getDamagingEntity(ActorDamageSource* ads) {
|
Actor* getDamagingEntity(ActorDamageSource* ads) {
|
||||||
auto id = ads->getDamagingEntityUniqueID();
|
auto id = ads->getDamagingEntityUniqueID();
|
||||||
return ll::service::getLevel()->fetchEntity(id,true);
|
return ll::service::getLevel()->fetchEntity(id,true);
|
||||||
@@ -45,9 +32,8 @@ Actor* getDamagingEntity(ActorDamageSource* ads) {
|
|||||||
|
|
||||||
// %entity.warden.name
|
// %entity.warden.name
|
||||||
std::string getResourcePackKey(std::string const& name, Actor* ac) {
|
std::string getResourcePackKey(std::string const& name, Actor* ac) {
|
||||||
if (ac->hasCategory(ActorCategory::Player)) {
|
if (ac->hasCategory(ActorCategory::Player))
|
||||||
return name;
|
return name;
|
||||||
}
|
|
||||||
auto type = ac->getTypeName();
|
auto type = ac->getTypeName();
|
||||||
ll::utils::string_utils::replaceAll(type, "minecraft:", "");
|
ll::utils::string_utils::replaceAll(type, "minecraft:", "");
|
||||||
std::string res = "%entity." + type + ".name";
|
std::string res = "%entity." + type + ".name";
|
||||||
@@ -68,16 +54,16 @@ DeathMessageResult makeDeathMessage(
|
|||||||
if (cause >= 35||mVanillaCauseMessage.count(cause) || isHardCodedMessage) {
|
if (cause >= 35||mVanillaCauseMessage.count(cause) || isHardCodedMessage) {
|
||||||
std::string msg = "death.attack.damageCause.item";
|
std::string msg = "death.attack.damageCause.item";
|
||||||
ll::utils::string_utils::replaceAll(msg, "damageCause", getCause(SharedTypes::Legacy::ActorDamageCause(cause)));
|
ll::utils::string_utils::replaceAll(msg, "damageCause", getCause(SharedTypes::Legacy::ActorDamageCause(cause)));
|
||||||
if (isHardCodedMessage) {
|
if (isHardCodedMessage)
|
||||||
msg = deathMessage.first;
|
msg = deathMessage.first;
|
||||||
}
|
|
||||||
// 没有武器名不使用.item结尾
|
// 没有武器名不使用.item结尾
|
||||||
if (weaponName.empty()) {
|
if (weaponName.empty()) {
|
||||||
// 试图逃离 xx 使用.player
|
// 试图逃离 xx 使用.player
|
||||||
if (killer) {
|
if (killer) {
|
||||||
if (isEscaping) {
|
if (isEscaping)
|
||||||
ll::utils::string_utils::replaceAll(msg, ".item", ".player");
|
ll::utils::string_utils::replaceAll(msg, ".item", ".player");
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ll::utils::string_utils::replaceAll(msg, ".item", "");
|
ll::utils::string_utils::replaceAll(msg, ".item", "");
|
||||||
}
|
}
|
||||||
@@ -268,6 +254,9 @@ bool registerCustomDeathMessage(
|
|||||||
mHardCodedDeathMessage[cause][killerType] = message;
|
mHardCodedDeathMessage[cause][killerType] = message;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//===============Copy finish===============
|
||||||
|
|
||||||
|
|
||||||
void RegisterDamageDefinition() {
|
void RegisterDamageDefinition() {
|
||||||
setVanillaCauseMessage(SharedTypes::Legacy::ActorDamageCause::Anvil, "anvil");
|
setVanillaCauseMessage(SharedTypes::Legacy::ActorDamageCause::Anvil, "anvil");
|
||||||
setVanillaCauseMessage(SharedTypes::Legacy::ActorDamageCause::EntityAttack, "mob");
|
setVanillaCauseMessage(SharedTypes::Legacy::ActorDamageCause::EntityAttack, "mob");
|
||||||
|
|||||||
+13
-5
@@ -1,24 +1,29 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "ll/api/mod/Mod.h"
|
|
||||||
#include "ll/api/Config.h"
|
#include "ll/api/Config.h"
|
||||||
|
#include "ll/api/data/IndirectValue.h"
|
||||||
#include "ll/api/io/PatternFormatter.h"
|
#include "ll/api/io/PatternFormatter.h"
|
||||||
#include "ll/api/io/Logger.h"
|
#include "ll/api/io/Logger.h"
|
||||||
#include "ll/api/io/LoggerRegistry.h"
|
#include "ll/api/io/LoggerRegistry.h"
|
||||||
#include "ll/api/io/FileSink.h"
|
#include "ll/api/io/FileSink.h"
|
||||||
|
#include "ll/api/mod/Mod.h"
|
||||||
|
#include "ll/api/mod/ModManagerRegistry.h"
|
||||||
#include "ll/api/mod/RegisterHelper.h"
|
#include "ll/api/mod/RegisterHelper.h"
|
||||||
#include "ll/api/data/IndirectValue.h"
|
#include "ll/api/service/Bedrock.h"
|
||||||
|
|
||||||
#include "gmlib/gm/i18n/LangI18n.h"
|
#include "gmlib/gm/i18n/LangI18n.h"
|
||||||
#include "gmlib/gm/i18n/ResourceI18n.h"
|
#include "gmlib/gm/i18n/ResourceI18n.h"
|
||||||
#include "ll/api/mod/ModManagerRegistry.h"
|
|
||||||
#include <ll/api/service/Bedrock.h>
|
|
||||||
|
|
||||||
ll::io::LoggerRegistry& loggerRegistry = ll::io::LoggerRegistry::getInstance();
|
ll::io::LoggerRegistry& loggerRegistry = ll::io::LoggerRegistry::getInstance();
|
||||||
std::shared_ptr<ll::io::Logger> logger = loggerRegistry.getOrCreate(MOD_NAME);
|
std::shared_ptr<ll::io::Logger> logger = loggerRegistry.getOrCreate(MOD_NAME);
|
||||||
std::shared_ptr<ll::io::Logger> deathLogger = loggerRegistry.getOrCreate("Death");
|
std::shared_ptr<ll::io::Logger> deathLogger = loggerRegistry.getOrCreate("Death");
|
||||||
std::shared_ptr<ll::io::Logger> infoLogger = loggerRegistry.getOrCreate("Server");
|
std::shared_ptr<ll::io::Logger> infoLogger = loggerRegistry.getOrCreate("Server");
|
||||||
|
extern void uninstallHooks();
|
||||||
|
extern void RegisterDamageDefinition();
|
||||||
|
extern void uninstallEventListeners();
|
||||||
|
extern void ListenEvents();
|
||||||
|
|
||||||
namespace DeathMessages {
|
namespace DeathMessages {
|
||||||
|
|
||||||
@@ -63,6 +68,9 @@ bool Entry::unload() {
|
|||||||
mConfig.reset();
|
mConfig.reset();
|
||||||
mI18n.reset();
|
mI18n.reset();
|
||||||
uninstallHooks();
|
uninstallHooks();
|
||||||
|
loggerRegistry.erase(MOD_NAME);
|
||||||
|
loggerRegistry.erase("Death");
|
||||||
|
loggerRegistry.erase("Server");
|
||||||
// getInstance().reset();
|
// getInstance().reset();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "ll/api/mod/Mod.h"
|
|
||||||
|
|
||||||
|
#include "ll/api/mod/Mod.h"
|
||||||
#include <ll/api/mod/NativeMod.h>
|
#include <ll/api/mod/NativeMod.h>
|
||||||
|
|
||||||
#include <gmlib/gm/i18n/LangI18n.h>
|
#include <gmlib/gm/i18n/LangI18n.h>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <mc/legacy/ActorUniqueID.h>
|
#include <mc/legacy/ActorUniqueID.h>
|
||||||
#include <mc/world/actor/ActorDamageSource.h>
|
#include <mc/world/actor/ActorDamageSource.h>
|
||||||
#include <parallel_hashmap/phmap.h>
|
#include <parallel_hashmap/phmap.h>
|
||||||
#include "ll/api/i18n/I18n.h"
|
|
||||||
|
|
||||||
#define MOD_NAME "DeathMessages"
|
#define MOD_NAME "DeathMessages"
|
||||||
|
|
||||||
@@ -16,11 +15,6 @@ extern phmap::flat_hash_map<int64, ActorUniqueID> mHurtByEntityMap;
|
|||||||
extern bool isCrystal;
|
extern bool isCrystal;
|
||||||
|
|
||||||
using DeathMessageResult = std::pair<std::string, std::vector<std::string>>;
|
using DeathMessageResult = std::pair<std::string, std::vector<std::string>>;
|
||||||
using namespace ll::i18n_literals;
|
|
||||||
|
|
||||||
extern DeathMessageResult translateDeathMessage(DeathMessageResult origin, std::string name, Actor* dead, ActorDamageSource* ads);
|
extern DeathMessageResult translateDeathMessage(DeathMessageResult origin, std::string name, Actor* dead, ActorDamageSource* ads);
|
||||||
extern void uninstallHooks();
|
|
||||||
extern void RegisterDamageDefinition();
|
|
||||||
|
|
||||||
extern std::string tr(std::string const& key, std::vector<std::string> const& params = {});
|
extern std::string tr(std::string const& key, std::vector<std::string> const& params = {});
|
||||||
extern void ListenEvents();
|
|
||||||
+7
-18
@@ -1,19 +1,22 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
|
#include "Hooks.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
#include "ll/api/memory/Hook.h"
|
#include "ll/api/memory/Hook.h"
|
||||||
#include "ll/api/chrono/GameChrono.h"
|
#include "ll/api/chrono/GameChrono.h"
|
||||||
#include "ll/api/thread/ThreadPoolExecutor.h"
|
#include "ll/api/thread/ThreadPoolExecutor.h"
|
||||||
#include <chrono>
|
|
||||||
#include "mc/world/actor/Mob.h"
|
#include "mc/world/actor/Mob.h"
|
||||||
|
#include "mc/world/actor/monster/EnderCrystal.h"
|
||||||
#include "mc/world/actor/ActorDamageSource.h"
|
#include "mc/world/actor/ActorDamageSource.h"
|
||||||
#include "mc/world/actor/ActorDamageByActorSource.h"
|
#include "mc/world/actor/ActorDamageByActorSource.h"
|
||||||
#include "mc/world/actor/ActorDamageByBlockSource.h"
|
#include "mc/world/actor/ActorDamageByBlockSource.h"
|
||||||
#include "mc/world/actor/ActorDamageByChildActorSource.h"
|
#include "mc/world/actor/ActorDamageByChildActorSource.h"
|
||||||
#include "mc/world/actor/monster/EnderCrystal.h"
|
|
||||||
#include "mc/world/actor/ActorHurtResult.h"
|
#include "mc/world/actor/ActorHurtResult.h"
|
||||||
#include "Global.h"
|
|
||||||
#include "mc/world/actor/Actor.h"
|
#include "mc/world/actor/Actor.h"
|
||||||
|
|
||||||
#include "Hooks.h"
|
#include <chrono>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -29,17 +32,11 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
|
|||||||
|
|
||||||
if (ads.mCause == SharedTypes::Legacy::ActorDamageCause::Fall) {
|
if (ads.mCause == SharedTypes::Legacy::ActorDamageCause::Fall) {
|
||||||
mFallHeightMap[uid.rawID] = getFallDistance();
|
mFallHeightMap[uid.rawID] = getFallDistance();
|
||||||
logger->info("跌落高度为 {}", getFallDistance());
|
|
||||||
}
|
}
|
||||||
if (hasCategory(ActorCategory::Player) || isTame()) {
|
if (hasCategory(ActorCategory::Player) || isTame()) {
|
||||||
if (mLastHurtByMobTime != 0) {
|
if (mLastHurtByMobTime != 0) {
|
||||||
auto hm = getLastHurtByMob();
|
auto hm = getLastHurtByMob();
|
||||||
mHurtByEntityMap[uid.rawID] = hm->getOrCreateUniqueID();
|
mHurtByEntityMap[uid.rawID] = hm->getOrCreateUniqueID();
|
||||||
if (!getLastHurtByMob()->getNameTag().empty()) logger->info("伤害来源为 {}", getLastHurtByMob()->getNameTag());
|
|
||||||
logger->info("伤害来源为 {}", getLastHurtByMob()->getTypeName());
|
|
||||||
|
|
||||||
|
|
||||||
if (!getLastHurtByMob()->getCarriedItem().getCustomName().empty()) logger->info("伤害来源为 {}", getLastHurtByMob()->getCarriedItem().getCustomName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
origin(ads);
|
origin(ads);
|
||||||
@@ -94,8 +91,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
|
|||||||
|
|
||||||
|
|
||||||
auto originl = origin(a1, a2);
|
auto originl = origin(a1, a2);
|
||||||
logger->info("原消息name为 {}", a1);
|
|
||||||
logger->info("原消息为 {}", originl.first);
|
|
||||||
auto res = translateDeathMessage(originl, a1, a2, this);
|
auto res = translateDeathMessage(originl, a1, a2, this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -110,8 +105,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
|
|||||||
Actor* a2
|
Actor* a2
|
||||||
) {
|
) {
|
||||||
auto originl = origin(a1, a2);
|
auto originl = origin(a1, a2);
|
||||||
logger->info("原消息name为 {}", a1);
|
|
||||||
logger->info("原消息为 {}", originl.first);
|
|
||||||
auto res = translateDeathMessage(originl, a1, a2, this);
|
auto res = translateDeathMessage(originl, a1, a2, this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -127,8 +120,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
|
|||||||
Actor* a2
|
Actor* a2
|
||||||
) {
|
) {
|
||||||
auto originl = origin(a1, a2);
|
auto originl = origin(a1, a2);
|
||||||
logger->info("原消息name为 {}", a1);
|
|
||||||
logger->info("原消息为 {}", originl.first);
|
|
||||||
auto res = translateDeathMessage(originl, a1, a2, this);
|
auto res = translateDeathMessage(originl, a1, a2, this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -145,8 +136,6 @@ LL_AUTO_TYPE_INSTANCE_HOOK(
|
|||||||
Actor* a2
|
Actor* a2
|
||||||
) {
|
) {
|
||||||
auto originl = origin(a1, a2);
|
auto originl = origin(a1, a2);
|
||||||
logger->info("原消息name为 {}", a1);
|
|
||||||
logger->info("原消息为 {}", originl.first);
|
|
||||||
auto res = translateDeathMessage(originl, a1, a2, this);
|
auto res = translateDeathMessage(originl, a1, a2, this);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -250,7 +250,7 @@ entity.breeze.name=Breeze
|
|||||||
entity.creaking.name=Creaking
|
entity.creaking.name=Creaking
|
||||||
multiplayer.player.joined=%s joined the game
|
multiplayer.player.joined=%s joined the game
|
||||||
multiplayer.player.left=%s left the game
|
multiplayer.player.left=%s left the game
|
||||||
plugin.deathmessages.modapi.warn=The plugin ModAPI is not loaded, so client-side translation is unavailable. Only server-side translation can be used.
|
plugin.deathmessages.modapi.warn=The optional Dependency plugin ModAPI is not loaded, so client-side translation is unavailable. Only server-side translation can be used.
|
||||||
)";
|
)";
|
||||||
|
|
||||||
std::string zh_CN = R"(
|
std::string zh_CN = R"(
|
||||||
@@ -504,5 +504,5 @@ entity.breeze.name=旋风人
|
|||||||
entity.creaking.name=嘎枝
|
entity.creaking.name=嘎枝
|
||||||
multiplayer.player.joined=%s 加入了游戏
|
multiplayer.player.joined=%s 加入了游戏
|
||||||
multiplayer.player.left=%s 退出了游戏
|
multiplayer.player.left=%s 退出了游戏
|
||||||
plugin.deathmessages.modapi.warn=插件ModAPI没有被加载,所以客户端侧翻译无法使用,正在启用服务端侧翻译
|
plugin.deathmessages.modapi.warn=可选依赖ModAPI没有被加载,所以客户端侧翻译无法使用,正在启用服务端侧翻译
|
||||||
)";
|
)";
|
||||||
+16
-6
@@ -1,17 +1,20 @@
|
|||||||
|
|
||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
#include "ll/api/event/player/PlayerConnectEvent.h"
|
#include "ll/api/event/player/PlayerConnectEvent.h"
|
||||||
#include "ll/api/event/EventBus.h"
|
|
||||||
#include "ll/api/event/player/PlayerDieEvent.h"
|
#include "ll/api/event/player/PlayerDieEvent.h"
|
||||||
|
|
||||||
#include "ll/api/event/player/PlayerDisconnectEvent.h"
|
#include "ll/api/event/player/PlayerDisconnectEvent.h"
|
||||||
|
|
||||||
|
#include "ll/api/event/EventBus.h"
|
||||||
|
|
||||||
|
ll::event::ListenerPtr playerConnectEventListener;
|
||||||
|
ll::event::ListenerPtr playerDieEventListener;
|
||||||
|
ll::event::ListenerPtr playerDisconnectEventListener;
|
||||||
void ListenEvents() {
|
void ListenEvents() {
|
||||||
auto& config = DeathMessages::Entry::getInstance().getConfig();
|
auto& config = DeathMessages::Entry::getInstance().getConfig();
|
||||||
auto& eventBus = ll::event::EventBus::getInstance();
|
auto& eventBus = ll::event::EventBus::getInstance();
|
||||||
if (config.ConsoleLog.JoinMessage) {
|
if (config.ConsoleLog.JoinMessage) {
|
||||||
eventBus.emplaceListener<ll::event::player::PlayerConnectEvent>([](ll::event::player::PlayerConnectEvent& ev) {
|
playerConnectEventListener=eventBus.emplaceListener<ll::event::player::PlayerConnectEvent>([](ll::event::player::PlayerConnectEvent& ev) {
|
||||||
infoLogger->info(
|
infoLogger->info(
|
||||||
fmt::format(fg(fmt::color::yellow), fmt::runtime(tr("multiplayer.player.joined", {ev.self().getRealName()})))
|
fmt::format(fg(fmt::color::yellow), fmt::runtime(tr("multiplayer.player.joined", {ev.self().getRealName()})))
|
||||||
);
|
);
|
||||||
@@ -19,7 +22,7 @@ void ListenEvents() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (config.ConsoleLog.LeftMessage) {
|
if (config.ConsoleLog.LeftMessage) {
|
||||||
eventBus.emplaceListener<ll::event::player::PlayerDisconnectEvent>(
|
playerDisconnectEventListener=eventBus.emplaceListener<ll::event::player::PlayerDisconnectEvent>(
|
||||||
[](ll::event::player::PlayerDisconnectEvent& ev) {
|
[](ll::event::player::PlayerDisconnectEvent& ev) {
|
||||||
infoLogger->info(
|
infoLogger->info(
|
||||||
fmt::format(fg(fmt::color::yellow), fmt::runtime(tr("multiplayer.player.left", {ev.self().getRealName()})))
|
fmt::format(fg(fmt::color::yellow), fmt::runtime(tr("multiplayer.player.left", {ev.self().getRealName()})))
|
||||||
@@ -28,7 +31,7 @@ void ListenEvents() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (config.ConsoleLog.DeathMessage) {
|
if (config.ConsoleLog.DeathMessage) {
|
||||||
eventBus.emplaceListener<ll::event::player::PlayerDieEvent>(
|
playerDieEventListener=eventBus.emplaceListener<ll::event::player::PlayerDieEvent>(
|
||||||
[](ll::event::player::PlayerDieEvent& ev) {
|
[](ll::event::player::PlayerDieEvent& ev) {
|
||||||
auto [key, params] = ev.source().getDeathMessage(ev.self().getRealName(), &ev.self());
|
auto [key, params] = ev.source().getDeathMessage(ev.self().getRealName(), &ev.self());
|
||||||
auto info = tr(key, params);
|
auto info = tr(key, params);
|
||||||
@@ -36,4 +39,11 @@ void ListenEvents() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uninstallEventListeners() {
|
||||||
|
auto& eventBus = ll::event::EventBus::getInstance();
|
||||||
|
eventBus.removeListener(playerDieEventListener);
|
||||||
|
eventBus.removeListener(playerConnectEventListener);
|
||||||
|
eventBus.removeListener(playerDisconnectEventListener);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user