3#include "../IBaseApi.h"
4#include "Ark/MessagingManager.h"
5#include "Ark/AsaApiUtilsMessagingManager.h"
17 std::shared_ptr<MessagingManager> manager = ReadApiMessagingManager();
18 manager->SetWorldContext(uworld);
19 SetMessagingManagerInternal(
"Default", manager);
59 if (!player_controller)
66 eos_id_map_[eos_id] = player_controller;
72 if (!player_controller)
79 eos_id_map_.erase(eos_id);
90 auto iter = eos_id_map_.find(eos_id);
91 if (iter != eos_id_map_.end()
92 && iter->first == eos_id)
94 found_player = iter->second;
97 if (found_player ==
nullptr)
100 for (TWeakObjectPtr<APlayerController> player_controller : player_controllers)
102 AShooterPlayerController* shooter_pc =
static_cast<AShooterPlayerController*>(player_controller.Get());
106 const FString& iter_eos_id = *API::game_api->GetApiUtils()->GetEOSIDFromController(shooter_pc);
107 if (iter_eos_id == eos_id)
109 found_player = shooter_pc;
126 auto iter = messaging_managers_.find(forPlugin);
127 if (forPlugin.IsEmpty()
128 || iter == messaging_managers_.end())
130 return messaging_managers_.find(
"Default")->second;
137 if (manager ==
nullptr)
138 throw std::invalid_argument(
"MessagingManager cannot be null");
140 messaging_managers_[forPlugin] = manager;
141 manager->SetWorldContext(u_world_);
152 messaging_managers_.erase(forPlugin);
157 for (
auto it = messaging_managers_.begin(); it != messaging_managers_.end(); )
159 auto& manager = it->second;
162 it = messaging_managers_.erase(it);
167 std::optional<std::string> error = manager->MeetsRequirementsToWork();
168 if (error.has_value())
170 TArray<FString> parsedName;
171 it->first.ParseIntoArray(parsedName, L"\\",
true);
172 Log::GetLog()->error(
"Custom messaging error for '{}', using normal messaging. Reason: {}", parsedName.Last().ToString(), error.value());
173 it = messaging_managers_.erase(it);
178 manager->SetWorldContext(u_world_);
187 const std::string config_path = AsaApi::Tools::GetCurrentDir() +
"/config.json";
188 std::ifstream file{ config_path };
192 nlohmann::json config;
196 std::string messaging_manager_name = config[
"settings"].value(
"DefaultMessaging",
"Default");
197 if (messaging_manager_name ==
"Default")
199 else if (messaging_manager_name ==
"AsaApiUtilsMod")
208 return *API::game_api->GetApiUtils();
void SetStatus(ServerStatus status)
std::shared_ptr< MessagingManager > GetMessagingManagerInternal(const FString &forPlugin) const override
void SetCheatManager(UShooterCheatManager *cheatmanager)
std::shared_ptr< MessagingManager > ReadApiMessagingManager()
UShooterCheatManager * GetCheatManager() const override
Returns a point to URCON CheatManager.
void CheckMessagingManagersRequirements()
AShooterPlayerController * FindPlayerFromEOSID_Internal(const FString &eos_id) const override
AShooterGameMode * GetShooterGameMode() const override
Returns a pointer to AShooterGameMode.
void SetShooterGameMode(AShooterGameMode *shooter_game_mode)
void RemoveMessagingManagerInternal(const FString &forPlugin)
AShooterGameMode * shooter_game_mode_
UWorld * GetWorld() const override
Returns a pointer to UWorld.
void SetMessagingManagerInternal(const FString &forPlugin, std::shared_ptr< MessagingManager > manager) override
ServerStatus GetStatus() const override
Returns the current server status.
void SetPlayerController(AShooterPlayerController *player_controller)
void RemovePlayerController(AShooterPlayerController *player_controller)
void SetWorld(UWorld *uworld)
UShooterCheatManager * cheatmanager_
static FORCEINLINE FString GetEOSIDFromController(AController *controller)
Returns EOS ID from player controller.
UE_NODISCARD FORCEINLINE bool IsEmpty() const
Messaging manager. Allows to send server messages, notifications and chat messages.
IApiUtils & GetApiUtils()
TArray< TWeakObjectPtr< APlayerController >, TSizedDefaultAllocator< 32 > > & PlayerControllerListField()