|
7 | 7 | using System.Collections.Generic; |
8 | 8 | using System.Linq; |
9 | 9 | using System.Text.RegularExpressions; |
10 | | -using Oxide.Core.Libraries; |
| 10 | +using Oxide.CSharp.Common; |
11 | 11 |
|
12 | 12 | namespace Oxide.Plugins |
13 | 13 | { |
@@ -35,19 +35,19 @@ public static CompilablePlugin GetCompilablePlugin(string directory, string name |
35 | 35 |
|
36 | 36 | public override string FileExtension => ".cs"; |
37 | 37 |
|
38 | | - private List<CompilablePlugin> compilationQueue = new List<CompilablePlugin>(); |
39 | | - private CompilerService compiler; |
| 38 | + private readonly List<CompilablePlugin> _compilationQueue = new List<CompilablePlugin>(); |
| 39 | + private readonly CompilerService _compiler; |
40 | 40 |
|
41 | 41 | public CSharpPluginLoader(CSharpExtension extension) |
42 | 42 | { |
43 | 43 | Instance = this; |
44 | 44 | CSharpPluginLoader.extension = extension; |
45 | | - compiler = new CompilerService(extension); |
| 45 | + _compiler = new CompilerService(extension); |
46 | 46 | } |
47 | 47 |
|
48 | 48 | public void OnModLoaded() |
49 | 49 | { |
50 | | - compiler.Precheck(); |
| 50 | + _compiler.Precheck(); |
51 | 51 |
|
52 | 52 | // Include references to all loaded game extensions and any assemblies they reference |
53 | 53 | foreach (Core.Extensions.Extension extension in Interface.Oxide.GetAllExtensions()) |
@@ -78,7 +78,7 @@ public void OnModLoaded() |
78 | 78 |
|
79 | 79 | public override IEnumerable<string> ScanDirectory(string directory) |
80 | 80 | { |
81 | | - bool installed = compiler.Installed; |
| 81 | + bool installed = _compiler.Installed; |
82 | 82 | if (!installed) |
83 | 83 | { |
84 | 84 | yield break; |
@@ -126,7 +126,7 @@ public override Plugin Load(string directory, string name) |
126 | 126 | /// <param name="name"></param> |
127 | 127 | public override void Reload(string directory, string name) |
128 | 128 | { |
129 | | - if (Regex.Match(directory, @"\\include\b", RegexOptions.IgnoreCase).Success) |
| 129 | + if (Constants.IncludeRegex.Match(directory).Success) |
130 | 130 | { |
131 | 131 | name = $"Oxide.{name}"; |
132 | 132 | foreach (CompilablePlugin plugin in plugins.Values) |
@@ -202,12 +202,14 @@ public void Load(CompilablePlugin plugin) |
202 | 202 | IEnumerable<string> loadingRequirements = plugin.Requires.Where(r => LoadingPlugins.Contains(r)); |
203 | 203 | if (loadingRequirements.Any()) |
204 | 204 | { |
205 | | - Interface.Oxide.RootLogger.WriteDebug(LogType.Info, LogEvent.Compile, "CSharp", $"{plugin.Name} plugin is waiting for requirements to be loaded: {loadingRequirements.ToSentence()}"); |
| 205 | + Interface.Oxide.RootLogger.WriteDebug(LogType.Info, LogEvent.Compile, "CSharp", |
| 206 | + $"{plugin.Name} plugin is waiting for requirements to be loaded: {loadingRequirements.ToSentence()}"); |
206 | 207 | } |
207 | 208 | else |
208 | 209 | { |
209 | | - Interface.Oxide.LogError($"{plugin.Name} plugin requires missing dependencies: {missingRequirements.ToSentence()}"); |
210 | | - PluginErrors[plugin.Name] = $"Missing dependencies: {missingRequirements.ToSentence()}"; |
| 210 | + string sentence = missingRequirements.ToSentence(); |
| 211 | + Interface.Oxide.LogError($"{plugin.Name} plugin requires missing dependencies: {sentence}"); |
| 212 | + PluginErrors[plugin.Name] = $"Missing dependencies: {sentence}"; |
211 | 213 | PluginLoadingCompleted(plugin); |
212 | 214 | } |
213 | 215 | } |
@@ -239,15 +241,15 @@ public void CompilationRequested(CompilablePlugin plugin) |
239 | 241 | Compilation.Current.Add(plugin); |
240 | 242 | return; |
241 | 243 | } |
242 | | - if (compilationQueue.Count < 1) |
| 244 | + if (_compilationQueue.Count < 1) |
243 | 245 | { |
244 | 246 | Interface.Oxide.NextTick(() => |
245 | 247 | { |
246 | | - CompileAssembly(compilationQueue.ToArray()); |
247 | | - compilationQueue.Clear(); |
| 248 | + CompileAssembly(_compilationQueue.ToArray()); |
| 249 | + _compilationQueue.Clear(); |
248 | 250 | }); |
249 | 251 | } |
250 | | - compilationQueue.Add(plugin); |
| 252 | + _compilationQueue.Add(plugin); |
251 | 253 | } |
252 | 254 |
|
253 | 255 | public void PluginLoadingStarted(CompilablePlugin plugin) |
@@ -278,7 +280,7 @@ private void PluginLoadingCompleted(CompilablePlugin plugin) |
278 | 280 |
|
279 | 281 | private void CompileAssembly(CompilablePlugin[] plugins) |
280 | 282 | { |
281 | | - compiler.Compile(plugins, compilation => |
| 283 | + _compiler.Compile(plugins, compilation => |
282 | 284 | { |
283 | 285 | if (compilation.compiledAssembly == null) |
284 | 286 | { |
@@ -316,6 +318,6 @@ private void CompileAssembly(CompilablePlugin[] plugins) |
316 | 318 | }); |
317 | 319 | } |
318 | 320 |
|
319 | | - public void OnShutdown() => compiler.Stop(true, "framework shutting down"); |
| 321 | + public void OnShutdown() => _compiler.Stop(true, "framework shutting down"); |
320 | 322 | } |
321 | 323 | } |
0 commit comments