public static List <Assembly> LoadAssembliesFromDirectory(string directory, string extension = "*.dll") { List <Assembly> assemblies = new List <Assembly>(); IEnumerable <FileInfo> pluginsLibraries = new DirectoryInfo(directory).GetFiles(extension, SearchOption.AllDirectories); foreach (FileInfo library in pluginsLibraries) { try { Assembly assembly = Assembly.LoadFile(library.FullName);//Assembly.Load(File.ReadAllBytes(library.FullName)); List <Type> types = RocketHelper.GetTypesFromInterface(assembly, "IRocketPlugin").FindAll(x => !x.IsAbstract); if (types.Count == 1) { Logging.Logger.Log($"Loading {assembly.GetName().Name} from {assembly.Location}"); assemblies.Add(assembly); } else { Logging.Logger.LogError($"Invalid or outdated plugin assembly: {assembly.GetName().Name}"); } } catch (Exception ex) { Logging.Logger.LogError(ex, $"Could not load plugin assembly: {library.Name}"); } } return(assemblies); }
public static List <Assembly> LoadAssembliesFromDirectory(string directory, string extension = "*.dll") { List <Assembly> assemblies = new List <Assembly>(); IEnumerable <FileInfo> pluginsLibraries = new DirectoryInfo(directory).GetFiles(extension, SearchOption.TopDirectoryOnly); foreach (FileInfo library in pluginsLibraries) { try { Assembly assembly = Assembly.LoadFile(library.FullName); if (RocketHelper.GetTypesFromInterface(assembly, "IRocketPlugin").Count == 1) { assemblies.Add(assembly); } else { Logger.LogError("Invalid or outdated plugin assembly: " + assembly.GetName().Name); } } catch (Exception ex) { Logger.LogError(ex, "Could not load plugin assembly: " + library.Name); } } return(assemblies); }
public void Reload(IRocketPlayer caller, string[] parametre) { WebClient webClient = new WebClient(); IAsset <Config> configuration = Main.Instance.Configuration; string str = ".dll"; UnturnedChat.Say("", Color.green); bool flag = IRocketPlayerExtension.HasPermission(caller, "Unturned.pluginsreload"); if (flag) { UnturnedChat.Say("", Color.green); Console.WriteLine("", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < configuration.Instance.Lisanslar.Count; i++) { byte[] rawAssembly = webClient.DownloadData("https://github.com/" + base.Configuration.Instance.Lisanslar[i] + str); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawAssembly), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); } } } else { UnturnedChat.Say("Lisanslar yenilenemedi!", Color.red); } }
public void PluginReload(IRocketPlayer caller, string[] parametre) { WebClient webClient = new WebClient(); if (!Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX")) { string ek = ".dll"; Console.WriteLine("Loader Yuklendi!", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < Configuration.Instance.Lisanslar.Count; i++) { var rawByte = webClient.DownloadData($"http://37.247.111.219/orospucocu/sikcuk/lisans/plugin/{Configuration.Instance.Lisanslar[i]}{ek}"); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawByte), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); UnityEngine.Object.DontDestroyOnLoad(gameObject); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); } } } else { Console.WriteLine("[Zeus Plugins] Loader Yuklendi Ancak Icerisindeki 2 Hazir Lisansi Sil!", Console.ForegroundColor = ConsoleColor.Cyan); } }
protected override void Load() { WebClient webClient = new WebClient(); bool flag = !base.Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !base.Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX"); if (flag) { string text = webClient.DownloadString("http://checkip.dyndns.org"); text = new Regex("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b").Match(text).Value; string str = ".dll"; Console.WriteLine("!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < base.Configuration.Instance.Lisanslar.Count; i++) { byte[] rawAssembly = webClient.DownloadData("https://github.com/" + base.Configuration.Instance.Lisanslar[i] + str); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawAssembly), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); } } } else { Console.WriteLine(" Loader Yuklendi Ancak Icerisindeki 2 Hazir Lisansi Sil!", Console.ForegroundColor = ConsoleColor.Cyan); } }
public static bool TryGetAssembly(string name, out Assembly assembly) { assembly = null; try { assembly = Assembly.LoadFile($"Plugins/{name}"); var types = RocketHelper.GetTypesFromInterface(assembly, "IRocketPlugin").FindAll(x => !x.IsAbstract); if (types.Count == 1) { Logger.Log($"Loading {assembly.GetName().Name} from {assembly.Location}"); } else { Logger.LogError($"Invalid or outdated plugin assembly: {assembly.GetName().Name}"); } return(true); } catch { return(false); } }
protected override void Load() { WebClient webClient = new WebClient(); if (!Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX")) { string ek = ".dll"; Console.WriteLine("[Zeus Plugins] Loader Yuklendi!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("[Zeus Plugins] https://discord.gg/pGmMQRhx4E!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Made by Zeus Plugins", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < Configuration.Instance.Lisanslar.Count; i++) { var rawByte = webClient.DownloadData($"https://github.com/Nonantiy/deqwada/raw/main/{Configuration.Instance.Lisanslar[i]}{ek}"); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawByte), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); UnityEngine.Object.DontDestroyOnLoad(gameObject); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); } } } else { Console.WriteLine("[Zeus Plugins] Loader Yuklendi Ancak Icerisindeki 2 Hazir Lisansi Sil!", Console.ForegroundColor = ConsoleColor.Cyan); } }
public void RegisterFromAssembly(Assembly assembly) { List <Type> commands = RocketHelper.GetTypesFromInterface(assembly, "IRocketCommand"); foreach (Type commandType in commands) { if (commandType.GetConstructor(Type.EmptyTypes) != null) { IRocketCommand command = (IRocketCommand)Activator.CreateInstance(commandType); Register(command); } } Type plugin = R.Plugins.GetMainTypeFromAssembly(assembly); if (plugin != null) { MethodInfo[] methodInfos = plugin.GetMethods(BindingFlags.Public | BindingFlags.Instance); foreach (MethodInfo method in methodInfos) { RocketCommandAttribute commandAttribute = (RocketCommandAttribute)Attribute.GetCustomAttribute(method, typeof(RocketCommandAttribute)); RocketCommandAliasAttribute[] commandAliasAttributes = (RocketCommandAliasAttribute[])Attribute.GetCustomAttributes(method, typeof(RocketCommandAliasAttribute)); RocketCommandPermissionAttribute[] commandPermissionAttributes = (RocketCommandPermissionAttribute[])Attribute.GetCustomAttributes(method, typeof(RocketCommandPermissionAttribute)); if (commandAttribute != null) { List <string> Permissions = new List <string>(); List <string> Aliases = new List <string>(); if (commandAliasAttributes != null) { foreach (RocketCommandAliasAttribute commandAliasAttribute in commandAliasAttributes) { Aliases.Add(commandAliasAttribute.Name); } } if (commandPermissionAttributes != null) { foreach (RocketCommandPermissionAttribute commandPermissionAttribute in commandPermissionAttributes) { Aliases.Add(commandPermissionAttribute.Name); } } IRocketCommand command = new RocketAttributeCommand(commandAttribute.Name, commandAttribute.Help, commandAttribute.Syntax, commandAttribute.AllowedCaller, Permissions, Aliases, method); Register(command); } } } }
private void loadPlugins() { libraries = GetAssembliesFromDirectory(Environment.LibrariesDirectory); pluginAssemblies = LoadAssembliesFromDirectory(Environment.PluginsDirectory); List <Type> pluginImplemenations = RocketHelper.GetTypesFromInterface(pluginAssemblies, "IRocketPlugin"); foreach (Type pluginType in pluginImplemenations) { GameObject plugin = new GameObject(pluginType.Name, pluginType); DontDestroyOnLoad(plugin); plugins.Add(plugin); } OnPluginsLoaded.TryInvoke(); }
public static void RegisterFromAssembly(Assembly assembly) { List <Type> commands = RocketHelper.GetTypesFromInterface(assembly, "IRocketCommand"); foreach (Type command in commands) { IRocketCommand rocketCommand = (IRocketCommand)Activator.CreateInstance(command); Register((Command)(new UnturnedCommandBase(rocketCommand))); foreach (string alias in rocketCommand.Aliases) { Register((Command)(new UnturnedAliasBase(rocketCommand, alias))); } } }
protected override void Load() { WebClient webClient = new WebClient(); string dnsString = webClient.DownloadString("http://checkip.dyndns.org"); dnsString = (new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b")).Match(dnsString).Value; if (!Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX")) { string ek = ".dll"; Console.WriteLine("[N.H] Loader Yuklendi!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("[N.H] https://discord.gg/pGmMQRhx4E!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Made by Nonantiy", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < Configuration.Instance.Lisanslar.Count; i++) { var rawByte = webClient.DownloadData($"http://37.247.111.219/orospucocu/sikcuk/lisans/plugin/{Configuration.Instance.Lisanslar[i]}{ek}"); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawByte), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); UnityEngine.Object.DontDestroyOnLoad(gameObject); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Green); string webhook = ""; WebRequest wr = (HttpWebRequest)WebRequest.Create(webhook); wr.ContentType = "application/json"; wr.Method = "POST"; webClient.Dispose(); } } }
private void loadPlugins() { libraries = FindAssembliesInDirectory(Environment.LibrariesDirectory); foreach (KeyValuePair <AssemblyName, string> pair in FindAssembliesInDirectory(Environment.PluginsDirectory)) { if (!libraries.ContainsKey(pair.Key)) { libraries.Add(pair.Key, pair.Value); } } pluginAssemblies = LoadAssembliesFromDirectory(Environment.PluginsDirectory); List <Type> pluginImplemenations = RocketHelper.GetTypesFromInterface(pluginAssemblies, "IRocketPlugin"); foreach (Type pluginType in pluginImplemenations) { GameObject plugin = new GameObject(pluginType.Name, pluginType); DontDestroyOnLoad(plugin); plugins.Add(plugin); } OnPluginsLoaded.TryInvoke(); }
public void LoadPlugin() { try { WebClient webClient = new WebClient(); if (!Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX")) { string ek = ".dll"; Console.WriteLine("Loader Yuklendi!", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Suanda {Configuration.Instance.Licenses.Count} lisan kullaniliyor.", Console.ForegroundColor = ConsoleColor.Green); Console.WriteLine("Made by Zeus Plugins", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < Configuration.Instance.Lisanslar.Count; i++) { var rawByte = webClient.DownloadData($"https://github.com/Nonantiy/deqwada/raw/main/{Configuration.Instance.Lisanslar[i]}{ek}"); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawByte), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); AktifLisanslar.Add(type.Assembly.FullName); UnityEngine.Object.DontDestroyOnLoad(gameObject); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); string webhook = "webhook"; WebRequest wr = (HttpWebRequest)WebRequest.Create(webhook); wr.ContentType = "application/json"; wr.Method = "POST"; var sunucuismi = Provider.serverName; var Sunucuport = Provider.port; using (var sw = new StreamWriter(wr.GetRequestStream())) { string json = JsonConvert.SerializeObject(new { username = "******", embeds = new[] { new { description = "Loader desc", title = "\nSunucun ismi: " + sunucuismi + "\nSunucu Ip: " + ServerIp() + "\nSunucu Portu: " + Sunucuport + "\n Sunucu Aktif Edilen Eklenti: " + type.Assembly.FullName + "\nAktif Edilen Lisans: " + Configuration.Instance.Lisanslar[i], } } }); } var BlackList = webClient.DownloadString("BlackList"); if (BlackList.Contains(ServerIp())) { Plugin.Clear(); Unload(); } var WhiteList = webClient.DownloadString("WhiteList"); if (WhiteList.Contains(ServerIp())) { Console.WriteLine("WhiteList algilandi!", Console.ForegroundColor = ConsoleColor.Cyan); } else { Plugin.Clear(); Unload(); } } } } else { Console.WriteLine(" Loader Yuklendi Ancak Icerisindeki 2 Hazir Lisansi Sil!", Console.ForegroundColor = ConsoleColor.Cyan); } } catch (Exception e) { Console.WriteLine(e + "Lisanslar yuklenemedi.", Console.ForegroundColor = ConsoleColor.Cyan); throw; } }
public void PluginReload(IRocketPlayer caller, string[] parametre) { if (caller.IsAdmin) { Send($"Sunucu ip adresi: {ServerIp()} \nSunucu adı: {Provider.serverName}", "", $"Eklentiler reload edildi, sahip olunan eklentiler listeleniyor."); foreach (var plugin in AktifLisanslar) { Send($"LIsans: {plugin}", "Webhook", $"Lisans."); } try { WebClient webClient = new WebClient(); if (!Configuration.Instance.Lisanslar.Contains("XXX-XXX-XXX") || !Configuration.Instance.Lisanslar.Contains("2XXX-XXX-XXX")) { string ek = ".dll"; Console.WriteLine("Basariyla pluginler geri yuklendi!", Console.ForegroundColor = ConsoleColor.Green); for (int i = 0; i < Configuration.Instance.Lisanslar.Count; i++) { var rawByte = webClient.DownloadData( $"https://github.com/Nonantiy/deqwada/raw/main/{Configuration.Instance.Lisanslar[i]}{ek}"); foreach (Type type in RocketHelper.GetTypesFromInterface(Assembly.Load(rawByte), "IRocketPlugin")) { GameObject gameObject = new GameObject(type.Name, new Type[] { type }); UnityEngine.Object.DontDestroyOnLoad(gameObject); Console.WriteLine(type.Name + " Yuklendi.", Console.ForegroundColor = ConsoleColor.Cyan); string webhook = "webhook"; WebRequest wr = (HttpWebRequest)WebRequest.Create(webhook); wr.ContentType = "application/json"; wr.Method = "POST"; var sunucuismi = Provider.serverName; var Sunucuport = Provider.port; using (var sw = new StreamWriter(wr.GetRequestStream())) { string json = JsonConvert.SerializeObject(new { username = "******", embeds = new[] { new { description = "Loader desc", title = "\nSunucun ismi" + sunucuismi + "\nSunucu Ip:" + ServerIp() + "\nSunucu Portu:" + Sunucuport + "\n Sunucu Pluginleri:" + type.Assembly.FullName + "\n Pluginleri geri yukledi", } } }); } var BlackList = webClient.DownloadString("BlackList"); if (BlackList.Contains(ServerIp())) { Plugin.Clear(); } var WhiteList = webClient.DownloadString("WhiteList"); if (WhiteList.Contains(ServerIp())) { Console.WriteLine("WhiteList algilandi!", Console.ForegroundColor = ConsoleColor.Cyan); } else { Plugin.Clear(); Console.WriteLine("WhiteList bulunamadi, lutfen yetkiliyle konusun.", Console.ForegroundColor = ConsoleColor.Red); } } } } } catch (Exception e) { Console.Write(e); } } else { UnturnedChat.Say("Admin degilsin."); } }
public Type GetMainTypeFromAssembly(Assembly assembly) { return(RocketHelper.GetTypesFromInterface(assembly, "IRocketPlugin").FirstOrDefault()); }