Skip to content

Commit 4f3aaad

Browse files
committed
ready for the official release of v5.0.0
1 parent 5a786cc commit 4f3aaad

17 files changed

Lines changed: 133 additions & 23 deletions

UncomplicatedCustomRoles/API/Features/CustomRole.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class CustomRole : ICustomRole
2525
/// </summary>
2626
public static List<ICustomRole> List => CustomRoles.Values.ToList();
2727

28+
/// <summary>
29+
/// Gets a list of every not loaded custom role.
30+
/// The data is the Id, the role path, the error type and the error name
31+
/// </summary>
32+
internal static List<Tuple<string, string, string, string>> NotLoadedRoles { get; } = new();
33+
2834
/// <summary>
2935
/// Gets or sets the <see cref="ICustomRole"/> unique Id
3036
/// </summary>

UncomplicatedCustomRoles/API/Features/SummonedCustomRole.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
using System.Linq;
99
using UncomplicatedCustomRoles.API.Enums;
1010
using UncomplicatedCustomRoles.API.Features.CustomModules;
11-
using UncomplicatedCustomRoles.API.Features.CustomModules.ItemBan;
1211
using UncomplicatedCustomRoles.API.Interfaces;
1312
using UncomplicatedCustomRoles.API.Struct;
1413
using UncomplicatedCustomRoles.Commands;
1514
using UncomplicatedCustomRoles.Manager;
1615

16+
// Sashimi <3
17+
1718
namespace UncomplicatedCustomRoles.API.Features
1819
{
1920
#pragma warning disable IDE1006 // Stili di denominazione
@@ -162,8 +163,6 @@ internal SummonedCustomRole(Player player, ICustomRole role, Triplet<string, str
162163

163164
EvaluateRoleBase();
164165

165-
ItemBanBase.CheckInventoryAll(this);
166-
167166
EventHandler = new(this);
168167
List.Add(this);
169168
}
@@ -284,7 +283,7 @@ private IEnumerator<float> CoroutineRoleCoroutine()
284283
/// Parse the current <see cref="SummonedCustomRole"/> instance as a RemoteAdmin text part
285284
/// </summary>
286285
/// <returns></returns>
287-
internal string ParseRemoteAdmin() => $"\n<size=26><color=#f55505>UncomplicatedCustomRoles</color></size>\nCustom Role: <color={Exiled.API.Extensions.RoleExtensions.GetColor(Role.Role).ToHex()}>{Role.Name}</color> [Id={Role.Id}]{LoadRoleFlags()}\n{LoadBadge()}";
286+
internal string ParseRemoteAdmin() => $"\n\n<size=26><color=#f55505>UncomplicatedCustomRoles</color></size>\nCustom Role: ({Role.Id}) <color={Exiled.API.Extensions.RoleExtensions.GetColor(Role.Role).ToHex()}>{Role.Name}</color>{LoadRoleFlags()}\n{LoadBadge()}";
288287

289288
private string LoadRoleFlags()
290289
{
@@ -315,7 +314,7 @@ private string LoadBadge()
315314
if (SpawnManager.colorMap.ContainsKey(Role.BadgeColor))
316315
output += $"<color={SpawnManager.colorMap[Role.BadgeColor]}>{Role.BadgeName}</color>";
317316
else
318-
output += $"{Role.BadgeName}";
317+
output += $"{Role.BadgeName.Replace("@hidden", "")}";
319318
else
320319
output += "None";
321320

UncomplicatedCustomRoles/Commands/CommandParent.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Exiled.Permissions.Extensions;
55
using System.Linq;
66
using UncomplicatedCustomRoles.API.Interfaces;
7+
using UncomplicatedCustomRoles.Manager.NET;
8+
using UncomplicatedCustomRoles.Manager;
79

810
namespace UncomplicatedCustomRoles.Commands
911
{
@@ -28,6 +30,7 @@ public override void LoadGeneratedCommands()
2830
RegisteredCommands.Add(new SpawnPoint());
2931
RegisteredCommands.Add(new Generate());
3032
RegisteredCommands.Add(new Show());
33+
RegisteredCommands.Add(new Version());
3134
}
3235

3336
public List<IUCRCommand> RegisteredCommands { get; } = new();
@@ -37,7 +40,7 @@ protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSe
3740
if (arguments.Count() == 0)
3841
{
3942
// Help page
40-
response = $"\n>> UncomplicatedCustomRoles v{Plugin.Instance.Version} <<\nby {Plugin.Instance.Author}\n\nAvailable commands:";
43+
response = $"\n>> UncomplicatedCustomRoles v{Plugin.Instance.Version}{(VersionManager.VersionInfo.CustomName is not null ? $" '{VersionManager.VersionInfo.CustomName}'" : string.Empty)} <<\nby {Plugin.Instance.Author}\n\nAvailable commands:";
4144

4245
foreach (IUCRCommand Command in RegisteredCommands)
4346
{

UncomplicatedCustomRoles/Commands/List.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using CommandSystem;
2+
using Exiled.API.Extensions;
3+
using System;
24
using System.Collections.Generic;
5+
using System.Linq;
36
using UncomplicatedCustomRoles.API.Features;
47
using UncomplicatedCustomRoles.API.Interfaces;
58

@@ -13,14 +16,23 @@ public class List : IUCRCommand
1316

1417
public string RequiredPermission { get; } = "ucr.list";
1518

19+
public const int TitleSize = 23;
20+
21+
public const int TextSize = 15;
22+
23+
public const string Spacing = " ";
24+
1625
public bool Executor(List<string> arguments, ICommandSender sender, out string response)
1726
{
1827
response = "List of all registered CustomRoles:";
1928
foreach (KeyValuePair<int, ICustomRole> Role in CustomRole.CustomRoles)
2029
{
21-
response += $"\n[{Role.Key}] '{Role.Value.Name}' ({Role.Value.Role})";
30+
response += $"\n<size={TitleSize}>✔ [{Role.Key}] <color={Role.Value.Role.GetColor().ToHex()}>{Role.Value.Name}</color></size>\n <size={TextSize}>Role: {Role.Value.Role} ({Role.Value.Team ?? Role.Value.Role.GetTeam()})\n{Spacing}HP: {Role.Value.Health.Amount}/{Role.Value.Health.Maximum}\n{Spacing}Custom info: {Role.Value.CustomInfo}\n{Spacing}Can escape: {Role.Value.CanEscape}\n{Spacing}Inventory: {string.Join(", ", Role.Value.Inventory)}\n{Spacing}Spawn: {Role.Value.SpawnSettings.Spawn} [{string.Join(", ", Role.Value.SpawnSettings.SpawnRooms)}] [{string.Join(", ", Role.Value.SpawnSettings.SpawnZones)}] [{string.Join(", ", Role.Value.SpawnSettings.SpawnPoints)}] ({Role.Value.SpawnSettings.SpawnChance}%)</size>\n";
2231
}
2332

33+
foreach (Tuple<string, string, string, string> tuple in CustomRole.NotLoadedRoles)
34+
response += $"\n<size={TitleSize}>❌ [{tuple.Item1}] <color=red>{tuple.Item2.Split('/').Last()}</color></size>\n <size={TextSize}>Path: {tuple.Item2}\n{Spacing}Error: <color=red>{tuple.Item4}</color></size>\n";
35+
2436
return true;
2537
}
2638
}

UncomplicatedCustomRoles/Commands/Reload.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public bool Executor(List<string> arguments, ICommandSender sender, out string r
2727
// Create a copy of the custom roles Dictionary
2828
Dictionary<int, ICustomRole> Roles = new();
2929

30+
CustomRole.NotLoadedRoles.Clear();
31+
3032
Plugin.FileConfigs.LoadAction((CustomRole Role) =>
3133
{
3234
if (!CustomRole.Validate(Role))
@@ -52,7 +54,7 @@ public bool Executor(List<string> arguments, ICommandSender sender, out string r
5254

5355
Plugin.FileConfigs.LoadAction((CustomRole Role) =>
5456
{
55-
if (!API.Features.CustomRole.Validate(Role))
57+
if (!CustomRole.Validate(Role))
5658
{
5759
LogManager.Warn($"[RL] Failed to register the UCR role with the ID {Role.Id} due to the validator check!");
5860
return;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using CommandSystem;
2+
using System.Collections.Generic;
3+
using UncomplicatedCustomRoles.API.Interfaces;
4+
using UncomplicatedCustomRoles.Manager;
5+
6+
namespace UncomplicatedCustomRoles.Commands
7+
{
8+
public class Version : IUCRCommand
9+
{
10+
public string Name { get; } = "list";
11+
12+
public string Description { get; } = "List all registered custom roles";
13+
14+
public string RequiredPermission { get; } = "ucr.list";
15+
16+
public const int TitleSize = 23;
17+
18+
public const int TextSize = 15;
19+
20+
public const string Spacing = " ";
21+
22+
public bool Executor(List<string> arguments, ICommandSender sender, out string response)
23+
{
24+
if (VersionManager.VersionInfo is null)
25+
{
26+
response = "Can't load VersionManager.VersionInfo: Failed to GET HTTPS";
27+
return false;
28+
}
29+
30+
response = $"<size=22><b>UncomplicatedCustomRoles</b></size>\n<size=18>Authors: {Plugin.Instance.Author}\nVersion: {VersionManager.VersionInfo.Name}{(VersionManager.VersionInfo.CustomName is not null ? $" '{VersionManager.VersionInfo.CustomName}'" : string.Empty)} ({Plugin.Instance.Version})\nSource: {VersionManager.VersionInfo.Source} - {VersionManager.VersionInfo.SourceLink ?? string.Empty}\nPre release: {(VersionManager.VersionInfo.PreRelease ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nForced debug: {(VersionManager.VersionInfo.ForceDebug ? "<color=red>TRUE</color>" : "<color=green>FALSE</color>")}\nHash: {(!VersionManager.CorrectHash ? "<color=red>NOT MATCHING!</color>" : "<color=green>Matching</color>")}</size>";
31+
32+
if (!VersionManager.CorrectHash)
33+
response += "\n\n<size=20><b><color=red>⚠ WARNING!</color></b></size>\n<size=18>You are using a <b>NON-OFFICIAL</b> version of the plugin!\nThis version might contain <b>viruses</b> and it's <b>NOT</b> ours!</size>";
34+
35+
if (!VersionManager.VersionInfo.Recall)
36+
response += $"\n\n<size=20><b><color=red>⚠ WARNING!</color></b></size>\n<size=18>This version has been <b>RECALLED</b> due to the following reason:\n<size=16>{VersionManager.VersionInfo.RecallReason}</size>\nYou are <b>HIGHLY SUGGESTED</b> to update the plugin to the last stable target: {VersionManager.VersionInfo.RecallTarget} {(VersionManager.VersionInfo.RecallImportant ?? true ? $"\n<color=red>You HAVE TO update it, otherwise bad things will happen!</color>" : string.Empty)}</size>";
37+
38+
return true;
39+
}
40+
}
41+
}

UncomplicatedCustomRoles/Config.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ internal class Config : IConfig
2424
[Description("If true the UCS credit tag system won't be activated. PLEASE DON'T DEACTIVATE IT as LOTS OF PEOPLE WORKED ON THIS PLUGIN completly for FREE!")]
2525
public bool EnableCreditTags { get; set; } = false;
2626

27+
[Description("Whether the NPCs can naturally spawn custom roles")]
28+
public bool IgnoreNpcs { get; set; } = true;
29+
2730
[Description("Whether you want your spawnpoints to be hosted inside our central server or locally in the configs folder")]
2831
public bool LocalSpawnPoints { get; set; } = false;
2932

UncomplicatedCustomRoles/Events/EventHandler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void OnChangingRole(ChangingRoleEventArgs ev)
165165
return;
166166

167167

168-
if (ev.Player.IsNPC)
168+
if (Plugin.Instance.Config.IgnoreNpcs && ev.Player.IsNPC)
169169
return;
170170

171171
if (Started || !FirstRoundPlayers.Contains(ev.Player.Id))
@@ -349,9 +349,12 @@ public void OnItemUsed(UsedItemEventArgs ev)
349349

350350
public void OnAddingTarget(AddingTargetEventArgs ev)
351351
{
352+
if (!ev.IsAllowed)
353+
return;
354+
352355
if (ev.Target.TryGetSummonedInstance(out SummonedCustomRole summonedInstance))
353356
{
354-
if (ev.Player.ReferenceHub.GetTeam() is Team.SCPs)
357+
if (ev.Target.ReferenceHub.GetTeam() is Team.SCPs)
355358
ev.IsAllowed = false;
356359

357360
if (summonedInstance.HasModule<DoNotTrigger096>())

UncomplicatedCustomRoles/Extensions/PlayerExtension.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public static void ApplyCustomInfoAndRoleName(this Player player, string customI
153153
{
154154
player.ReferenceHub.nicknameSync.Network_playerInfoToShow |= PlayerInfoArea.CustomInfo;
155155
player.ReferenceHub.nicknameSync.Network_playerInfoToShow &= ~PlayerInfoArea.Role; // Hide role
156+
player.ReferenceHub.nicknameSync.Network_playerInfoToShow &= ~PlayerInfoArea.Nickname; // Hide nickname
156157

157158
if (role.Contains("</"))
158159
LogManager.Error($"Failed to apply CustomInfo with Role name at PlayerExtension::ApplyCustomInfoAndRoleName(%Player, string, string): role name can't contains any end tag like </color>, </b>, </size> etc...!\nCustomInfo won't be applied to player {player.Nickname} ({player.Id}) -- Found: {role}");
@@ -162,11 +163,14 @@ public static void ApplyCustomInfoAndRoleName(this Player player, string customI
162163

163164
if (customInfo is null || customInfo.Length < 1)
164165
{
165-
player.ReferenceHub.nicknameSync.Network_playerInfoToShow &= ~PlayerInfoArea.CustomInfo;
166-
player.ReferenceHub.nicknameSync.Network_customPlayerInfoString = $"{role}";
166+
LogManager.Silent("Applying only role name (order: NICK-ROLE)");
167+
player.ReferenceHub.nicknameSync.Network_customPlayerInfoString = $"{player.DisplayNickname}\n{role}";
167168
}
168169
else
169-
player.ReferenceHub.nicknameSync.Network_customPlayerInfoString = $"{role}\n{ProcessCustomInfo(customInfo)}";
170+
{
171+
LogManager.Silent("Applying role name and custom info (CI-NICK-ROLE)");
172+
player.ReferenceHub.nicknameSync.Network_customPlayerInfoString = $"{ProcessCustomInfo(customInfo)}\n{player.DisplayNickname}\n{role}";
173+
}
170174
}
171175

172176
/// <summary>

UncomplicatedCustomRoles/Manager/FileConfigs.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public void LoadAction(Action<CustomRole> action, string localDir = "")
5454
}
5555
catch (Exception ex)
5656
{
57+
// Add the role to the not-loaded list
58+
CustomRole.NotLoadedRoles.Add(new(TryGetRoleId(File.ReadAllText(FileName)), FileName, ex.GetType().Name, ex.Message));
59+
5760
if (!Plugin.Instance.Config.Debug)
5861
LogManager.Error($"Failed to parse {FileName}. YAML Exception: {ex.Message}.");
5962
else
@@ -98,5 +101,14 @@ public void Welcome(string localDir = "")
98101
LogManager.Info($"Plugin does not have a role folder, generated one in {Path.Combine(Dir, localDir)}");
99102
}
100103
}
104+
105+
public static string TryGetRoleId(string content)
106+
{
107+
string[] pieces = content.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
108+
109+
if (pieces.Contains("id:"))
110+
return pieces.FirstOrDefault(l => l.Contains("id:")).Replace(" ", "").Replace("id:", "");
111+
return "ND";
112+
}
101113
}
102114
}

0 commit comments

Comments
 (0)