Skip to content

Commit d2cc4ea

Browse files
committed
Fixed ServerProcessKillPostfix
Fixed SCP207 HumeShieldPatches Postfix Fixed Reload Command
1 parent 0c02b8f commit d2cc4ea

9 files changed

Lines changed: 73 additions & 75 deletions

File tree

UncomplicatedCustomItems.sln

Lines changed: 3 additions & 3 deletions
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.3.11222.16 d18.3
4+
VisualStudioVersion = 18.3.11222.16
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UncomplicatedCustomItems", "UncomplicatedCustomItems\UncomplicatedCustomItems.csproj", "{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}"
77
EndProject
@@ -17,8 +17,8 @@ Global
1717
Release|x64 = Release|x64
1818
EndGlobalSection
1919
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20-
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|Any CPU.ActiveCfg = LabApi|Any CPU
21-
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|Any CPU.Build.0 = LabApi|Any CPU
20+
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|Any CPU.ActiveCfg = Exiled|Any CPU
21+
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|Any CPU.Build.0 = Exiled|Any CPU
2222
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|x64.ActiveCfg = LabApi|x64
2323
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Debug|x64.Build.0 = LabApi|x64
2424
{B39EE633-0EFE-42FC-B3E8-C6C4C86029E5}.Exiled|Any CPU.ActiveCfg = Exiled|Any CPU

UncomplicatedCustomItems/API/Extensions/FirearmItemExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public static bool TryApplyAttachment(this FirearmPickup firearmPickup, Attachme
8484
if (firearm == null)
8585
return false;
8686

87+
firearm.ItemSerial = firearmPickup.Info.Serial;
8788
AttachmentCodeSync.ServerSetCode(firearmPickup.Info.Serial, AttachmentsUtils.GetRandomAttachmentsCode(firearmPickup.Info.ItemId));
8889
bool success = TryApplyAttachment(firearm, name);
8990
if (success && firearm.WorldModel != null)

UncomplicatedCustomItems/Commands/Admin/Reload.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public bool Execute(List<string> arguments, ICommandSender sender, out string re
4242
response = "This command doesnt have any arguments";
4343
return false;
4444
}
45+
4546
if (CustomItem.List.Count == 0)
4647
{
4748
response = $"No loaded custom items!";
4849
return false;
4950
}
51+
5052
if (CustomItem.List.Count > 0)
5153
{
5254
CustomItems.Clear();
@@ -57,8 +59,11 @@ public bool Execute(List<string> arguments, ICommandSender sender, out string re
5759
ReloadedActions = 0;
5860
ReloadedAPIItems = 0;
5961

60-
foreach (SummonedCustomItem item in SummonedCustomItem.List.ToList())
62+
foreach (SummonedCustomItem item in SummonedCustomItem.List.ToArray())
6163
{
64+
if (item is null)
65+
continue;
66+
6267
if (item.Owner != null && !CustomItems.ContainsKey(item.Owner))
6368
CustomItems[item.Owner] = [];
6469

@@ -67,7 +72,7 @@ public bool Execute(List<string> arguments, ICommandSender sender, out string re
6772

6873
if (!item.IsPickup)
6974
CustomItems[item.Owner].Add(item.CustomItem);
70-
else if (item.Pickup.Position != null)
75+
else if (item.IsPickup && item.Pickup.Position != null && item.Pickup.Position != Vector3.zero)
7176
CustomItemsPickups[item.CustomItem].Add(item.Pickup.Position);
7277

7378
item.Destroy();

UncomplicatedCustomItems/Commands/BaseCommand.cs

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,45 +48,56 @@ public override void LoadGeneratedCommands()
4848

4949
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)
5050
{
51-
if (arguments.Count == 0)
51+
try
5252
{
53-
response = $"UncomplicatedCustomItems v{Plugin.Instance.Version} by FoxWorn3365, SpGerg & Mr. Baguetter\n\n<size=35>Available commands:</size>";
54-
foreach (ISubcommand command in Subcommands)
55-
response += $"\n- uci {command.Name}{(command.VisibleArgs != string.Empty ? $" {command.VisibleArgs}" : "")} - {command.Description}";
53+
if (arguments.Count == 0)
54+
{
55+
response = $"UncomplicatedCustomItems v{Plugin.Instance.Version} by FoxWorn3365, SpGerg & Mr. Baguetter\n\n<size=35>Available commands:</size>";
56+
foreach (ISubcommand command in Subcommands)
57+
response += $"\n- uci {command.Name}{(command.VisibleArgs != string.Empty ? $" {command.VisibleArgs}" : "")} - {command.Description}";
5658

57-
return true;
58-
}
59+
return true;
60+
}
5961

60-
ISubcommand cmd = Subcommands.FirstOrDefault(cmd => cmd.Name == arguments.At(0));
62+
ISubcommand cmd = Subcommands.FirstOrDefault(cmd => cmd.Name == arguments.At(0));
6163

62-
cmd ??= Subcommands.FirstOrDefault(cmd => cmd.Aliases.Contains(arguments.At(0)));
64+
cmd ??= Subcommands.FirstOrDefault(cmd => cmd.Aliases.Contains(arguments.At(0)));
6365

64-
if (cmd is null)
65-
{
66-
response = "Command not found!";
67-
return false;
68-
}
66+
if (cmd is null)
67+
{
68+
response = "Command not found!";
69+
return false;
70+
}
6971
#if EXILED
70-
if (!sender.CheckPermission(cmd.RequiredPermission))
72+
if (!sender.CheckPermission(cmd.RequiredPermission))
7173
#else
72-
if (!sender.HasPermissions(cmd.RequiredPermission))
74+
if (!sender.HasPermissions(cmd.RequiredPermission))
7375
#endif
76+
{
77+
response = "You don't have permission to access that command! \n Required permission: {cmd.RequiredPermission}";
78+
return false;
79+
}
7480

75-
{
76-
response = "You don't have permission to access that command! \n Required permission: {cmd.RequiredPermission}";
77-
return false;
78-
}
81+
if (arguments.Count < cmd.RequiredArgsCount)
82+
{
83+
response = $"Wrong usage!\nCorrect usage: uci {cmd.Name} {cmd.VisibleArgs}";
84+
return false;
85+
}
86+
87+
List<string> args = [.. arguments];
88+
args.RemoveAt(0);
7989

80-
if (arguments.Count < cmd.RequiredArgsCount)
90+
return cmd.Execute(args, sender, out response);
91+
}
92+
catch (Exception ex)
8193
{
82-
response = $"Wrong usage!\nCorrect usage: uci {cmd.Name} {cmd.VisibleArgs}";
94+
ISubcommand cmd = Subcommands.FirstOrDefault(cmd => cmd.Name == arguments.At(0));
95+
cmd ??= Subcommands.FirstOrDefault(cmd => cmd.Aliases.Contains(arguments.At(0)));
96+
97+
LogManager.Error($"Error when running command {cmd.Name} \n\n {ex.Message} \n\n {ex.StackTrace}");
98+
response = $"Error when running command {cmd.Name} \n\n {ex.Message} \n\n {ex.StackTrace}";
8399
return false;
84100
}
85-
86-
List<string> args = [.. arguments];
87-
args.RemoveAt(0);
88-
89-
return cmd.Execute(args, sender, out response);
90101
}
91102
}
92103
}

UncomplicatedCustomItems/HarmonyElements/Patches/CustomItemPatches/SCP127/HumeShieldPatches.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public static class HumeShieldPatches
1515
[HarmonyPatch("HsMax", MethodType.Getter)]
1616
public static void Postfix(Scp127HumeModule __instance, ref float __result)
1717
{
18+
if (__instance is null || __instance.Item is null)
19+
return;
20+
1821
if (APICustomItem.TryGet(__instance.Item.ItemSerial, out var item2) && item2 is CustomSCP127 custom127)
1922
{
2023
try

UncomplicatedCustomItems/HarmonyElements/Patches/CustomItemPatches/SCP1509/Revive.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class Revive
1414
{
1515
[HarmonyPatch(nameof(Scp1509Item.ServerProcessKill))]
1616
[HarmonyPostfix]
17-
public static void ServerProcessKill_Postfix(Scp1509Item __instance, ReferenceHub ply)
17+
public static void ServerProcessKillPostfix(Scp1509Item __instance, ReferenceHub victim)
1818
{
1919
if (Utilities.TryGetSummonedCustomItem(__instance.ItemSerial, out var item) && item.CustomItem.CustomData is SCP1509Data data)
2020
{

UncomplicatedCustomItems/Plugin.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
// Events
3232
using ServerEvent = LabApi.Events.Handlers.ServerEvents;
33+
using System.Linq;
3334

3435
// Building for remote development. You can ignore this :)
3536
// & "C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\MSBuild.exe" UncomplicatedCustomItems.csproj /p:Configuration=LabApi
@@ -52,17 +53,15 @@ public class Plugin : Plugin<Config>
5253
#else
5354
public override Version RequiredApiVersion { get; } = LabApi.Features.LabApiProperties.CurrentVersion;
5455
#endif
55-
public override Version Version { get; } = new(4, 0, 2);
56+
public override Version Version { get; } = new(4, 0, 3);
5657

5758
public Assembly Assembly => Assembly.GetExecutingAssembly();
5859
#if EXILED
5960
public override PluginPriority Priority => PluginPriority.First;
6061
#else
6162
public override LoadPriority Priority => LoadPriority.Highest;
6263
#endif
63-
/// <summary>
64-
/// The <see cref="Plugin"/> instance.
65-
/// </summary>
64+
6665
public static Plugin Instance { get; private set; }
6766

6867
internal Harmony _harmony;
@@ -83,6 +82,21 @@ public override void Enable()
8382
FileConfig = new();
8483
HttpManager = new("uci");
8584

85+
try
86+
{
87+
#if EXILED
88+
_harmony = new($"com.ucs.uci_exiled-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
89+
#else
90+
_harmony = new($"com.ucs.uci_labapi-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
91+
#endif
92+
_harmony.PatchAll();
93+
LogManager.Debug($"Successfully enabled {_harmony.GetPatchedMethods().Count()} patches");
94+
}
95+
catch (HarmonyException ex)
96+
{
97+
LogManager.Error($"Failed to enable patches! \n\n {ex.Message} \n\n {ex.StackTrace}");
98+
}
99+
86100
PlayerHandler.Register();
87101
ServerHandler.Register();
88102
ScpHandler.Register();
@@ -144,12 +158,6 @@ public override void Enable()
144158
FileConfig.LoadAll(Server.Port.ToString());
145159
FileConfig.LoadAll("Actions");
146160

147-
#if EXILED
148-
_harmony = new($"com.ucs.uci_exiled-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
149-
#else
150-
_harmony = new($"com.ucs.uci_labapi-{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}");
151-
#endif
152-
_harmony.PatchAll();
153161
#if EXILED
154162
if (Round.IsStarted)
155163
#else

UncomplicatedCustomItems/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
//
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
33-
[assembly: AssemblyVersion("4.0.0")]
34-
[assembly: AssemblyFileVersion("4.0.0")]
33+
[assembly: AssemblyVersion("4.0.3")]
34+
[assembly: AssemblyFileVersion("4.0.3")]

UncomplicatedCustomItems/UncomplicatedCustomItems.csproj

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
1313
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
1414
<Configurations>Debug;Release;Exiled;LabApi</Configurations>
15+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
1516
</PropertyGroup>
1617

1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
@@ -23,21 +24,6 @@
2324
<ErrorReport>prompt</ErrorReport>
2425
<WarningLevel>4</WarningLevel>
2526
<PlatformTarget>x64</PlatformTarget>
26-
<DocumentationFile>..\..\..\..\AppData\Roaming\EXILED\Plugins\UncomplicatedCustomItems.xml</DocumentationFile>
27-
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
28-
</PropertyGroup>
29-
30-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Exiled|x64'">
31-
<DebugSymbols>true</DebugSymbols>
32-
<DebugType>full</DebugType>
33-
<Optimize>true</Optimize>
34-
<OutputPath>bin\Debug\</OutputPath>
35-
<DefineConstants>DEBUG;TRACE</DefineConstants>
36-
<ErrorReport>prompt</ErrorReport>
37-
<WarningLevel>4</WarningLevel>
38-
<PlatformTarget>x64</PlatformTarget>
39-
<DocumentationFile>..\..\..\..\AppData\Roaming\EXILED\Plugins\UncomplicatedCustomItems.xml</DocumentationFile>
40-
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
4127
</PropertyGroup>
4228

4329
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
@@ -48,16 +34,6 @@
4834
<ErrorReport>prompt</ErrorReport>
4935
<WarningLevel>4</WarningLevel>
5036
<PlatformTarget>x64</PlatformTarget>
51-
<DocumentationFile>bin\x64\Release\UncomplicatedCustomItems.xml</DocumentationFile>
52-
<DebugSymbols>true</DebugSymbols>
53-
</PropertyGroup>
54-
55-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64' and '$(OutputPath)' == '' ">
56-
<OutputPath>bin\x64\Debug\</OutputPath>
57-
</PropertyGroup>
58-
59-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Exiled|x64' and '$(OutputPath)' == ''">
60-
<OutputPath>bin\x64\Debug\</OutputPath>
6137
</PropertyGroup>
6238

6339
<PropertyGroup Condition=" '$(Configuration)' == 'LabApi' ">
@@ -76,12 +52,6 @@
7652
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7753
</PropertyGroup>
7854

79-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'LabApi|AnyCPU'">
80-
<DebugType>embedded</DebugType>
81-
<DebugSymbols>true</DebugSymbols>
82-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
83-
</PropertyGroup>
84-
8555
<ItemGroup>
8656
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.*" />
8757
</ItemGroup>

0 commit comments

Comments
 (0)