bool InstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force) { if (!gamePath.IsNotNullAndExists()) { throw new ArgumentNullException("Unable to find the Game Install Directory"); } if (mod == null) { throw new ArgumentNullException(nameof(mod), "Fatal Error Occured: Mod incorrectly registered"); } if (plugin == null) { throw new ArgumentNullException(nameof(plugin), "Fatal Error Occured: Plugin Path was not set"); } if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists()) { throw new InvalidOperationException("The mod is not installed"); } var pluginPath = mod.PathInternal.GetChildFileWithName(plugin); var gamePluginFolder = gamePath; return(InstallDll(pluginPath, gamePluginFolder, force)); }
public void InstallDllPlugin(IContentEngineGame game, IContentEngineContent content, string plugin, bool force = false) { var success = TryInstallPlugin(game.WorkingDirectory, content, plugin, force); MainLog.Logger.Info("Install Success?: " + success); }
async Task LoadModSFromStream(IContentEngineContent content, IContentEngineGame game) { using (var streamR = new StreamReader(_resourceService.GetResource(GetScriptPath(content.Id)))) { var js = streamR.ReadToEnd(); await HandleCommand(content, game, js).ConfigureAwait(false); } }
bool InstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force) { if (!tsPath.IsNotNullAndExists()) { throw new ArgumentNullException("Unable to find the Teamspeak Install Directory"); } if (mod == null) { throw new ArgumentNullException(nameof(mod), "Fatal Error Occured: Mod incorrectly registered"); } if (plugin == null) { throw new ArgumentNullException(nameof(plugin), "Fatal Error Occured: Plugin Path was not set"); } if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists()) { throw new InvalidOperationException("The mod is not installed"); } var pluginPath = Path.Combine(mod.PathInternal.ToString(), plugin).ToAbsoluteFilePath(); var tsPluginFolder = GetPluginPath(tsPath); return(InstallDll(pluginPath, tsPluginFolder, force)); }
public Task LoadModS(IContentEngineContent mod, IContentEngineGame game, bool overrideMod = false) { if (!ModHasScript(mod)) { throw new Exception("This mod does not have a Script"); } return(LoadModSFromStream(mod, game)); }
private static void InstallDll(IContentEngineContent content, IContentEngineGame game, InstallDllCommand c) { var s = new GameFolderService(); foreach (var f in c.Source) { s.InstallDllPlugin(game, content, f, c.Options.Force); } }
public bool TryGetMod(IContentEngineContent mod, out RegisteredMod registeredMod) { try { registeredMod = GetMod(mod); return true; } catch (Exception e) { _logger.FormattedWarnException(e, "Failure getting mod"); } registeredMod = null; return false; }
bool TryInstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force) { try { return InstallPlugin(tsPath, mod, plugin, force); } catch (PathDoesntExistException e) { MainLog.Logger.FormattedWarnException(e, "Path: " + e.Path); } catch (Win32Exception e) { MainLog.Logger.FormattedWarnException(e); } catch (Exception ex) { MainLog.Logger.FormattedErrorException(ex); } return false; }
public IModS LoadModS(IContentEngineContent mod, bool overrideMod = false) { if (!ModHasScript(mod)) throw new Exception("This mod does not have a Script"); RegisteredMod loadedMod; if (_scriptRegistry.TryGetMod(mod.NetworkId, out loadedMod)) { if (overrideMod) loadedMod.Mod = mod; return loadedMod.ModScript; } var modS = LoadModSFromStream(mod.NetworkId); FinalizeLoadMod(mod, modS); return modS; }
bool TryInstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force) { try { return(InstallPlugin(gamePath, mod, plugin, force)); } catch (PathDoesntExistException e) { MainLog.Logger.FormattedWarnException(e, "Path: " + e.Path); } catch (Win32Exception e) { MainLog.Logger.FormattedWarnException(e); } catch (Exception ex) { MainLog.Logger.FormattedErrorException(ex); } return(false); }
private static void InstallTeamspeakFiles(IContentEngineContent content, InstallTeamspeakPluginCommand c) { var s = new TeamspeakService(); foreach (var f in c.Files) { switch (f.Type) { case TsType.Any: { foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { if (s.IsX86Installed()) s.InstallX86PluginFolder(content, p, c.Options.Force); if (s.IsX64Installed()) s.InstallX64PluginFolder(content, p, c.Options.Force); } else { if (s.IsX86Installed()) s.InstallX86Plugin(content, p, c.Options.Force); if (s.IsX64Installed()) s.InstallX64Plugin(content, p, c.Options.Force); } } break; } case TsType.x86: { if (!s.IsX86Installed()) return; foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { s.InstallX86PluginFolder(content, p, c.Options.Force); } else { s.InstallX86Plugin(content, p, c.Options.Force); } } break; } case TsType.x64: { if (!s.IsX64Installed()) return; foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { s.InstallX64PluginFolder(content, p, c.Options.Force); } else { s.InstallX64Plugin(content, p, c.Options.Force); } } break; } } } }
bool InstallPlugin(IAbsoluteDirectoryPath gamePath, IContentEngineContent mod, string plugin, bool force) { Contract.Requires<ArgumentNullException>(gamePath.IsNotNullAndExists(), "Unable to find the Game Install Directory"); Contract.Requires<ArgumentNullException>(mod != null, "Fatal Error Occured: Mod incorrectly registered"); Contract.Requires<ArgumentNullException>(plugin != null, "Fatal Error Occured: Plugin Path was not set"); if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists()) throw new InvalidOperationException("The mod is not installed"); var pluginPath = mod.PathInternal.GetChildFileWithName(plugin); var gamePluginFolder = gamePath; return InstallDll(pluginPath, gamePluginFolder, force); }
private static async Task HandleCommand(IContentEngineContent content, IContentEngineGame game, string js) { var bc = js.FromJson<CommandBase>(); switch (bc.Command) { case Commands.installDll: { var c = js.FromJson<InstallDllCommand>(); InstallDll(content, game, c); break; } case Commands.installTeamspeakPlugin: { var c = js.FromJson<InstallTeamspeakPluginCommand>(); InstallTeamspeakFiles(content, c); break; } } }
private static async Task HandleCommand(IContentEngineContent content, IContentEngineGame game, string js) { var bc = js.FromJson <CommandBase>(); switch (bc.Command) { case Commands.installDll: { var c = js.FromJson <InstallDllCommand>(); InstallDll(content, game, c); break; } case Commands.installTeamspeakPlugin: { var c = js.FromJson <InstallTeamspeakPluginCommand>(); InstallTeamspeakFiles(content, c); break; } } }
public bool ModHasScript(IContentEngineContent mod) => ModHasScript(mod.NetworkId);
private static void InstallDll(IContentEngineContent content, IContentEngineGame game, InstallDllCommand c) { var s = new GameFolderService(); foreach (var f in c.Source) s.InstallDllPlugin(game, content, f, c.Options.Force); }
public Task LoadModS(IContentEngineContent mod, IContentEngineGame game, bool overrideMod = false) { if (!ModHasScript(mod)) throw new Exception("This mod does not have a Script"); return LoadModSFromStream(mod, game); }
public void InstallX64PluginFolder(IContentEngineContent content, string plugin, bool force = false) { var success = TryInstallPluginFolder(TS3_64_Path, content, plugin, force); MainLog.Logger.Info("Install Success?: " + success); }
public void UnregisterMod(IContentEngineContent mod) { UnregisterMod(GetMod(mod)); }
void FinalizeLoadMod(IContentEngineContent mod, IModS modS) { var registeredMod = new RegisteredMod(mod.NetworkId, mod, modS); _scriptRegistry.RegisterMod(registeredMod); }
public RegisteredMod GetMod(IContentEngineContent mod) { return GetMod(mod.Id); }
internal RegisteredMod(Guid guid, IContentEngineContent mod, IModS modScript) { Guid = guid; Mod = mod; ModScript = modScript; AccessToken = Convert.ToBase64String(Guid.NewGuid().ToByteArray().Combine(guid.ToByteArray())); ModScript.setToken(AccessToken); }
public bool ModHasScript(IContentEngineContent mod) { return ModHasScript(mod.NetworkId); }
bool InstallPlugin(IAbsoluteDirectoryPath tsPath, IContentEngineContent mod, string plugin, bool force) { Contract.Requires<ArgumentNullException>(tsPath.IsNotNullAndExists(), "Unable to find the Teamspeak Install Directory"); Contract.Requires<ArgumentNullException>(mod != null, "Fatal Error Occured: Mod incorrectly registered"); Contract.Requires<ArgumentNullException>(plugin != null, "Fatal Error Occured: Plugin Path was not set"); if (!mod.IsInstalled || !mod.PathInternal.IsNotNullAndExists()) throw new InvalidOperationException("The mod is not installed"); var pluginPath = Path.Combine(mod.PathInternal.ToString(), plugin).ToAbsoluteFilePath(); var tsPluginFolder = GetPluginPath(tsPath); return InstallDll(pluginPath, tsPluginFolder, force); }
private static void InstallTeamspeakFiles(IContentEngineContent content, InstallTeamspeakPluginCommand c) { var s = new TeamspeakService(); foreach (var f in c.Files) { switch (f.Type) { case TsType.Any: { foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { if (s.IsX86Installed()) { s.InstallX86PluginFolder(content, p, c.Options.Force); } if (s.IsX64Installed()) { s.InstallX64PluginFolder(content, p, c.Options.Force); } } else { if (s.IsX86Installed()) { s.InstallX86Plugin(content, p, c.Options.Force); } if (s.IsX64Installed()) { s.InstallX64Plugin(content, p, c.Options.Force); } } } break; } case TsType.x86: { if (!s.IsX86Installed()) { return; } foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { s.InstallX86PluginFolder(content, p, c.Options.Force); } else { s.InstallX86Plugin(content, p, c.Options.Force); } } break; } case TsType.x64: { if (!s.IsX64Installed()) { return; } foreach (var f2 in f.Source) { var p = Path.Combine(content.PathInternal.ToString(), f2); if (Directory.Exists(p)) { s.InstallX64PluginFolder(content, p, c.Options.Force); } else { s.InstallX64Plugin(content, p, c.Options.Force); } } break; } } } }