-
Notifications
You must be signed in to change notification settings - Fork 1
/
TeamSpeakPlugin.cs
72 lines (66 loc) · 2.69 KB
/
TeamSpeakPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Microsoft.Win32;
using NLog;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BSU.Sync
{
public static class TeamSpeakPlugin
{
private static Logger logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// Determines if TeamSpeak is installed
/// </summary>
/// <returns></returns>
public static bool TeamSpeakInstalled()
{
return TeamSpeakPath() != string.Empty;
}
/// <summary>
/// Determines the location of TeamSpeak
/// </summary>
/// <returns></returns>
public static string TeamSpeakPath()
{
RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
localKey = localKey.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
if (localKey != null)
{
return localKey.GetValue(null).ToString();
}
RegistryKey localkey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
localkey32 = localkey32.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
if (localkey32 != null)
{
return localkey32.GetValue(null).ToString();
}
return string.Empty;
}
/// <summary>
/// Gets a list of all mod folders which contain
/// </summary>
/// <param name="mods"></param>
/// <param name="localPath"></param>
/// <returns></returns>
public static List<ModFolder> GetModFoldersWithPlugins(List<ModFolder> mods, string localPath)
{
var returnList = new List<ModFolder>();
foreach (ModFolder m in mods)
{
var modPath = new DirectoryInfo(Path.Combine(localPath, m.ModName));
DirectoryInfo[] folders = modPath.GetDirectories();
var pluginFolders = new List<string> {"plugins", "plugin"};
// ^ Support for both TFAR and ACRE
foreach (string folder in pluginFolders)
{
if (!folders.Any(x => x.FullName.Equals(Path.Combine(modPath.FullName, folder)))) continue;
//var modPluginFolder = new DirectoryInfo(Path.Combine(modPath.FullName, folder));
//var tsPluginFolder = new DirectoryInfo(Path.Combine(TeamSpeakPlugin.TeamSpeakPath(), folder));
logger.Trace("Plugins exists inside of {0}", modPath);
returnList.Add(m);
}
}
return returnList;
}
}
}