Skip to content
Merged

Dev #15

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
SyncChangedGroup(ev.Player.ReferenceHub);
#endif

private static void SyncChangedGroup(ReferenceHub hub)

Check warning on line 39 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Method return value is never used (private accessibility)

Method 'SyncChangedGroup' return value is never used
{
Timing.CallDelayed(0.1f, () =>
{
Expand Down Expand Up @@ -81,7 +81,7 @@
Menu menu = Menu.GetCurrentPlayerMenu(hub);
if (!menu?.CheckAccess(hub) ?? false)
{
Log.Warn($"{hub.nicknameSync.MyNick} tried to interact with menu {menu.Name} which is disabled for him.");

Check warning on line 84 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
Menu.LoadForPlayer(hub, null);
return;
}
Expand All @@ -101,21 +101,24 @@
if (ss.SettingId == 0 && menu != null)
{
// return to upper menu (or main menu)
Menu m = Menu.GetMenu(menu.MenuRelated);

Check warning on line 104 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
Menu.LoadForPlayer(hub, m);
}
// load method when input is used on specific menu.
else if (menu != null)
{
if (ss.SettingId < 0)
Menu.LoadForPlayer(hub, menu.TryGetSubMenu(ss.SettingId));

Check warning on line 111 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
else
{
ServerSpecificSettingBase s = menu.Settings.FirstOrDefault(s => s.SettingId == ss.SettingId);
if (menu.SettingsSync[hub].Any(x => x.SettingId == ss.SettingId))
menu.SettingsSync[hub][menu.SettingsSync[hub].FindIndex(x => x.SettingId == ss.SettingId)] = ss;
if (menu.InternalSettingsSync[hub].Any(x => x.SettingId == ss.SettingId))

Check warning on line 114 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
menu.InternalSettingsSync[hub][menu.InternalSettingsSync[hub].FindIndex(x => x.SettingId == ss.SettingId)] = ss;
else
menu.SettingsSync[hub].Add(ss);
menu.InternalSettingsSync[hub].Add(ss);
ServerSpecificSettingBase s =
!menu.SentSettings.TryGetValue(hub, out ServerSpecificSettingBase[] customSettings)
? menu.Settings.FirstOrDefault(b => b.SettingId == ss.SettingId)
: customSettings.FirstOrDefault(b => b.SettingId == ss.SettingId);
switch (s)
{
case Button wBtn:
Expand Down Expand Up @@ -157,11 +160,11 @@
#else
Log.Debug(e.ToString());
#endif
if (Plugin.StaticConfig.ShowErrorToClient)
if (Plugin.Instance.Config.ShowErrorToClient)
{
Features.Utils.SendToPlayer(hub, null, new ServerSpecificSettingBase[]

Check warning on line 165 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant explicit type in array creation

Redundant explicit array type specification

Check warning on line 165 in EventHandler.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant name qualifier

Qualifier is redundant
{
new SSTextArea(-5, $"<color=red><b>{Plugin.GetTranslation().ServerError}\n{((hub.serverRoles.RemoteAdmin || Plugin.StaticConfig.ShowFullErrorToClient) && Plugin.StaticConfig.ShowFullErrorToModerators ? e.ToString() : Plugin.GetTranslation().NoPermission)}</b></color>", SSTextArea.FoldoutMode.CollapsedByDefault, Plugin.GetTranslation().ServerError),
new SSTextArea(-5, $"<color=red><b>{Plugin.GetTranslation().ServerError}\n{((hub.serverRoles.RemoteAdmin || Plugin.Instance.Config.ShowFullErrorToClient) && Plugin.Instance.Config.ShowFullErrorToModerators ? e.ToString() : Plugin.GetTranslation().NoPermission)}</b></color>", SSTextArea.FoldoutMode.CollapsedByDefault, Plugin.GetTranslation().ServerError),
new SSButton(-999, Plugin.GetTranslation().ReloadButton.Label, Plugin.GetTranslation().ReloadButton.ButtonText)
});
}
Expand Down
4 changes: 2 additions & 2 deletions Features/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static void Info(string message)
/// <param name="message">The message to be sent.</param>
internal static void Debug(object message)
{
if (Plugin.StaticConfig?.Debug ?? false)
if (Plugin.Instance.Config?.Debug ?? false)
Send($"[SSMenuSystem] {message}", LogLevel.Debug, ConsoleColor.Green);
}

Expand All @@ -41,7 +41,7 @@ internal static void Debug(object message)
/// <param name="message">The message to be sent.</param>
internal static void Debug(string message)
{
if (Plugin.StaticConfig?.Debug ?? false)
if (Plugin.Instance.Config?.Debug ?? false)
Send($"[SSMenuSystem] {message}", LogLevel.Debug, ConsoleColor.Green);
}

Expand Down
55 changes: 35 additions & 20 deletions Features/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
public static ReadOnlyDictionary<Menu, List<Keybind>> GlobalKeybindings => new(GlobalKeybindingSync);

/// <summary>
/// All synced parameters for a specified <see cref="ReferenceHub"/>.

Check warning on line 44 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
internal readonly Dictionary<ReferenceHub, List<ServerSpecificSettingBase>> InternalSettingsSync = new();

/// <summary>
/// All synced parameters for a specified <see cref="ReferenceHub"/>.

Check warning on line 49 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
public ReadOnlyDictionary<ReferenceHub, List<ServerSpecificSettingBase>> SettingsSync => new(InternalSettingsSync);

/// <summary>
/// This is used to see if <see cref="ReferenceHub"/> can use <see cref="Menu"/> or not.

Check warning on line 54 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target <see cref="ReferenceHub"/></param>

Check warning on line 56 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// <returns>True => Player can view and use the menu, and False => can't saw and use.</returns>
public virtual bool CheckAccess(ReferenceHub hub) => true;

Expand All @@ -73,7 +73,7 @@
/// </summary>
public static void QueueOrRegister()
{
if (Plugin.StaticConfig is null)
if (Plugin.Instance.Config is null)
{
Assembly assembly = Assembly.GetCallingAssembly();
if (!_waitingAssemblies.Contains(assembly))
Expand All @@ -84,17 +84,17 @@
}

/// <summary>
/// Register all menus in the <see cref="Assembly.GetCallingAssembly"/>.

Check warning on line 87 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Assembly'
/// </summary>
public static void RegisterAll() => Register(Assembly.GetCallingAssembly());

/// <summary>
/// Register all menus of indicated assembly.
/// </summary>
/// <param name="assembly">The target <see cref="Assembly"/>.</param>

Check warning on line 94 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Assembly'
private static void Register(Assembly assembly)

Check warning on line 95 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Method return value is never used (private accessibility)

Method 'Register' return value is never used
{
if (Plugin.StaticConfig is null) // plugin is not loaded.
if (Plugin.Instance.Config is null) // plugin is not loaded.
{
if (!_waitingAssemblies.Contains(assembly))
_waitingAssemblies.Enqueue(assembly);
Expand All @@ -109,7 +109,7 @@
if (type == typeof(AssemblyMenu)) // only used for comptability (throw error when loaded)
continue;

if (type == typeof(MainExample) && (!Plugin.StaticConfig.EnableExamples))
if (type == typeof(MainExample) && (!Plugin.Instance.Config.EnableExamples))
continue;

if (type.IsAbstract || type.IsInterface)
Expand Down Expand Up @@ -160,12 +160,12 @@
/// Register specific menu.
/// </summary>
/// <param name="menu">The target menu.</param>
/// <exception cref="ArgumentException">One of parameters of target menu is invalid. please check the <see cref="Exception.Message"/> to find the invalid parameter.</exception>

Check warning on line 163 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ArgumentException'

Check warning on line 163 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Exception'
public static void Register(Menu menu)
{
if (menu == null)
return;
if (menu.MenuRelated == typeof(MainExample) && !Plugin.StaticConfig.EnableExamples)
if (menu.MenuRelated == typeof(MainExample) && !Plugin.Instance.Config.EnableExamples)
return;

Log.Debug($"loading Server Specific menu {menu.Name}...");
Expand Down Expand Up @@ -251,7 +251,7 @@
/// Gets or Sets if this menu is related to a <see cref="MenuRelated"/> (will be shown as a SubMenu).
/// </summary>
#nullable enable
public virtual Type? MenuRelated { get; set; } = null;

Check warning on line 254 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property accessor is never used (non-private accessibility)

Auto-property accessor 'MenuRelated.set' is never used
#nullable disable

/// <summary>
Expand All @@ -259,7 +259,13 @@
/// </summary>
public abstract ServerSpecificSettingBase[] Settings { get; }

/// <summary>
/// <summary>
/// Gets all settings sent to the refHub. (only in the case of one GetSettings is not null or empty)
///
/// </summary>
internal readonly Dictionary<ReferenceHub, ServerSpecificSettingBase[]> SentSettings = new();

/// <summary>
/// Gets the Hash of menu, based on <see cref="Name"/>. Mainly used to seperate menu settings for client.
/// </summary>
public int Hash => Mathf.Abs(Name.GetHashCode() % 100000);
Expand All @@ -270,9 +276,9 @@
public abstract string Name { get; set; }

/// <summary>
/// Gets or Sets the description of Menu. Will be shown as <see cref="ServerSpecificSettingBase.HintDescription"/>.

Check warning on line 279 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
/// </summary>
protected virtual string Description { get; set; } = string.Empty;

Check warning on line 281 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Auto-property accessor is never used (non-private accessibility)

Auto-property accessor 'Description.set' is never used

/// <summary>
/// Gets or Sets the id of Menu. Must be above 0 and must not be equal to 0.
Expand All @@ -288,7 +294,7 @@
{
List<ServerSpecificSettingBase> mainMenu = new();

if (Plugin.StaticConfig.AllowPinnedContent)
if (Plugin.Instance.Config.AllowPinnedContent)
mainMenu.AddRange(Pinned.Values.SelectMany(pin => pin));

if (LoadedMenus.Where(x => x.CheckAccess(hub)).IsEmpty())
Expand All @@ -310,10 +316,10 @@
{
List<ServerSpecificSettingBase> settings = new();

if (Plugin.StaticConfig.AllowPinnedContent)
if (Plugin.Instance.Config.AllowPinnedContent)
settings.AddRange(Pinned.Values.SelectMany(pin => pin));

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.StaticConfig.ForceMainMenuEvenIfOnlyOne)
if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
{
if (MenuRelated != null)
settings.Add(new SSButton(0, string.Format(Plugin.GetTranslation().ReturnTo.Label, Menu.GetMenu(MenuRelated)?.Name ?? "Unknown"),
Expand All @@ -323,7 +329,7 @@
Plugin.GetTranslation().ReturnToMenu.ButtonText));
}

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) == this && !Plugin.StaticConfig.ForceMainMenuEvenIfOnlyOne)
if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) == this && !Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
settings.Add(new SSGroupHeader(Name));
else
{
Expand All @@ -334,7 +340,7 @@
foreach (Menu s in LoadedMenus.Where(x => x.MenuRelated == GetType() && x != this))
settings.Add(new SSButton(s.Id, string.Format(Plugin.GetTranslation().OpenMenu.Label, s.Name), Plugin.GetTranslation().OpenMenu.ButtonText, null, string.IsNullOrEmpty(Description) ? null : Description));

if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.StaticConfig.ForceMainMenuEvenIfOnlyOne)
if (LoadedMenus.First(x => x.CheckAccess(hub) && x.MenuRelated == null) != this || Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
settings.Add(new SSGroupHeader(Name, false, Description));

if (this is AssemblyMenu assemblyMenu &&
Expand All @@ -346,16 +352,17 @@
return settings;
}

if (Settings == null || Settings.IsEmpty())
ServerSpecificSettingBase[] oSettings = GetSettingsFor(hub);

if ((Settings == null || Settings.IsEmpty()) && (oSettings == null || oSettings.IsEmpty()))
{
settings.RemoveAt(settings.Count - 1);
return settings;
}

ServerSpecificSettingBase[] oSettings = GetSettingsFor(hub);
if (oSettings != null && !oSettings.IsEmpty())
if (Settings != null)
{
foreach (ServerSpecificSettingBase t in oSettings)
foreach (ServerSpecificSettingBase t in Settings)
{
if (t is ISetting setting)
settings.Add(setting.Base);
Expand All @@ -364,13 +371,21 @@
}
}

foreach (ServerSpecificSettingBase t in Settings)
if (oSettings != null && !oSettings.IsEmpty())
{
if (t is ISetting setting)
settings.Add(setting.Base);
else
settings.Add(t);
foreach (ServerSpecificSettingBase t in oSettings)
{
if (t is ISetting setting)
settings.Add(setting.Base);
else
settings.Add(t);
}

SentSettings[hub] = settings.ToArray();
}
else
SentSettings.Remove(hub);

return settings;
}

Expand Down Expand Up @@ -405,26 +420,26 @@
public virtual void OnInput(ReferenceHub hub, ServerSpecificSettingBase setting) {}

/// <summary>
/// Executed when <see cref="ReferenceHub"/> opened the menu.

Check warning on line 423 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">the target hub.</param>
protected virtual void ProperlyEnable(ReferenceHub hub) {}

/// <summary>
/// Executed when <see cref="ReferenceHub"/> closed the menu.

Check warning on line 429 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub.</param>
protected virtual void ProperlyDisable(ReferenceHub hub) {}

/// <summary>
/// Gets the loaded <see cref="ReferenceHub"/> menu. (menu that been displayed on the <see cref="ReferenceHub"/>).

Check warning on line 435 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'

Check warning on line 435 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub</param>
/// <returns><see cref="Menu"/> if <see cref="ReferenceHub"/> opened a menu, null if he was on the main menu.</returns>

Check warning on line 438 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
public static Menu GetCurrentPlayerMenu(ReferenceHub hub) => MenuSync.TryGetValue(hub, out Menu menu) ? menu : null;

/// <summary>
/// Load <see cref="Menu"/> for <see cref="ReferenceHub"/> (only if he has access).

Check warning on line 442 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub"></param>
/// <param name="menu"></param>
Expand All @@ -432,10 +447,10 @@
{
GetCurrentPlayerMenu(hub)?.ProperlyDisable(hub);
Log.Debug("try loading " + (menu?.Name ?? "main menu") + " for player " + hub.nicknameSync.MyNick);
if (menu != null && !menu.CheckAccess(hub))

Check warning on line 450 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
menu = null;

if (menu == null && LoadedMenus.Count(x => x.CheckAccess(hub) && x.MenuRelated == null) == 1 && !Plugin.StaticConfig.ForceMainMenuEvenIfOnlyOne)
if (menu == null && LoadedMenus.Count(x => x.CheckAccess(hub) && x.MenuRelated == null) == 1 && !Plugin.Instance.Config.ForceMainMenuEvenIfOnlyOne)
{
menu = Menus.First(x => x.CheckAccess(hub) && x.MenuRelated == null);
Log.Debug($"triggered The only menu registered: {menu.Name}.");
Expand All @@ -448,7 +463,7 @@
return;
}

List<ServerSpecificSettingBase> settings = menu.GetSettings(hub);

Check warning on line 466 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
settings.AddRange(GetGlobalKeybindings(hub, menu));
MenuSync[hub] = menu;

Expand Down Expand Up @@ -480,11 +495,11 @@
public Menu TryGetSubMenu(int id) => LoadedMenus.FirstOrDefault(x => x.Id == id && x.MenuRelated == GetType() && x != this);

/// <summary>
/// Gets the first keybind linked to <see cref="ServerSpecificSettingBase"/>.

Check warning on line 498 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
/// </summary>
/// <param name="hub">The target hub.</param>
/// <param name="ss">The specified <see cref="SSKeybindSetting"/> or <see cref="Keybind"/>.</param>

Check warning on line 501 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'SSKeybindSetting'
/// <param name="menu">The <see cref="ReferenceHub"/> current loaded menu, to get global or local keybinds.</param>

Check warning on line 502 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// <returns><see cref="Keybind"/> if found or not.</returns>
public static Keybind TryGetKeybinding(ReferenceHub hub, ServerSpecificSettingBase ss, Menu menu = null)
{
Expand All @@ -503,26 +518,26 @@

if (menu == null)
return null;
if (!menu.CheckAccess(hub))

Check warning on line 521 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Possible 'System.NullReferenceException'

Possible 'System.NullReferenceException'
return null;
return menu.Settings.FirstOrDefault(x => x.SettingId == id) as Keybind;
}

/// <summary>
/// Get a menu by <see cref="Type"/>.

Check warning on line 527 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Type'
/// </summary>
/// <param name="type">The type</param>
/// <returns><see cref="Menu"/> if found.</returns>
public static Menu GetMenu(Type type) => LoadedMenus.FirstOrDefault(x => x.GetType() == type);

/// <summary>
/// Reload the menu of the specified <see cref="ReferenceHub"/>.

Check warning on line 534 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub.</param>
public void Reload(ReferenceHub hub) => LoadForPlayer(hub, this);

/// <summary>
/// Reload all <see cref="ReferenceHub"/> that loaded the <see cref="Menu"/>.

Check warning on line 540 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
public void ReloadAll()
{
Expand All @@ -531,14 +546,14 @@
}

/// <summary>
/// Register <see cref="ServerSpecificSettingBase"/> that will be displayed on the top of all pages.

Check warning on line 549 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
/// </summary>
/// <param name="toPin">the list of <see cref="ServerSpecificSettingBase"/> to pin.</param>

Check warning on line 551 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
public static void RegisterPin(SSTextArea[] toPin) =>
Pinned[Assembly.GetCallingAssembly()] = toPin;

/// <summary>
/// Remove pins that was registered by <see cref="Assembly.GetCallingAssembly"/>.

Check warning on line 556 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Assembly'
/// </summary>
public static void UnregisterPin() => Pinned.Remove(Assembly.GetCallingAssembly());

Expand All @@ -548,9 +563,9 @@
protected virtual void OnRegistered(){}

/// <summary>
/// Get settings for the specific <see cref="ReferenceHub"/>

Check warning on line 566 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// <param name="hub">The target <see cref="ReferenceHub"/>.</param>

Check warning on line 567 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// <returns>A list of <see cref="ServerSpecificSettingBase"/> that will be sent into the player (like <see cref="Settings"/> but only for the <see cref="ReferenceHub"/>)</returns>

Check warning on line 568 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'

Check warning on line 568 in Features/Menu.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
/// </summary>
public virtual ServerSpecificSettingBase[] GetSettingsFor(ReferenceHub hub)
{
Expand Down
4 changes: 2 additions & 2 deletions Features/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
public static class Parameters
{
/// <summary>
/// Get synced parameter value for <see cref="ReferenceHub"/>.

Check warning on line 15 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub.</param>
/// <param name="settingId">The id of setting.</param>
/// <typeparam name="TMenu">The Menu to get parameter.</typeparam>
/// <typeparam name="TSs">The setting type.</typeparam>
/// <returns>An instance of <see cref="ServerSpecificSettingBase"/> That contains synecd value, or null if not found.</returns>

Check warning on line 21 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ServerSpecificSettingBase'
public static TSs GetParameter<TMenu, TSs>(this ReferenceHub hub, int settingId)
where TMenu : Menu
where TSs : ServerSpecificSettingBase
Expand All @@ -26,7 +26,7 @@
if (typeof(TSs).BaseType == typeof(ISetting))
{
Log.Error(nameof(TSs) + " need to be of base type (example: Plaintext became SSPlaintextSetting).");
return default;
return null;
}

foreach (Menu menu in Menu.Menus.Where(x => x is TMenu))
Expand All @@ -38,15 +38,15 @@
return t as TSs;
}

return default;
return null;
}


/// <summary>
/// Sync all paramters for all menus for <see cref="ReferenceHub"/>.

Check warning on line 46 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub</param>
/// <returns>a enumerator for <see cref="Timing.RunCoroutine(System.Collections.Generic.IEnumerator{float})"/></returns>.

Check warning on line 49 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'System'

Check warning on line 49 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Timing'
internal static IEnumerator<float> SyncAll(ReferenceHub hub)
{
SyncCache.Add(hub, new List<ServerSpecificSettingBase>());
Expand Down Expand Up @@ -129,10 +129,10 @@
internal static readonly Dictionary<ReferenceHub, List<ServerSpecificSettingBase>> SyncCache = new();

/// <summary>
/// Get ALL synced parameters from ALL menus for <see cref="ReferenceHub"/>

Check warning on line 132 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="referenceHub">The target hub.</param>
/// <returns>all synced parameters from ALL menus for <see cref="ReferenceHub"/>.</returns>

Check warning on line 135 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
public static List<ServerSpecificSettingBase> GetAllSyncedParameters(ReferenceHub referenceHub)
{
List<ServerSpecificSettingBase> toReturn = new();
Expand All @@ -156,12 +156,12 @@
}

/// <summary>
/// Sync all parameters from <see cref="Menu"/> for <see cref="ReferenceHub"/>.

Check warning on line 159 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'ReferenceHub'
/// </summary>
/// <param name="hub">The target hub.</param>
/// <param name="menu">The target menu.</param>
/// <param name="toSendWhenEnded">All parameters to send when ended.</param>
/// <returns>an enumerator for <see cref="Timing.RunCoroutine(System.Collections.Generic.IEnumerator{float})"/></returns>

Check warning on line 164 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'System'

Check warning on line 164 in Features/Parameters.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Cannot resolve reference in XML comment

Cannot resolve symbol 'Timing'
internal static IEnumerator<float> Sync(ReferenceHub hub, Menu menu, ServerSpecificSettingBase[] toSendWhenEnded)
{
SyncCache.Add(hub, new List<ServerSpecificSettingBase>());
Expand Down
2 changes: 1 addition & 1 deletion Patchs/CompatibilizerPatchs/Compatibilizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
[HarmonyPatch(typeof(ServerSpecificSettingsSync), nameof(ServerSpecificSettingsSync.DefinedSettings), MethodType.Setter)]
internal static class Compatibilizer
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions,

Check warning on line 19 in Patchs/CompatibilizerPatchs/Compatibilizer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Type member is never used (private accessibility)

Method 'Transpiler' is never used

Check warning on line 19 in Patchs/CompatibilizerPatchs/Compatibilizer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Unused parameter (private accessibility)

Parameter 'instructions' is never used
ILGenerator generator)

Check warning on line 20 in Patchs/CompatibilizerPatchs/Compatibilizer.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Unused parameter (private accessibility)

Parameter 'generator' is never used
{
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Shared.Rent();
newInstructions.InsertRange(0, new CodeInstruction[]
Expand All @@ -38,7 +38,7 @@

internal static void Load(ServerSpecificSettingBase[] settings)
{
if (!Plugin.StaticConfig.ComptabilitySystem.ComptabilityEnabled)
if (!Plugin.Instance.Config.ComptabilitySystem.ComptabilityEnabled)
return;
Assembly assembly = Assembly.GetCallingAssembly();
Log.Debug(assembly.GetName().Name + " tried to set " + nameof(ServerSpecificSettingsSync.DefinedSettings) + ". Game Assembly: " + typeof(ReferenceHub).Assembly.GetName().Name);
Expand Down
28 changes: 7 additions & 21 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
using LabApi.Events.CustomHandlers;
using SSMenuSystem.Features;
using UserSettings.ServerSpecific;
using Log = SSMenuSystem.Features.Log;

Check warning on line 7 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed
#if EXILED || LABAPI
using System;
#endif
#if EXILED
using Exiled.API.Features;
#elif NWAPI
using PluginAPI.Core;
#elif LABAPI
#else
using LabApi.Loader.Features.Plugins;
#endif

Expand All @@ -22,14 +18,11 @@
/// Load the plugin to send datas to player
/// </summary>
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin
#if EXILED || LABAPI
: Plugin<Config
public class Plugin : Plugin<Config
#if EXILED
, Translation
#endif
>
#endif
{
/// <summary>
/// Gets the author of the plugin.
Expand All @@ -44,17 +37,17 @@
/// <summary>
/// Gets the version of the plugin.
/// </summary>
public override Version Version => new(2, 0, 4);
public override Version Version => new(2, 0, 6);

#if EXILED
/// <inheritdoc/>

Check warning on line 43 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Usage of <inheritdoc /> is invalid

Usage of is invalid: No base candidate to inherit from
public override Version RequiredExiledVersion => new(9, 5, 0);

/// <summary>
/// Gets the prefix used for configs.
/// </summary>
public override string Prefix => "ss_menu_system";
#elif LABAPI
#else

/// <inheritdoc />
public override string Description => "Convert all Server-Specifics Settings created by plugins into menu. Help for multi-plugin comptability and organization.";
Expand All @@ -63,13 +56,6 @@
public override Version RequiredApiVersion => new(1, 0, 0);
#endif

private static Config _staticConfig;

/// <summary>
/// Gets the <see cref="Config"/> instance. Can be null if the plugin is not enabled.
/// </summary>
public static Config StaticConfig => _staticConfig ??= Instance?.Config;

/// <summary>
/// Gets the <see cref="Plugin"/> instance. can be null if the plugin is not enabled.
/// </summary>
Expand All @@ -78,7 +64,7 @@
private Harmony _harmony;

#if EXILED
/// <inheritdoc/>

Check warning on line 67 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Usage of <inheritdoc /> is invalid

Usage of is invalid: No base candidate to inherit from
public override void OnEnabled()
{
Exiled.Events.Handlers.Player.Verified += EventHandler.Verified;
Expand All @@ -86,10 +72,10 @@
Exiled.Events.Handlers.Player.ChangingGroup += EventHandler.ChangingGroup;
Exiled.Events.Handlers.Server.ReloadedConfigs += EventHandler.ReloadedConfigs;
GenericEnable();
base.OnEnabled();

Check warning on line 75 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant 'base.' qualifier

Qualifier 'base.' is redundant
}

/// <inheritdoc />

Check warning on line 78 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Usage of <inheritdoc /> is invalid

Usage of is invalid: No base candidate to inherit from
public override void OnDisabled()
{
Exiled.Events.Handlers.Player.Verified -= EventHandler.Verified;
Expand All @@ -104,10 +90,10 @@

Menu.UnregisterAll();

base.OnDisabled();

Check warning on line 93 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant 'base.' qualifier

Qualifier 'base.' is redundant
}

#elif LABAPI
#else

/// <inheritdoc />
public override void Enable()
Expand All @@ -132,7 +118,7 @@

}
#endif
private void GenericEnable()

Check warning on line 121 in Plugin.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Method return value is never used (private accessibility)

Method 'GenericEnable' return value is never used
{
Instance = this;
_harmony = new Harmony("fr.sky.patches");
Expand All @@ -143,7 +129,7 @@
#if DEBUG
Log.Warn("EXPERIMENTAL VERSION IS ACTIVATED. BE AWARD OF BUGS CAN BE DONE. NOT STABLE VERSION.");
Menu.RegisterPin(new[]{new SSTextArea(null, "this pinned content is related to the called assembly\nwith Menu.UnregisterPin() you just unregister ONLY pinned settings by the called assembly.", SSTextArea.FoldoutMode.CollapsedByDefault, "This is a pinned content.")});
StaticConfig.Debug = true;
Instance.Config!.Debug = true;
#endif

ServerSpecificSettingsSync.ServerOnSettingValueReceived += EventHandler.OnReceivingInput;
Expand All @@ -158,7 +144,7 @@
#if EXILED
return Instance?.Translation;
#else
return StaticConfig?.Translation;
return Instance.Config?.Translation;
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.4")]
[assembly: AssemblyVersion("2.0.6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
8 changes: 4 additions & 4 deletions SSMenuSystem-EXILED.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>SSMenuSystem</id>
<title>SS Menu System</title>
<version>2.0.4-EXILED</version>
<version>2.0.6-EXILED</version>
<authors>Sky</authors>
<owners>Sky</owners>
<copyright>Copyright © Sky 2025</copyright>
Expand All @@ -15,7 +15,7 @@

<dependencies>
<group targetFramework="net48">
<dependency id="ExMod.Exiled" version="[9.5.0]" />
<dependency id="ExMod.Exiled" version="[9.6.0-beta3]" />
</group>
</dependencies>

Expand All @@ -25,7 +25,7 @@
<!-- Project files -->
<file src="$(PACKAGE_REF)/Assembly-CSharp-Publicized.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/NorthwoodLib.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/PluginAPI.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/LabApi.dll" target="lib\net48" />
<file src="bin/Release EXILED/SSMenuSystem-EXILED.dll" target="lib\net48" />
<file src="bin/Release EXILED/SSMenuSystem-EXILED.xml" target="lib\net48" />
<file src="$(PACKAGE_REF)/Unity.TextMeshPro.dll" target="lib\net48" />
Expand All @@ -35,4 +35,4 @@
<!-- Project files -->
</files>

</package>
</package>
4 changes: 2 additions & 2 deletions SSMenuSystem-LABAPI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>SSMenuSystem</id>
<title>SS Menu System</title>
<version>2.0.4-LABAPI-BETA</version>
<version>2.0.6-LABAPI-Beta</version>
<authors>Sky</authors>
<owners>Sky</owners>
<copyright>Copyright © Sky 2025</copyright>
Expand All @@ -23,7 +23,7 @@
<!-- Project files -->
<file src="$(PACKAGE_REF)/Assembly-CSharp-Publicized.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/NorthwoodLib.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/PluginAPI.dll" target="lib\net48" />
<file src="$(PACKAGE_REF)/LabApi.dll" target="lib\net48" />
<file src="bin/Release LABAPI/SSMenuSystem-LABAPI.dll" target="lib\net48" />
<file src="bin/Release LABAPI/SSMenuSystem-LABAPI.xml" target="lib\net48" />
<file src="$(PACKAGE_REF)/Unity.TextMeshPro.dll" target="lib\net48" />
Expand Down
2 changes: 1 addition & 1 deletion SSMenuSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<Content Include="SSMenuSystem.ruleset" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ExMod.Exiled" Version="9.6.0-beta3" />
<PackageReference Include="ExMod.Exiled" Version="9.6.0-beta8" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
Loading
Loading