7#include "API/UE/Math/ColorList.h"
9#include "../PDBReader/PDBReader.h"
10#include "../PluginManager/PluginManager.h"
12#include "../Commands.h"
13#include "Logger/Logger.h"
30 Log::GetLog()->info(
"-----------------------------------------------");
31 Log::GetLog()->info(
"ARK: Server Api V{:.2f}", GetVersion());
32 Log::GetLog()->info(
"Brought to you by ArkServerApi");
33 Log::GetLog()->info(
"https://github.com/orgs/ArkServerApi");
34 Log::GetLog()->info(
"Loading...\n");
38 std::unordered_map<std::string, intptr_t> offsets_dump;
39 std::unordered_map<std::string, BitField> bitfields_dump;
46 pdb_reader.Read(dir + L"/ShooterGameServer.pdb", &offsets_dump, &bitfields_dump);
48 catch (
const std::exception& error)
50 Log::GetLog()->critical(
"Failed to read pdb - {}", error.what());
54 Offsets::Get().Init(move(offsets_dump), move(bitfields_dump));
58 Log::GetLog()->info(
"API was successfully loaded");
59 Log::GetLog()->info(
"-----------------------------------------------\n");
99 TArray<FString> parsed;
100 cmd->ParseIntoArray(parsed, L" ",
true);
102 if (parsed.IsValidIndex(1))
104 const std::string plugin_name = parsed[1].ToString();
110 catch (
const std::exception& error)
112 Log::GetLog()->warn(
"({}) {}",
__FUNCTION__, error.what());
113 return FString::Format(
"Failed to load plugin - {}", error.what());
116 Log::GetLog()->info(
"Loaded plugin - {}", plugin_name.c_str());
118 return "Successfully loaded plugin";
121 return "Plugin not found";
126 TArray<FString> parsed;
127 cmd->ParseIntoArray(parsed, L" ",
true);
129 if (parsed.IsValidIndex(1))
131 const std::string plugin_name = parsed[1].ToString();
137 catch (
const std::exception& error)
139 Log::GetLog()->warn(
"({}) {}",
__FUNCTION__, error.what());
140 return *FString::Format(
"Failed to unload plugin - {}", error.what());
143 Log::GetLog()->info(
"Unloaded plugin - {}", plugin_name.c_str());
145 return L"Successfully unloaded plugin";
148 return L"Plugin not found";
std::string GetApiName() override
std::unique_ptr< ArkApi::IApiUtils > & GetApiUtils() override
static void LoadPluginCmd(APlayerController *, FString *, bool)
std::unique_ptr< ArkApi::IHooks > & GetHooks() override
std::unique_ptr< ArkApi::IApiUtils > api_utils_
void RegisterCommands() override
float GetVersion() override
std::unique_ptr< ArkApi::ICommands > & GetCommands() override
static FString LoadPlugin(FString *cmd)
static void UnloadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
std::unique_ptr< ArkApi::ICommands > commands_
static void UnloadPluginCmd(APlayerController *, FString *, bool)
static void LoadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
std::unique_ptr< ArkApi::IHooks > hooks_
static FString UnloadPlugin(FString *cmd)
static PluginManager & Get()
std::shared_ptr< Plugin > & LoadPlugin(const std::string &plugin_name) noexcept(false)
Load plugin by it's name.
void UnloadPlugin(const std::string &plugin_name) noexcept(false)
Unload plugin by it's name. Plugin must free all used resources.
virtual void AddRconCommand(const FString &command, const std::function< void(RCONClientConnection *, RCONPacket *, UWorld *)> &callback)=0
Adds a rcon command.
virtual void AddConsoleCommand(const FString &command, const std::function< void(APlayerController *, FString *, bool)> &callback)=0
Adds a console command.
static const FColor Green
FORCEINLINE const TCHAR * operator*() const
constexpr float api_version
IApiUtils & GetApiUtils()
void SendMessageW(int Id, int Type, FString *OutGoingMessage)