adapt: adapt to GMLIB v0.13.10
This commit is contained in:
+17
-13
@@ -2,14 +2,16 @@
|
||||
#include "Global.h"
|
||||
#include "Language.h"
|
||||
|
||||
ll::Logger logger(MOD_NAME);
|
||||
ll::Logger deathLogger("Death");
|
||||
ll::Logger infoLogger("Server");
|
||||
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> deathLogger = loggerRegistry.getOrCreate("Death");
|
||||
std::shared_ptr<ll::io::Logger> infoLogger = loggerRegistry.getOrCreate("Server");
|
||||
|
||||
|
||||
namespace DeathMessages {
|
||||
|
||||
std::unique_ptr<Entry>& Entry::getInstance() {
|
||||
static std::unique_ptr<Entry> instance;
|
||||
Entry& Entry::getInstance() {
|
||||
static Entry instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -24,8 +26,10 @@ bool Entry::load() {
|
||||
loadResourcePack();
|
||||
}
|
||||
if (getConfig().FileLog.Enabled) {
|
||||
auto& path = getConfig().FileLog.Path;
|
||||
deathLogger.setFile(path);
|
||||
auto& path = getConfig().FileLog.Path;
|
||||
ll::Polymorphic<ll::io::PatternFormatter> polymorphicFormatter =
|
||||
ll::makePolymorphic<ll::io::PatternFormatter>("[{3:.3%F %T.} {2}][{1}] {0}", false);
|
||||
deathLogger->addSink(std::make_shared<ll::io::FileSink>(path, polymorphicFormatter));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -41,13 +45,13 @@ bool Entry::disable() { return true; }
|
||||
bool Entry::unload() {
|
||||
mConfig.reset();
|
||||
mI18n.reset();
|
||||
getInstance().reset();
|
||||
// getInstance().reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
Config& Entry::getConfig() { return mConfig.value(); }
|
||||
|
||||
std::optional<gmlib::i18n::LangI18n> Entry::getI18n() { return mI18n; }
|
||||
std::optional<GMLIB::Files::I18n::LangI18n> Entry::getI18n() { return mI18n; }
|
||||
|
||||
void Entry::loadI18n() {
|
||||
mI18n.emplace(getSelf().getLangDir(), getConfig().ServerSideTranslation.Language);
|
||||
@@ -58,8 +62,8 @@ void Entry::loadI18n() {
|
||||
}
|
||||
|
||||
void Entry::loadResourcePack() {
|
||||
gmlib::tools::VanillaFix::setFixI18nEnabled();
|
||||
auto resource = gmlib::i18n::ResourceI18n(getSelf().getModDir() / u8"resource", MOD_NAME, 0, 8, 0);
|
||||
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
auto resource = GMLIB::Files::ResourceLanguage(getSelf().getModDir() / u8"resource", MOD_NAME, 0, 8, 0);
|
||||
resource.addLanguage("en_US", en_US);
|
||||
resource.addLanguage("zh_CN", zh_CN);
|
||||
}
|
||||
@@ -69,8 +73,8 @@ void Entry::loadResourcePack() {
|
||||
LL_REGISTER_MOD(DeathMessages::Entry, DeathMessages::Entry::getInstance());
|
||||
|
||||
std::string tr(std::string const& key, std::vector<std::string> const& params) {
|
||||
if (auto i18n = DeathMessages::Entry::getInstance()->getI18n()) {
|
||||
if (auto i18n = DeathMessages::Entry::getInstance().getI18n()) {
|
||||
return i18n->get(key, params);
|
||||
}
|
||||
return gmlib::world::I18nAPI::get(key, params);
|
||||
return ::I18nAPI::get(key, params);
|
||||
}
|
||||
Reference in New Issue
Block a user