Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updated ItemExtension & Missing Obsolete #409

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions EXILED/Exiled.API/Enums/ProjectileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Exiled.API.Enums
{
using System;

using Extensions;

/// <summary>
Expand Down Expand Up @@ -44,5 +46,26 @@ public enum ProjectileType
/// Used by <see cref="ItemType.SCP2176"/>.
/// </summary>
Scp2176,

/// <summary>
/// Coal.
/// Used by <see cref="ItemType.Coal"/>.
/// </summary>
[Obsolete("Only availaible for Christmas and AprilFools.")]
Coal,
louis1706 marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// SpecialCoal.
/// Used by <see cref="ItemType.SpecialCoal"/>.
/// </summary>
[Obsolete("Only availaible for Christmas and AprilFools.")]
SpecialCoal,
louis1706 marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Snowball.
/// Used by <see cref="ItemType.Snowball"/>.
/// </summary>
[Obsolete("Only availaible for Christmas.")]
Snowball,
louis1706 marked this conversation as resolved.
Show resolved Hide resolved
}
}
14 changes: 12 additions & 2 deletions EXILED/Exiled.API/Extensions/ItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static class ItemExtensions
/// </summary>
/// <param name="type">The item to be checked.</param>
/// <returns>Returns whether the <see cref="ItemType"/> is a throwable item.</returns>
public static bool IsThrowable(this ItemType type) => type is ItemType.SCP018 or ItemType.GrenadeHE or ItemType.GrenadeFlash or ItemType.SCP2176;
public static bool IsThrowable(this ItemType type) => type is ItemType.SCP018 or ItemType.GrenadeHE or ItemType.GrenadeFlash or ItemType.SCP2176 or ItemType.Coal or ItemType.SpecialCoal or ItemType.Snowball;

/// <summary>
/// Check if an <see cref="ItemType">item</see> is a medical item.
Expand Down Expand Up @@ -129,7 +129,7 @@ public static int GetMaxAmmo(this FirearmType item)
if (!InventoryItemLoader.AvailableItems.TryGetValue(item.GetItemType(), out ItemBase itemBase) || itemBase is not InventorySystem.Items.Firearms.Firearm firearm)
return 0;

return (firearm.Modules.FirstOrDefault(x => x is IAmmoContainerModule) as IAmmoContainerModule).AmmoMax;
return firearm.GetTotalMaxAmmo();
}

/// <summary>
Expand Down Expand Up @@ -234,6 +234,11 @@ public static int GetMaxAmmo(this FirearmType item)
ItemType.GrenadeHE => ProjectileType.FragGrenade,
ItemType.SCP018 => ProjectileType.Scp018,
ItemType.SCP2176 => ProjectileType.Scp2176,
#pragma warning disable CS0618
ItemType.Coal => ProjectileType.Coal,
ItemType.SpecialCoal => ProjectileType.SpecialCoal,
ItemType.Snowball => ProjectileType.Snowball,
#pragma warning restore CS0618
_ => ProjectileType.None,
};

Expand All @@ -248,6 +253,11 @@ public static int GetMaxAmmo(this FirearmType item)
ProjectileType.Scp018 => ItemType.SCP018,
ProjectileType.FragGrenade => ItemType.GrenadeHE,
ProjectileType.Scp2176 => ItemType.SCP2176,
#pragma warning disable CS0618
ProjectileType.Coal => ItemType.Coal,
ProjectileType.SpecialCoal => ItemType.SpecialCoal,
ProjectileType.Snowball => ItemType.Snowball,
#pragma warning restore CS0618
_ => ItemType.None,
};

Expand Down
1 change: 1 addition & 0 deletions EXILED/Exiled.API/Features/Coffee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Exiled.API.Features
/// <summary>
/// A wrapper for coffee cup.
/// </summary>
[Obsolete("Never available (for now).")]
public class Coffee : IWrapper<BaseCoffee>
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.API/Features/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ internal static void ClearCache()

#pragma warning disable CS0618
Scp559.CakeToWrapper.Clear();
#pragma warning restore CS0618

Coffee.BaseToWrapper.Clear();
#pragma warning restore CS0618
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

namespace Exiled.Events.EventArgs.Player
{
using System;

using Exiled.API.Features;
using Exiled.Events.EventArgs.Interfaces;

/// <summary>
/// Contains all information before player interacts with coffee cup.
/// </summary>
[Obsolete("Never available (for now).")]
public class DrinkingCoffeeEventArgs : IPlayerEvent, IDeniableEvent
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions EXILED/Exiled.Events/Handlers/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ public class Player
/// <summary>
/// Invoked before player interacts with coffee cup.
/// </summary>
[Obsolete("Never available (for now).")]
public static Event<DrinkingCoffeeEventArgs> DrinkingCoffee { get; set; } = new();

/// <summary>
Expand Down Expand Up @@ -1263,6 +1264,7 @@ public static void OnItemRemoved(ReferenceHub referenceHub, InventorySystem.Item
/// Called before player interacts with coffee cup.
/// </summary>
/// <param name="ev">The <see cref="DrinkingCoffeeEventArgs"/> instance.</param>
[Obsolete("Never available (for now).")]
public static void OnDrinkingCoffee(DrinkingCoffeeEventArgs ev) => DrinkingCoffee.InvokeSafely(ev);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Exiled.Events.Patches.Events.Player
{
#pragma warning disable CS0618 // Le type ou le membre est obsolète
using System.Collections.Generic;
using System.Reflection.Emit;

Expand Down
2 changes: 1 addition & 1 deletion EXILED/Exiled.Events/Patches/Generic/CoffeeListAdd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Exiled.Events.Patches.Generic
using Exiled.API.Features;
using HarmonyLib;
#pragma warning disable SA1313

#pragma warning disable CS0618
/// <summary>
/// Patches <see cref="global::Coffee.Start"/> to control coffee list.
/// </summary>
Expand Down
Loading