8#include "../PDBReader/PDBReader.h"
9#include "../PluginManager/PluginManager.h"
11#include "../Commands.h"
12#include "Logger/Logger.h"
18 constexpr float api_version = 1.7f;
29 Log::GetLog()->info(
"-----------------------------------------------");
30 Log::GetLog()->info(
"YAPI V{:.1f}", GetVersion());
31 Log::GetLog()->info(
"Loading...\n");
35 std::unordered_map<std::string, intptr_t> offsets_dump;
36 std::unordered_map<std::string, BitField> bitfields_dump;
43 pdb_reader.Read(dir + L"/ShooterGameServer.pdb", &offsets_dump, &bitfields_dump);
45 catch (
const std::exception& error)
47 Log::GetLog()->critical(
"Failed to read pdb - {}", error.what());
51 Offsets::Get().Init(move(offsets_dump), move(bitfields_dump));
55 Log::GetLog()->info(
"API was successfully loaded");
56 Log::GetLog()->info(
"-----------------------------------------------\n");
96 TArray<FString> parsed;
97 cmd->ParseIntoArray(parsed, L" ",
true);
99 if (parsed.IsValidIndex(1))
101 const std::string plugin_name = parsed[1].ToString();
107 catch (
const std::exception& error)
109 Log::GetLog()->warn(
"({}) {}",
__FUNCTION__, error.what());
110 return FString::Format(
"Failed to load plugin - {}", error.what());
113 Log::GetLog()->info(
"Loaded plugin - {}", plugin_name.c_str());
115 return "Successfully loaded plugin";
118 return "Plugin not found";
123 TArray<FString> parsed;
124 cmd->ParseIntoArray(parsed, L" ",
true);
126 if (parsed.IsValidIndex(1))
128 const std::string plugin_name = parsed[1].ToString();
134 catch (
const std::exception& error)
136 Log::GetLog()->warn(
"({}) {}",
__FUNCTION__, error.what());
137 return *FString::Format(
"Failed to unload plugin - {}", error.what());
140 Log::GetLog()->info(
"Unloaded plugin - {}", plugin_name.c_str());
142 return L"Successfully unloaded plugin";
145 return L"Plugin not found";
static void UnloadPluginCmd(APlayerController *, FString *, bool)
std::unique_ptr< ArkApi::ICommands > commands_
static FString LoadPlugin(FString *cmd)
std::unique_ptr< ArkApi::IApiUtils > api_utils_
std::unique_ptr< ArkApi::ICommands > & GetCommands() override
std::unique_ptr< ArkApi::IHooks > & GetHooks() override
static void LoadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
void RegisterCommands() override
std::unique_ptr< ArkApi::IApiUtils > & GetApiUtils() override
std::unique_ptr< ArkApi::IHooks > hooks_
static void LoadPluginCmd(APlayerController *, FString *, bool)
static FString UnloadPlugin(FString *cmd)
float GetVersion() override
static void UnloadPluginRcon(RCONClientConnection *, RCONPacket *, UWorld *)
std::string GetApiName() override
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
IApiUtils & GetApiUtils()
void SendMessageW(int Id, int Type, FString *OutGoingMessage)