Skip to content

Commit 9b9c9f9

Browse files
committed
Small fixes
1 parent d5677dd commit 9b9c9f9

8 files changed

Lines changed: 26 additions & 18 deletions

File tree

UncomplicatedCustomItems.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.0.11010.61 d18.0
4+
VisualStudioVersion = 18.0.11010.61
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UncomplicatedCustomItems", "UncomplicatedCustomItems\UncomplicatedCustomItems.csproj", "{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}"
77
EndProject

UncomplicatedCustomItems/API/Features/Manager/HttpManager.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Exiled.API.Interfaces;
33
using Exiled.Loader;
44
#endif
5+
using CentralAuth;
56
using LabApi.Events.Arguments.PlayerEvents;
67
using LabApi.Features;
78
using LabApi.Features.Wrappers;
@@ -329,6 +330,9 @@ internal HttpStatusCode ShareLogs(string data, out HttpContent httpContent)
329330
/// </summary>
330331
public void StartPresence(int intervalSeconds = 60)
331332
{
333+
if (!CustomNetworkManager.IsVerified || !PlayerAuthenticationManager.OnlineMode || CentralServer.Abort)
334+
return;
335+
332336
LogManager.Debug("Starting UCI API Presence");
333337
if (string.IsNullOrWhiteSpace(UCIAPIEndpoint))
334338
throw new ArgumentException("Presence Worker Url required", nameof(UCIAPIEndpoint));
@@ -385,7 +389,7 @@ private async Task TrackPresenceResult(Task<bool> presenceTask)
385389
try
386390
{
387391
bool success = await presenceTask;
388-
392+
389393
if (success)
390394
{
391395
_presenceFailureCount = 0;
@@ -473,7 +477,7 @@ internal async Task<bool> SendPresenceOnceAsync()
473477
showOnList = Plugin.Instance.Config.ShowOnuciList.ToString(),
474478
plugins = pluginNames,
475479
exiled = hasExiled.ToString().ToLower(),
476-
extra = $"PlayerCount: {Server.PlayerCount}, MaxPlayers: {Server.MaxPlayers}, Idling: {Server.IdleModeActive}"
480+
extra = $"PlayerCount: {Player.ReadyList.Where(p => p.IsReady && p.IsPlayer).Count()}, MaxPlayers: {Server.MaxPlayers}, Idling: {Server.IdleModeActive}"
477481
};
478482

479483
string json = JsonConvert.SerializeObject(payload);

UncomplicatedCustomItems/API/Toolgun/Settings.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ public static void GiveToPlayers()
2323

2424
ServerSpecificSettingsSync.SendOnJoinFilter = (_) => false;
2525
ServerSpecificSettingsSync.DefinedSettings = _settings.ToArray();
26-
ServerSpecificSettingsSync.SendToPlayersConditionally(x => Utilities.TryGetSummonedCustomItem(x.inventory.CurInstance.ItemSerial, out var item) && item.HasModule(CustomFlags.ToolGun));
27-
Timing.RunCoroutine(ResetSettings());
26+
Timing.CallDelayed(1, () => ServerSpecificSettingsSync.SendToPlayersConditionally(x => Utilities.TryGetSummonedCustomItem(x.inventory.CurInstance.ItemSerial, out var item) && item.HasModule(CustomFlags.ToolGun)));
2827
}
2928

3029
internal static IEnumerator<float> ResetSettings()
3130
{
3231
for (; ; )
3332
{
3433
ResetPlayer();
35-
yield return 5f;
34+
yield return 1f;
3635
}
3736
}
3837

UncomplicatedCustomItems/API/Utilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static bool CustomItemValidator(ICustomItem item, out string error)
4242
case CustomItemType.Item:
4343
if (item.CustomData is null)
4444
{
45-
error = $"The item has been flagged as 'Item' but the CustomData class is not 'IData', found '{item.CustomData.GetType().Name}' The CustomData formatting is incorrect. \n Please follow the format found here: https://discord.com/channels/1170301876990914631/1339667038750244979";
45+
error = $"The item has been flagged as 'Item' but the CustomData class is not 'IData', found '{item.CustomData.GetType().Name}' The CustomData formatting is incorrect. \n Please follow the format found here: https://discord.com/channels/1170301876990914631/1339667038750244979";
4646
return false;
4747
}
4848

UncomplicatedCustomItems/Commands/Admin/ToolGun.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public bool Execute(List<string> arguments, ICommandSender sender, out string re
2727

2828
if (arguments.Count == 1)
2929
{
30-
Player target = Player.Get(arguments[0]);
30+
Player target = Player.Get(int.Parse(arguments[0]));
3131
if (target is null)
3232
{
3333
response = "Player not found!";

UncomplicatedCustomItems/Intergrations/MER.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ public static void Init()
2929
{
3030
Found = true;
3131
plugin.TryGetLoadedAssembly(out MERAssembly);
32+
break;
3233
}
3334
}
3435

35-
if (Found)
36+
if (Found && MERAssembly != null)
3637
{
3738
LogManager.Silent($"MER Found! :D");
3839
Register();
@@ -49,7 +50,7 @@ private static void Register()
4950
LogManager.Debug($"MER SchematicSpawned Event Triggered");
5051
string name = obj?.GetType().GetProperty("Name")?.GetValue(obj)?.ToString() ?? "<unknown>";
5152
object schematicObject = obj?.GetType().GetProperty("Schematic")?.GetValue(obj);
52-
53+
5354
foreach (CustomItem item in CustomItem.List)
5455
{
5556
if (item.HasModule(CustomFlags.MERSpawn))
@@ -86,7 +87,7 @@ private static void Register()
8687

8788
internal static void Unregister()
8889
{
89-
EventToken.Unregister();
90+
EventToken?.Unregister();
9091
}
9192

9293
private static List<Locker> GetLockers(object schematicObj)

UncomplicatedCustomItems/Plugin.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
// Events
2727
using PlayerEvent = LabApi.Events.Handlers.PlayerEvents;
2828
using ServerEvent = LabApi.Events.Handlers.ServerEvents;
29+
using MEC;
30+
using UncomplicatedCustomItems.API.ToolGun;
2931

3032
// Building for remote development. You can ignore this :)
3133
// & "C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\MSBuild.exe" UncomplicatedCustomItems.csproj /p:Configuration=LabApi
@@ -44,7 +46,7 @@ public class Plugin : Plugin<Config>
4446
#endif
4547
public override string Author => "SpGerg, FoxWorn & Mr. Baguetter";
4648
#if EXILED
47-
public override Version RequiredExiledVersion { get; } = new(9, 8, 1);
49+
public override Version RequiredExiledVersion { get; } = new(9, 9, 1);
4850
#else
4951
public override Version RequiredApiVersion { get; } = LabApi.Features.LabApiProperties.CurrentVersion;
5052
#endif
@@ -252,6 +254,7 @@ public override void Disable()
252254
base.OnDisabled();
253255
#endif
254256
}
257+
255258
public void OnFinishedLoading()
256259
{
257260
HttpManager.StartPresence();
@@ -265,6 +268,7 @@ public void OnFinishedLoading()
265268
LabAPIExtensions.Init();
266269
MERIntergration.Init();
267270
ECRIntegration.Init();
271+
Timing.RunCoroutine(Settings.ResetSettings());
268272
#if EXILED
269273
CommonUtilitiesPatch.Initialize();
270274
#endif

UncomplicatedCustomItems/UncomplicatedCustomItems.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@
102102
</Reference>
103103
<Reference Include="0Harmony, Version=2.2.2.0, Culture=neutral, processorArchitecture=MSIL">
104104
<SpecificVersion>False</SpecificVersion>
105-
<HintPath>..\..\..\..\Downloads\EXILED_REFERENCES\0Harmony.dll</HintPath>
105+
<HintPath>$(EXILED_REFERENCES)\0Harmony.dll</HintPath>
106106
</Reference>
107107
<Reference Include="LabApi-Publicized">
108-
<HintPath>..\..\..\..\Downloads\EXILED_REFERENCES\LabApi-Publicized.dll</HintPath>
108+
<HintPath>$(EXILED_REFERENCES)\LabApi-Publicized.dll</HintPath>
109109
</Reference>
110110
<Reference Include="Mirror-Publicized">
111-
<HintPath>..\..\..\..\Downloads\EXILED_REFERENCES\Mirror-Publicized.dll</HintPath>
111+
<HintPath>$(EXILED_REFERENCES)\Mirror-Publicized.dll</HintPath>
112112
</Reference>
113113
<Reference Include="NorthwoodLib, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
114114
<SpecificVersion>False</SpecificVersion>
115115
<HintPath>$(EXILED_REFERENCES)\NorthwoodLib.dll</HintPath>
116116
</Reference>
117117
<Reference Include="Assembly-CSharp-Publicized, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
118118
<SpecificVersion>False</SpecificVersion>
119-
<HintPath>..\..\..\..\Downloads\Release\Assembly-CSharp-Publicized.dll</HintPath>
119+
<HintPath>$(EXILED_REFERENCES)\Assembly-CSharp-Publicized.dll</HintPath>
120120
</Reference>
121121
<Reference Include="Microsoft.CSharp" />
122122
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
@@ -151,10 +151,10 @@
151151
</Reference>
152152
<Reference Include="Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
153153
<SpecificVersion>False</SpecificVersion>
154-
<HintPath>..\..\..\Release\Mono.Security.dll</HintPath>
154+
<HintPath>$(EXILED_REFERENCES)\Mono.Security.dll</HintPath>
155155
</Reference>
156156
<Reference Include="NorthwoodLib">
157-
<HintPath>..\..\..\..\Downloads\EXILED_REFERENCES\NorthwoodLib.dll</HintPath>
157+
<HintPath>$(EXILED_REFERENCES)\NorthwoodLib.dll</HintPath>
158158
</Reference>
159159
<Reference Include="NVorbis">
160160
<HintPath>$(EXILED_REFERENCES)\NVorbis.dll</HintPath>

0 commit comments

Comments
 (0)