[Server] Move plugin enforcement functions to ServerFunctions

pull/491/head
David Cernat 6 years ago
parent 2933526995
commit d8ca268067

@ -48,16 +48,6 @@ void MiscellaneousFunctions::SetCurrentMpNum(int mpNum) noexcept
mwmp::Networking::getPtr()->setCurrentMpNum(mpNum); mwmp::Networking::getPtr()->setCurrentMpNum(mpNum);
} }
int MiscellaneousFunctions::GetPluginEnforcementState() noexcept
{
return mwmp::Networking::getPtr()->getPluginEnforcementState();
}
void MiscellaneousFunctions::SetPluginEnforcementState(bool state) noexcept
{
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
}
void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept void MiscellaneousFunctions::LogMessage(unsigned short level, const char *message) noexcept
{ {
LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message); LOG_MESSAGE_SIMPLE(level, "[Script]: %s", message);

@ -12,9 +12,6 @@
{"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\ {"GetCurrentMpNum", MiscellaneousFunctions::GetCurrentMpNum},\
{"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\ {"SetCurrentMpNum", MiscellaneousFunctions::SetCurrentMpNum},\
\ \
{"GetPluginEnforcementState", MiscellaneousFunctions::GetPluginEnforcementState},\
{"SetPluginEnforcementState", MiscellaneousFunctions::SetPluginEnforcementState},\
\
{"LogMessage", MiscellaneousFunctions::LogMessage},\ {"LogMessage", MiscellaneousFunctions::LogMessage},\
{"LogAppend", MiscellaneousFunctions::LogAppend} {"LogAppend", MiscellaneousFunctions::LogAppend}
@ -79,25 +76,6 @@ public:
*/ */
static void SetCurrentMpNum(int mpNum) noexcept; static void SetCurrentMpNum(int mpNum) noexcept;
/**
* \brief Get the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \return The enforcement state.
*/
static int GetPluginEnforcementState() noexcept;
/**
* \brief Set the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \param state The new enforcement state.
* \return void
*/
static void SetPluginEnforcementState(bool state) noexcept;
/** /**
* \brief Write a log message with its own timestamp. * \brief Write a log message with its own timestamp.
* *

@ -75,6 +75,11 @@ bool ServerFunctions::HasPassword() noexcept
return mwmp::Networking::get().isPassworded(); return mwmp::Networking::get().isPassworded();
} }
int ServerFunctions::GetPluginEnforcementState() noexcept
{
return mwmp::Networking::getPtr()->getPluginEnforcementState();
}
void ServerFunctions::SetGameMode(const char *gameMode) noexcept void ServerFunctions::SetGameMode(const char *gameMode) noexcept
{ {
if (mwmp::Networking::getPtr()->getMasterClient()) if (mwmp::Networking::getPtr()->getMasterClient())
@ -92,6 +97,11 @@ void ServerFunctions::SetServerPassword(const char *password) noexcept
mwmp::Networking::getPtr()->setServerPassword(password); mwmp::Networking::getPtr()->setServerPassword(password);
} }
void ServerFunctions::SetPluginEnforcementState(bool state) noexcept
{
mwmp::Networking::getPtr()->setPluginEnforcementState(state);
}
void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept void ServerFunctions::SetRuleString(const char *key, const char *value) noexcept
{ {
auto mc = mwmp::Networking::getPtr()->getMasterClient(); auto mc = mwmp::Networking::getPtr()->getMasterClient();

@ -4,26 +4,28 @@
#include "../Types.hpp" #include "../Types.hpp"
#define SERVERAPI \ #define SERVERAPI \
{"StopServer", ServerFunctions::StopServer},\ {"StopServer", ServerFunctions::StopServer},\
\ \
{"Kick", ServerFunctions::Kick},\ {"Kick", ServerFunctions::Kick},\
{"BanAddress", ServerFunctions::BanAddress},\ {"BanAddress", ServerFunctions::BanAddress},\
{"UnbanAddress", ServerFunctions::UnbanAddress},\ {"UnbanAddress", ServerFunctions::UnbanAddress},\
\ \
{"GetServerVersion", ServerFunctions::GetServerVersion},\ {"GetServerVersion", ServerFunctions::GetServerVersion},\
{"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\ {"GetProtocolVersion", ServerFunctions::GetProtocolVersion},\
{"GetAvgPing", ServerFunctions::GetAvgPing},\ {"GetAvgPing", ServerFunctions::GetAvgPing},\
{"GetIP", ServerFunctions::GetIP},\ {"GetIP", ServerFunctions::GetIP},\
{"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\ {"GetMaxPlayers", ServerFunctions::GetMaxPlayers},\
{"GetPort", ServerFunctions::GetPort},\ {"GetPort", ServerFunctions::GetPort},\
{"HasPassword", ServerFunctions::HasPassword},\ {"HasPassword", ServerFunctions::HasPassword},\
{"GetPluginEnforcementState", ServerFunctions::GetPluginEnforcementState},\
\ \
{"SetGameMode", ServerFunctions::SetGameMode},\ {"SetGameMode", ServerFunctions::SetGameMode},\
{"SetHostname", ServerFunctions::SetHostname},\ {"SetHostname", ServerFunctions::SetHostname},\
{"SetServerPassword", ServerFunctions::SetServerPassword},\ {"SetServerPassword", ServerFunctions::SetServerPassword},\
{"SetRuleString", ServerFunctions::SetRuleString},\ {"SetPluginEnforcementState", ServerFunctions::SetPluginEnforcementState},\
{"SetRuleValue", ServerFunctions::SetRuleValue},\ {"SetRuleString", ServerFunctions::SetRuleString},\
{"AddPluginHash", ServerFunctions::AddPluginHash} {"SetRuleValue", ServerFunctions::SetRuleValue},\
{"AddPluginHash", ServerFunctions::AddPluginHash}
class ServerFunctions class ServerFunctions
{ {
@ -112,6 +114,15 @@ public:
*/ */
static bool HasPassword() noexcept; static bool HasPassword() noexcept;
/**
* \brief Get the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \return The enforcement state.
*/
static int GetPluginEnforcementState() noexcept;
/** /**
* \brief Set the game mode of the server, as displayed in the server browser. * \brief Set the game mode of the server, as displayed in the server browser.
* *
@ -134,7 +145,17 @@ public:
* \param password The password. * \param password The password.
* \return void * \return void
*/ */
static void SetServerPassword(const char *passw) noexcept; static void SetServerPassword(const char *password) noexcept;
/**
* \brief Set the plugin enforcement state of the server.
*
* If true, clients are required to use the same plugins as set for the server.
*
* \param state The new enforcement state.
* \return void
*/
static void SetPluginEnforcementState(bool state) noexcept;
/** /**
* \brief Set a rule string for the server details displayed in the server browser. * \brief Set a rule string for the server details displayed in the server browser.

Loading…
Cancel
Save