Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
Loading...
Searching...
No Matches
config.cpp File Reference

The file containing the config logic. More...

#include <fstream>
#include <sstream>
#include <string>
#include <filesystem>
#include <rapidjson/prettywriter.h>
#include <rapidjson/stringbuffer.h>
#include <cmd/commands.h>
#include <utils/logger.h>
#include "config.h"

Macros

#define UF(x)   x.load(document);
 
#define UF(x)
 
#define UF(x)   Config::inst()->x.load(doc);
 
#define UF(x)   x.registerLuaProperty(state);
 
#define UF(x)   x.save(document);
 

Functions

template<typename T >
bool printFieldValue (ISender &sender, const std::string &section, const std::string &key, Field< T > &field)
 Prints to console field value if matching key and section.
 
void handleConfigCommand (const ISender::SenderType senderType, ISender &sender, const std::vector< std::string > &args)
 Handles /config command.
 

Variables

constexpr const charCONFIG_FILE = "config.json"
 The config file path.
 

Detailed Description

The file containing the config logic.

Author
Lygaen
Version
0.1
Date
2023-12-16

Macro Definition Documentation

◆ UF

#define UF ( x)
Value:
if (!wasFound) \
wasFound = printFieldValue(sender, section, key, Config::inst()->x);
static Config * inst()
Fetch the instance of the config.
Definition config.h:275
bool printFieldValue(ISender &sender, const std::string &section, const std::string &key, Field< T > &field)
Prints to console field value if matching key and section.
Definition config.cpp:257
constexpr std::string_view type_name()
Gets the name of the type paramater.
Definition event.h:56

Function Documentation

◆ handleConfigCommand()

void handleConfigCommand ( const ISender::SenderType senderType,
ISender & sender,
const std::vector< std::string > & args )

Handles /config command.

Parameters
senderTypethe type of sender
senderthe sender in and on itself
argsthe arguments of the command

◆ printFieldValue()

template<typename T >
bool printFieldValue ( ISender & sender,
const std::string & section,
const std::string & key,
Field< T > & field )

Prints to console field value if matching key and section.

See Config for more information on config fields

Template Parameters
Tthe field type
Parameters
senderthe asking sender
sectionthe section of the value
keythe key of the value
fieldthe current field
Returns
true the field's value was printed
false the field's value was not printed