diff --git a/Exiled.CustomModules/API/Extensions/ItemExtensions.cs b/Exiled.CustomModules/API/Extensions/ItemExtensions.cs new file mode 100644 index 0000000000..11717265e7 --- /dev/null +++ b/Exiled.CustomModules/API/Extensions/ItemExtensions.cs @@ -0,0 +1,24 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomModules.API.Extensions +{ + using Exiled.API.Features.Items; + using Exiled.CustomModules.API.Features.CustomItems; + + /// + /// A set of extensions for . + /// + public static class ItemExtensions + { + /// + public static CustomItem Get(this Item item) => CustomItem.Get(item); + + /// + public static bool TryGet(this Item item, out CustomItem customItem) => CustomItem.TryGet(item, out customItem); + } +} \ No newline at end of file diff --git a/Exiled.CustomModules/API/Extensions/PickupExtensions.cs b/Exiled.CustomModules/API/Extensions/PickupExtensions.cs new file mode 100644 index 0000000000..97ec820f1a --- /dev/null +++ b/Exiled.CustomModules/API/Extensions/PickupExtensions.cs @@ -0,0 +1,24 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomModules.API.Extensions +{ + using Exiled.API.Features.Pickups; + using Exiled.CustomModules.API.Features.CustomItems; + + /// + /// A set of extensions for . + /// + public static class PickupExtensions + { + /// + public static CustomItem Get(this Pickup pickup) => CustomItem.Get(pickup); + + /// + public static bool TryGet(this Pickup pickup, out CustomItem item) => CustomItem.TryGet(pickup, out item); + } +} \ No newline at end of file diff --git a/Exiled.CustomModules/API/Extensions/PlayerExtensions.cs b/Exiled.CustomModules/API/Extensions/PlayerExtensions.cs new file mode 100644 index 0000000000..2cbfd65878 --- /dev/null +++ b/Exiled.CustomModules/API/Extensions/PlayerExtensions.cs @@ -0,0 +1,59 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Exiled Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomModules.API.Extensions +{ + using System; + + using Exiled.API.Features; + using Exiled.CustomModules.API.Features; + using Exiled.CustomModules.API.Features.CustomItems; + using Exiled.CustomModules.API.Features.CustomRoles; + + /// + /// A set of extensions for . + /// + public static class PlayerExtensions + { + /// + public static CustomRole Get(this Player player) => CustomRole.Get(player.Cast()); + + /// + public static bool Spawn(this Player player, CustomRole customRole, bool shouldKeepPosition = false) => CustomRole.Spawn(player.Cast(), customRole, shouldKeepPosition); + + /// + public static bool Spawn(this Player player) + where T : CustomRole => CustomRole.Spawn(player.Cast()); + + /// + public static bool Spawn(this Player player, string name, bool shouldKeepPosition = false) => CustomRole.Spawn(player.Cast(), name, shouldKeepPosition); + + /// + public static bool Spawn(this Player player, uint id, bool shouldKeepPosition = false) => CustomRole.Spawn(player.Cast(), id, shouldKeepPosition); + + /// + public static bool TrySpawn(this Player player, CustomRole customRole) => CustomRole.TrySpawn(player.Cast(), customRole); + + /// + public static bool TrySpawn(this Player player, string name) => CustomRole.TrySpawn(player.Cast(), name); + + /// + public static bool TrySpawn(this Player player, uint id) => CustomRole.TrySpawn(player.Cast(), id); + + /// + public static bool TryGet(this Player player, out CustomRole customRole) => CustomRole.TryGet(player.Cast(), out customRole); + + /// + public static bool TryGive(this Player player, string name, bool displayMessage = true) => CustomItem.TryGive(player, name, displayMessage); + + /// + public static bool TryGive(this Player player, uint id, bool displayMessage = true) => CustomItem.TryGive(player, id, displayMessage); + + /// + public static bool TryGive(this Player player, Type type, bool displayMessage) => CustomItem.TryGive(player, type, displayMessage); + } +} \ No newline at end of file diff --git a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs index bb45df341c..2e96580794 100644 --- a/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs +++ b/Exiled.CustomModules/API/Features/CustomRoles/CustomRole.cs @@ -517,6 +517,21 @@ public static bool Spawn(Pawn player, string name, bool shouldKeepPosition = fal return true; } + /// + /// Spawns the specified player with the custom role identified by the provided type. + /// + /// The type of custom role to be added. + /// The to be spawned. + /// + /// if the player was spawned with the custom role successfully; otherwise, . + /// + /// + /// This method add the custom role of type assigned to the specified player. + /// If the addition operation fails, the method returns . + /// + public static bool Spawn(Pawn player) + where T : CustomRole => TryGet(typeof(T), out CustomRole customRole) && customRole.Spawn(player); + /// /// Removes the custom role from the specified player. ///