diff --git a/RainbowTags - Nebuli/Config.cs b/RainbowTags - Nebuli/Config.cs index 52946f8..61a3273 100644 --- a/RainbowTags - Nebuli/Config.cs +++ b/RainbowTags - Nebuli/Config.cs @@ -8,6 +8,7 @@ public class Config : IConfiguration { public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; + public bool GroupSpecificSequences { get; set; } = false; [Description("Tags Configuration")] public float ColorInterval { get; set; } = 0.5f; @@ -28,4 +29,12 @@ public class Config : IConfiguration "silver", "crimson" }; + + public Dictionary> GroupSequences { get; set; } = new Dictionary> + { + { "owner", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } }, + { "moderator", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } }, + { "admin", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } } + }; + } \ No newline at end of file diff --git a/RainbowTags - Nebuli/MainClass.cs b/RainbowTags - Nebuli/MainClass.cs index 80a668d..0eba415 100644 --- a/RainbowTags - Nebuli/MainClass.cs +++ b/RainbowTags - Nebuli/MainClass.cs @@ -1,5 +1,4 @@ -using InventorySystem.Items.Usables; -using Nebuli.API.Features; +using Nebuli.API.Features; using Nebuli.API.Features.Player; using Nebuli.Events.EventArguments.Player; using Nebuli.Events.Handlers; @@ -17,6 +16,7 @@ public class MainClass : Plugin public override string Name => "RainbowTags"; public override Version Version { get; } = new(1, 0, 2); public override Version NebuliVersion { get; } = new(0, 0, 0); + public override bool SkipVersionCheck { get; } = true; public static List PlayersWithoutRTags { get; } = new(); @@ -39,6 +39,17 @@ private bool TryGetColors(string rank, out string[] availableColors) availableColors = Config.Sequences; return !string.IsNullOrEmpty(rank) && Config.RanksWithRTags.Contains(rank); } + + private bool TryGetCustomColors(string rank, out string[] availableColors) + { + if (Config.GroupSequences[rank] == null) + { + availableColors = null; + return false; + } + availableColors = Config.GroupSequences[rank].ToArray(); + return !string.IsNullOrEmpty(rank) && Config.RanksWithRTags.Contains(rank); + } private bool EqualsTo(UserGroup thisGroup, UserGroup otherGroup) { return thisGroup.BadgeColor == otherGroup.BadgeColor && thisGroup.BadgeText == otherGroup.BadgeText && @@ -57,19 +68,41 @@ private string GetGroupKey(UserGroup group) } private void OnChangingGroup(PlayerChangingUserGroupEvent ev) { - if (!PlayersWithoutRTags.Contains(ev.Player) && ev.Group != null && ev.Player.Group == null && TryGetColors(GetGroupKey(ev.Group), out var colors)) + if (ev.Player == null || ev.Group == null) return; + + if (Config.GroupSpecificSequences) { - Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); - var rtController = ev.Player.GameObject.AddComponent(); - rtController.Colors = colors; - rtController.Interval = Config.ColorInterval; - return; + if (!PlayersWithoutRTags.Contains(ev.Player) && ev.Group != null && ev.Player.Group == null && TryGetCustomColors(GetGroupKey(ev.Group), out var colors)) + { + Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); + var rtController = ev.Player.GameObject.AddComponent(); + rtController.Colors = colors; + rtController.Interval = Config.ColorInterval; + return; + } + if (TryGetColors(GetGroupKey(ev.Group), out colors)) + { + ev.Player.GameObject.GetComponent().Colors = colors; + return; + } + Object.Destroy(ev.Player.GameObject.GetComponent()); } - if (TryGetColors(GetGroupKey(ev.Group), out colors)) + else { - ev.Player.GameObject.GetComponent().Colors = colors; - return; - } - Object.Destroy(ev.Player.GameObject.GetComponent()); + if (!PlayersWithoutRTags.Contains(ev.Player) && ev.Group != null && ev.Player.Group == null && TryGetColors(GetGroupKey(ev.Group), out var colors)) + { + Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); + var rtController = ev.Player.GameObject.AddComponent(); + rtController.Colors = colors; + rtController.Interval = Config.ColorInterval; + return; + } + if (TryGetColors(GetGroupKey(ev.Group), out colors)) + { + ev.Player.GameObject.GetComponent().Colors = colors; + return; + } + Object.Destroy(ev.Player.GameObject.GetComponent()); + } } } \ No newline at end of file diff --git a/RainbowTags/Config.cs b/RainbowTags/Config.cs index c61cadb..6b0d802 100644 --- a/RainbowTags/Config.cs +++ b/RainbowTags/Config.cs @@ -8,6 +8,7 @@ public class Config : IConfig { public bool IsEnabled { get; set; } = true; public bool Debug { get; set; } = false; + public bool GroupSpecificSequences { get; set; } = false; [Description("Tags Configuration")] public float ColorInterval { get; set; } = 0.5f; @@ -28,4 +29,11 @@ public class Config : IConfig "silver", "crimson" }; + + public Dictionary> GroupSequences { get; set; } = new Dictionary> + { + { "owner", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } }, + { "moderator", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } }, + { "admin", new List() { "red", "orange", "yellow", "green", "blue_green", "magenta", "silver", "crimson" } } + }; } \ No newline at end of file diff --git a/RainbowTags/MainClass.cs b/RainbowTags/MainClass.cs index adbd0a0..c5ad87d 100644 --- a/RainbowTags/MainClass.cs +++ b/RainbowTags/MainClass.cs @@ -37,6 +37,17 @@ private bool TryGetColors(string rank, out string[] availableColors) availableColors = Config.Sequences; return !string.IsNullOrEmpty(rank) && Config.RanksWithRTags.Contains(rank); } + + private bool TryGetCustomColors(string rank, out string[] availableColors) + { + if (Config.GroupSequences[rank] == null) + { + availableColors = null; + return false; + } + availableColors = Config.GroupSequences[rank].ToArray(); + return !string.IsNullOrEmpty(rank) && Config.RanksWithRTags.Contains(rank); + } private bool EqualsTo(UserGroup thisGroup, UserGroup otherGroup) { return thisGroup.BadgeColor == otherGroup.BadgeColor && thisGroup.BadgeText == otherGroup.BadgeText && @@ -55,19 +66,39 @@ private string GetGroupKey(UserGroup group) } private void OnChangingGroup(ChangingGroupEventArgs ev) { - if (!PlayersWithoutRTags.Contains(ev.Player) && ev.NewGroup != null && ev.Player.Group == null && TryGetColors(GetGroupKey(ev.NewGroup), out var colors)) + if (Config.GroupSpecificSequences) { - Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); - var rtController = ev.Player.GameObject.AddComponent(); - rtController.Colors = colors; - rtController.Interval = Config.ColorInterval; - return; + if (!PlayersWithoutRTags.Contains(ev.Player) && ev.NewGroup != null && ev.Player.Group == null && TryGetCustomColors(GetGroupKey(ev.NewGroup), out var colors)) + { + Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); + var rtController = ev.Player.GameObject.AddComponent(); + rtController.Colors = colors; + rtController.Interval = Config.ColorInterval; + return; + } + if (TryGetColors(GetGroupKey(ev.NewGroup), out colors)) + { + ev.Player.GameObject.GetComponent().Colors = colors; + return; + } + Object.Destroy(ev.Player.GameObject.GetComponent()); } - if (TryGetColors(GetGroupKey(ev.NewGroup), out colors)) + else { - ev.Player.GameObject.GetComponent().Colors = colors; - return; + if (!PlayersWithoutRTags.Contains(ev.Player) && ev.NewGroup != null && ev.Player.Group == null && TryGetColors(GetGroupKey(ev.NewGroup), out var colors)) + { + Log.Debug("RainbowTags: Added to " + ev.Player.Nickname); + var rtController = ev.Player.GameObject.AddComponent(); + rtController.Colors = colors; + rtController.Interval = Config.ColorInterval; + return; + } + if (TryGetColors(GetGroupKey(ev.NewGroup), out colors)) + { + ev.Player.GameObject.GetComponent().Colors = colors; + return; + } + Object.Destroy(ev.Player.GameObject.GetComponent()); } - Object.Destroy(ev.Player.GameObject.GetComponent()); } } \ No newline at end of file