mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-30 12:23:39 +01:00
Add plugin error notifications, per-plugin event invocation wrappers
This commit is contained in:
parent
1913a4cd2c
commit
ddf0a97c83
11 changed files with 358 additions and 85 deletions
|
|
@ -11,6 +11,47 @@ namespace Dalamud.Console;
|
|||
|
||||
#pragma warning disable Dalamud001
|
||||
|
||||
/// <summary>
|
||||
/// Utility functions for the console manager.
|
||||
/// </summary>
|
||||
internal static partial class ConsoleManagerPluginUtil
|
||||
{
|
||||
private static readonly string[] ReservedNamespaces = ["dalamud", "xl", "plugin"];
|
||||
|
||||
/// <summary>
|
||||
/// Get a sanitized namespace name from a plugin's internal name.
|
||||
/// </summary>
|
||||
/// <param name="pluginInternalName">The plugin's internal name.</param>
|
||||
/// <returns>A sanitized namespace.</returns>
|
||||
public static string GetSanitizedNamespaceName(string pluginInternalName)
|
||||
{
|
||||
// Must be lowercase
|
||||
pluginInternalName = pluginInternalName.ToLowerInvariant();
|
||||
|
||||
// Remove all non-alphabetic characters
|
||||
pluginInternalName = NonAlphaRegex().Replace(pluginInternalName, string.Empty);
|
||||
|
||||
// Remove reserved namespaces from the start or end
|
||||
foreach (var reservedNamespace in ReservedNamespaces)
|
||||
{
|
||||
if (pluginInternalName.StartsWith(reservedNamespace))
|
||||
{
|
||||
pluginInternalName = pluginInternalName[reservedNamespace.Length..];
|
||||
}
|
||||
|
||||
if (pluginInternalName.EndsWith(reservedNamespace))
|
||||
{
|
||||
pluginInternalName = pluginInternalName[..^reservedNamespace.Length];
|
||||
}
|
||||
}
|
||||
|
||||
return pluginInternalName;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"[^a-z]")]
|
||||
private static partial Regex NonAlphaRegex();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugin-scoped version of the console service.
|
||||
/// </summary>
|
||||
|
|
@ -130,44 +171,3 @@ internal class ConsoleManagerPluginScoped : IConsole, IInternalDisposableService
|
|||
return command;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Utility functions for the console manager.
|
||||
/// </summary>
|
||||
internal static partial class ConsoleManagerPluginUtil
|
||||
{
|
||||
private static readonly string[] ReservedNamespaces = ["dalamud", "xl", "plugin"];
|
||||
|
||||
/// <summary>
|
||||
/// Get a sanitized namespace name from a plugin's internal name.
|
||||
/// </summary>
|
||||
/// <param name="pluginInternalName">The plugin's internal name.</param>
|
||||
/// <returns>A sanitized namespace.</returns>
|
||||
public static string GetSanitizedNamespaceName(string pluginInternalName)
|
||||
{
|
||||
// Must be lowercase
|
||||
pluginInternalName = pluginInternalName.ToLowerInvariant();
|
||||
|
||||
// Remove all non-alphabetic characters
|
||||
pluginInternalName = NonAlphaRegex().Replace(pluginInternalName, string.Empty);
|
||||
|
||||
// Remove reserved namespaces from the start or end
|
||||
foreach (var reservedNamespace in ReservedNamespaces)
|
||||
{
|
||||
if (pluginInternalName.StartsWith(reservedNamespace))
|
||||
{
|
||||
pluginInternalName = pluginInternalName[reservedNamespace.Length..];
|
||||
}
|
||||
|
||||
if (pluginInternalName.EndsWith(reservedNamespace))
|
||||
{
|
||||
pluginInternalName = pluginInternalName[..^reservedNamespace.Length];
|
||||
}
|
||||
}
|
||||
|
||||
return pluginInternalName;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"[^a-z]")]
|
||||
private static partial Regex NonAlphaRegex();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue