Skip to content

Commit 0a598f3

Browse files
authored
Merge pull request #5 from UncomplicatedCustomServer/dev-labapi
UCEZ v1.0.0 - First Release
2 parents 98aa49e + 72f9b2c commit 0a598f3

3 files changed

Lines changed: 35 additions & 7 deletions

File tree

UncomplicatedCustomEscapeZones/Config.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ internal class Config
1010
[Description(
1111
"If false 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!")]
1212
public bool EnableCreditTags { get; set; } = true;
13+
14+
[Description("Do enable the basic UCEZ logs?")]
15+
public bool EnableBasicLogs { get; set; } = true;
1316
}

UncomplicatedCustomEscapeZones/Events/EventHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public override void OnServerWaitingForPlayers()
110110

111111
foreach (ICustomEscapeZone customEscapeZone in CustomEscapeZone.List) new SummonedEscapeZone(customEscapeZone);
112112

113+
if (!Plugin.Instance.Config.EnableBasicLogs) return;
113114
LogManager.Info(
114115
$"Thanks for using UncomplicatedCustomEscapeZones v{Plugin.Instance.Version.ToString(3)} by {Plugin.Instance.Author}! Note that if you're using UCR, this plugin is the higher priority.",
115116
ConsoleColor.Blue);

UncomplicatedCustomEscapeZones/Intergrations/UCR.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,40 @@ public static bool TryGetSummonedCustomRole(Player player, out object summonedCu
8888
return false;
8989
}
9090

91-
if (SummonedCustomRole?.GetProperty("List", BindingFlags.Public | BindingFlags.Static)?.GetValue(null) is not
92-
IEnumerable list)
91+
object listObj = SummonedCustomRole?.GetProperty("List", BindingFlags.Public | BindingFlags.Static)?.GetValue(null);
92+
93+
if (listObj is not IEnumerable list)
9394
return false;
9495

95-
foreach (object scr in list)
96+
object[] entries = list.Cast<object>().ToArray();
97+
LogManager.Debug($"Found SummonedCustomRole.List with {entries.Length} entries.");
98+
99+
foreach (object entry in entries)
96100
{
97-
object scrPlayer = scr.GetType().GetProperty("Player")?.GetValue(scr);
98-
PropertyInfo playerIdProp = scrPlayer?.GetType().GetProperty("PlayerId");
99-
if (playerIdProp == null || playerIdProp.GetValue(scrPlayer)?.Equals(player.PlayerId) != true) continue;
100-
summonedCustomRole = scr;
101+
object candidate = entry;
102+
PropertyInfo valueProp = entry.GetType().GetProperty("Value");
103+
if (valueProp != null)
104+
{
105+
object value = valueProp.GetValue(entry);
106+
if (value != null)
107+
candidate = value;
108+
}
109+
110+
LogManager.Debug($"Examining entry candidate: {candidate}");
111+
112+
object scrPlayer = candidate.GetType().GetProperty("Player")?.GetValue(candidate);
113+
LogManager.Debug($"Player property value: {scrPlayer}");
114+
if (scrPlayer is null)
115+
continue;
116+
117+
PropertyInfo playerIdProp = scrPlayer.GetType().GetProperty("PlayerId");
118+
LogManager.Debug($"PlayerId property: {playerIdProp}");
119+
object idObj = playerIdProp?.GetValue(scrPlayer);
120+
LogManager.Debug($"Found PlayerId value: {idObj}");
121+
122+
if (idObj is not int foundId || foundId != player.PlayerId) continue;
123+
summonedCustomRole = candidate;
124+
LogManager.Debug($"Matched SummonedCustomRole for PlayerId {player.PlayerId}: {candidate}");
101125
return true;
102126
}
103127

0 commit comments

Comments
 (0)