diff --git a/EventHandler.cs b/EventHandler.cs
index 20045f4..f842d00 100644
--- a/EventHandler.cs
+++ b/EventHandler.cs
@@ -111,11 +111,14 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
Menu.LoadForPlayer(hub, menu.TryGetSubMenu(ss.SettingId));
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))
+ 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:
@@ -157,11 +160,11 @@ public static void OnReceivingInput(ReferenceHub hub, ServerSpecificSettingBase
#else
Log.Debug(e.ToString());
#endif
- if (Plugin.StaticConfig.ShowErrorToClient)
+ if (Plugin.Instance.Config.ShowErrorToClient)
{
Features.Utils.SendToPlayer(hub, null, new ServerSpecificSettingBase[]
{
- new SSTextArea(-5, $"{Plugin.GetTranslation().ServerError}\n{((hub.serverRoles.RemoteAdmin || Plugin.StaticConfig.ShowFullErrorToClient) && Plugin.StaticConfig.ShowFullErrorToModerators ? e.ToString() : Plugin.GetTranslation().NoPermission)}", SSTextArea.FoldoutMode.CollapsedByDefault, Plugin.GetTranslation().ServerError),
+ new SSTextArea(-5, $"{Plugin.GetTranslation().ServerError}\n{((hub.serverRoles.RemoteAdmin || Plugin.Instance.Config.ShowFullErrorToClient) && Plugin.Instance.Config.ShowFullErrorToModerators ? e.ToString() : Plugin.GetTranslation().NoPermission)}", SSTextArea.FoldoutMode.CollapsedByDefault, Plugin.GetTranslation().ServerError),
new SSButton(-999, Plugin.GetTranslation().ReloadButton.Label, Plugin.GetTranslation().ReloadButton.ButtonText)
});
}
diff --git a/Features/Log.cs b/Features/Log.cs
index 6de9f1b..4cbf9c6 100644
--- a/Features/Log.cs
+++ b/Features/Log.cs
@@ -30,7 +30,7 @@ internal static void Info(string message)
/// The message to be sent.
internal static void Debug(object message)
{
- if (Plugin.StaticConfig?.Debug ?? false)
+ if (Plugin.Instance.Config?.Debug ?? false)
Send($"[SSMenuSystem] {message}", LogLevel.Debug, ConsoleColor.Green);
}
@@ -41,7 +41,7 @@ internal static void Debug(object message)
/// The message to be sent.
internal static void Debug(string message)
{
- if (Plugin.StaticConfig?.Debug ?? false)
+ if (Plugin.Instance.Config?.Debug ?? false)
Send($"[SSMenuSystem] {message}", LogLevel.Debug, ConsoleColor.Green);
}
diff --git a/Features/Menu.cs b/Features/Menu.cs
index ee7b7ff..fb3548c 100644
--- a/Features/Menu.cs
+++ b/Features/Menu.cs
@@ -73,7 +73,7 @@ internal static void RegisterQueuedAssemblies()
///
public static void QueueOrRegister()
{
- if (Plugin.StaticConfig is null)
+ if (Plugin.Instance.Config is null)
{
Assembly assembly = Assembly.GetCallingAssembly();
if (!_waitingAssemblies.Contains(assembly))
@@ -94,7 +94,7 @@ public static void QueueOrRegister()
/// The target .
private static void Register(Assembly assembly)
{
- 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);
@@ -109,7 +109,7 @@ private static void Register(Assembly assembly)
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)
@@ -165,7 +165,7 @@ 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}...");
@@ -259,7 +259,13 @@ internal static void UnregisterAll()
///
public abstract ServerSpecificSettingBase[] Settings { get; }
- ///
+ ///
+ /// Gets all settings sent to the refHub. (only in the case of one GetSettings is not null or empty)
+ ///
+ ///
+ internal readonly Dictionary SentSettings = new();
+
+ ///
/// Gets the Hash of menu, based on . Mainly used to seperate menu settings for client.
///
public int Hash => Mathf.Abs(Name.GetHashCode() % 100000);
@@ -288,7 +294,7 @@ private static ServerSpecificSettingBase[] GetMainMenu(ReferenceHub hub)
{
List 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())
@@ -310,10 +316,10 @@ private List GetSettings(ReferenceHub hub)
{
List 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"),
@@ -323,7 +329,7 @@ private List GetSettings(ReferenceHub hub)
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
{
@@ -334,7 +340,7 @@ private List GetSettings(ReferenceHub hub)
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 &&
@@ -346,16 +352,17 @@ private List GetSettings(ReferenceHub hub)
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);
@@ -364,13 +371,21 @@ private List GetSettings(ReferenceHub hub)
}
}
- 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;
}
@@ -435,7 +450,7 @@ internal static void LoadForPlayer(ReferenceHub hub, Menu menu)
if (menu != null && !menu.CheckAccess(hub))
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}.");
diff --git a/Features/Parameters.cs b/Features/Parameters.cs
index 14573e5..543e6b1 100644
--- a/Features/Parameters.cs
+++ b/Features/Parameters.cs
@@ -26,7 +26,7 @@ public static TSs GetParameter(this ReferenceHub hub, int settingId)
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))
@@ -38,7 +38,7 @@ public static TSs GetParameter(this ReferenceHub hub, int settingId)
return t as TSs;
}
- return default;
+ return null;
}
diff --git a/Patchs/CompatibilizerPatchs/Compatibilizer.cs b/Patchs/CompatibilizerPatchs/Compatibilizer.cs
index b7f5f03..ef93b7b 100644
--- a/Patchs/CompatibilizerPatchs/Compatibilizer.cs
+++ b/Patchs/CompatibilizerPatchs/Compatibilizer.cs
@@ -38,7 +38,7 @@ private static IEnumerable Transpiler(IEnumerable
// ReSharper disable once ClassNeverInstantiated.Global
- public class Plugin
-#if EXILED || LABAPI
- : Plugin
-#endif
{
///
/// Gets the author of the plugin.
@@ -44,7 +37,7 @@ public class Plugin
///
/// Gets the version of the plugin.
///
- public override Version Version => new(2, 0, 4);
+ public override Version Version => new(2, 0, 6);
#if EXILED
///
@@ -54,7 +47,7 @@ public class Plugin
/// Gets the prefix used for configs.
///
public override string Prefix => "ss_menu_system";
-#elif LABAPI
+#else
///
public override string Description => "Convert all Server-Specifics Settings created by plugins into menu. Help for multi-plugin comptability and organization.";
@@ -63,13 +56,6 @@ public class Plugin
public override Version RequiredApiVersion => new(1, 0, 0);
#endif
- private static Config _staticConfig;
-
- ///
- /// Gets the instance. Can be null if the plugin is not enabled.
- ///
- public static Config StaticConfig => _staticConfig ??= Instance?.Config;
-
///
/// Gets the instance. can be null if the plugin is not enabled.
///
@@ -107,7 +93,7 @@ public override void OnDisabled()
base.OnDisabled();
}
-#elif LABAPI
+#else
///
public override void Enable()
@@ -143,7 +129,7 @@ private void GenericEnable()
#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;
@@ -158,7 +144,7 @@ public static Translation GetTranslation()
#if EXILED
return Instance?.Translation;
#else
- return StaticConfig?.Translation;
+ return Instance.Config?.Translation;
#endif
}
}
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 99b5ee4..130a590 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -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")]
\ No newline at end of file
diff --git a/SSMenuSystem-EXILED.nuspec b/SSMenuSystem-EXILED.nuspec
index 83d0600..ca7b86f 100644
--- a/SSMenuSystem-EXILED.nuspec
+++ b/SSMenuSystem-EXILED.nuspec
@@ -3,7 +3,7 @@
SSMenuSystem
SS Menu System
- 2.0.4-EXILED
+ 2.0.6-EXILED
Sky
Sky
Copyright © Sky 2025
@@ -15,7 +15,7 @@
-
+
@@ -25,7 +25,7 @@
-
+
@@ -35,4 +35,4 @@
-
\ No newline at end of file
+
diff --git a/SSMenuSystem-LABAPI.nuspec b/SSMenuSystem-LABAPI.nuspec
index ca6b494..3a17c17 100644
--- a/SSMenuSystem-LABAPI.nuspec
+++ b/SSMenuSystem-LABAPI.nuspec
@@ -3,7 +3,7 @@
SSMenuSystem
SS Menu System
- 2.0.4-LABAPI-BETA
+ 2.0.6-LABAPI-Beta
Sky
Sky
Copyright © Sky 2025
@@ -23,7 +23,7 @@
-
+
diff --git a/SSMenuSystem.csproj b/SSMenuSystem.csproj
index 085d100..9e82033 100644
--- a/SSMenuSystem.csproj
+++ b/SSMenuSystem.csproj
@@ -139,7 +139,7 @@
-
+