Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
format all
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Apr 16, 2024
1 parent 05742e4 commit 97dbf2c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
47 changes: 47 additions & 0 deletions src/File/Config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "Config.h"
#include "entry/Entry.h"

#include <filesystem>
#include <ll/api/Config.h>
#include <ll/api/i18n/I18n.h>

namespace tls::config {

S_Config cfg; // init Config

#define CONFIG_FILE_NAME "Config.json"
using ll::i18n_literals::operator""_tr;


bool loadConfig() {
auto& mSelf = entry::entry::getInstance().getSelf();
auto filePath = mSelf.getConfigDir() / CONFIG_FILE_NAME;
auto& logger = mSelf.getLogger();
// init file
std::filesystem::path p = filePath;
if (!std::filesystem::exists(p)) {
logger.info("Saving default configurations");
writeConfig(cfg);
}
// loading
if (!ll::config::loadConfig(cfg, filePath)) {
logger.warn("Unable to load configuration from {}"_tr(filePath));
return false;
}
return true;
}

bool writeConfig(S_Config newCfg) {
auto& mSelf = entry::entry::getInstance().getSelf();
auto configFilePath = mSelf.getConfigDir() / CONFIG_FILE_NAME;
auto& logger = mSelf.getLogger();

if (!ll::config::saveConfig(newCfg, configFilePath)) {
logger.error("Cannot save configurations to {}"_tr(configFilePath));
return false;
}
return true;
}
bool writeConfig() { return writeConfig(cfg); }

} // namespace tls::config
File renamed without changes.
5 changes: 3 additions & 2 deletions src/Form/Mapping.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "mc/world/actor/player/Player.h"
#include <functional>
#include <string>
#include <unordered_map>
#include "mc/world/actor/player/Player.h"


namespace tls::form {

extern std::unordered_map<std::string, std::function<void(Player&)>> mapping;
bool initMapping();

}
} // namespace tls::form
3 changes: 2 additions & 1 deletion src/Form/index.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "Form/index.h"
#include "Api/Api.h"
#include "Entry/Entry.h"
#include "Entry/PluginInfo.h"
#include "File/file.h"
#include "Form/index.h"
#include "Form/Mapping.h"


#include <functional>
#include <ll/api/form/CustomForm.h>
#include <ll/api/form/ModalForm.h>
Expand Down
2 changes: 1 addition & 1 deletion src/Permission/Permission.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ enum Permission {

void initPermission();

} // namespace tls::perm
} // namespace tls::perms

0 comments on commit 97dbf2c

Please sign in to comment.