Skip to content

Commit

Permalink
Fix CustomItem
Browse files Browse the repository at this point in the history
  • Loading branch information
louis1706 committed Feb 7, 2024
1 parent 70543eb commit 6a4713c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 24 deletions.
6 changes: 3 additions & 3 deletions EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Exiled.API.Features.Doors;
using Exiled.API.Features.Items;
using Exiled.API.Features.Pickups;
using Exiled.Events.EventArgs.Interfaces;
using Exiled.Events.EventArgs.Item;
using Exiled.Events.EventArgs.Player;
using InventorySystem;
Expand Down Expand Up @@ -224,8 +225,9 @@ public void CustomGenerator()
generator.DeactivationTime = generator914Build.DeactivationTime.Value;
}
}
public void CustomItem(Item newItem)
public void CustomItem(IItemEvent ev)
{
Item newItem = ev.Item;
if (newItem is null || !plugin.Config.CustomItem.TryGetValue(newItem.Type, out ItemBuild itemBuild))
return;
foreach (KeyValuePair<string, string> e in itemBuild.Custom)
Expand All @@ -240,8 +242,6 @@ public void CustomItem(Item newItem)
object value = ItemBuild.Parse(e.Value, propertyInfo.PropertyType, out bool success);
if (success)
{
Log.Debug($"ItemType {newItem.Type} Key '{e.Key}'({propertyInfo.PropertyType}) Old {propertyInfo.GetValue(newItem)} => New '{e.Value}'");

propertyInfo.SetValue(newItem, value);
}
else
Expand Down
1 change: 0 additions & 1 deletion FacilityManagement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
<Compile Include="Patches\IntercomText\IntercomPatch.cs" />
<Compile Include="Main.cs" />
<Compile Include="Patches\IntercomText\NameFormaterPatch.cs" />
<Compile Include="Patches\NewItemConfig.cs" />
<Compile Include="Patches\RAUtilsAddon.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Exiled.Events.Handlers;
using HarmonyLib;
using InventorySystem;
using InventorySystem.Items;
using MEC;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -61,6 +62,8 @@ private void RegisterEvents()
Player.Hurting += EventHandlers.OnHurting;
if (Config.WarheadCleanup)
Warhead.Detonated += EventHandlers.OnDetonated;
if (Config.CustomItem is not null)
Player.ItemAdded += EventHandlers.CustomItem;
}
private void UnRegisterEvents()
{
Expand All @@ -73,6 +76,7 @@ private void UnRegisterEvents()
Player.Hurting -= EventHandlers.OnHurting;

Warhead.Detonated -= EventHandlers.OnDetonated;
Player.ItemAdded -= EventHandlers.CustomItem;

EventHandlers = null;
}
Expand Down
20 changes: 0 additions & 20 deletions Patches/NewItemConfig.cs

This file was deleted.

0 comments on commit 6a4713c

Please sign in to comment.