22
33using LabExtended . Commands . Attributes ;
44using LabExtended . Commands . Interfaces ;
5+ using LabExtended . Commands . Utilities ;
56
67namespace LabExtended . Commands . Custom . CustomAmmo ;
78
@@ -15,89 +16,65 @@ namespace LabExtended.Commands.Custom.CustomAmmo;
1516[ Command ( "customammo" , "Custom Ammo management." , "cammo" ) ]
1617public class CustomAmmoCommand : CommandBase , IServerSideCommand
1718{
18- /// <summary>
19- /// Displays the amount of custom ammo of a specified type in a player's inventory.
20- /// </summary>
21- /// <param name="ammoId">The identifier of the custom ammo type to query. Cannot be null or empty.</param>
22- /// <param name="target">The player whose inventory will be checked. If null, the command sender is used.</param>
2319 [ CommandOverload ( "get" , "Gets the amount of custom ammo in a player's inventory." , null ) ]
24- public void GetCommand (
20+ private void GetCommand (
2521 [ CommandParameter ( "ID" , "ID of the ammo." ) ] string ammoId ,
26- [ CommandParameter ( "Target " , "The target player ." ) ] ExPlayer ? target = null )
22+ [ CommandParameter ( "Targets " , "The target players ." ) ] List < ExPlayer > players )
2723 {
28- var player = target ?? Sender ;
29- var amount = player . Ammo . GetCustomAmmo ( ammoId ) ;
30-
31- Ok ( $ "Player \" { player . Nickname } \" ({ player . ClearUserId } ) has \" { amount } \" of ammo \" { ammoId } \" .") ;
24+ this . ForEachExecute ( players , player =>
25+ {
26+ var amount = player . Ammo . GetCustomAmmo ( ammoId ) ;
27+ return $ "&6{ ammoId } x&r of &6{ ammoId } &r";
28+ } ) ;
3229 }
3330
34- /// <summary>
35- /// Sets the specified amount of custom ammunition for a player.
36- /// </summary>
37- /// <param name="ammoId">The identifier of the custom ammo type to set. Cannot be null or empty.</param>
38- /// <param name="amount">The amount of ammo to set. Must be zero or greater.</param>
39- /// <param name="target">The player whose ammo will be set. If null, the command sender is used.</param>
4031 [ CommandOverload ( "set" , "Sets a specific amount of custom ammo in a player's inventory." , null ) ]
41- public void SetCommand (
32+ private void SetCommand (
4233 [ CommandParameter ( "ID" , "ID of the ammo." ) ] string ammoId ,
4334 [ CommandParameter ( "Amount" , "Amount to set." ) ] int amount ,
44- [ CommandParameter ( "Target " , "The target player ." ) ] ExPlayer ? target = null )
35+ [ CommandParameter ( "Targets " , "The target players ." ) ] List < ExPlayer > players )
4536 {
46- var player = target ?? Sender ;
47-
48- player . Ammo . SetCustomAmmo ( ammoId , amount ) ;
49-
50- Ok ( $ "Set ammo \" { ammoId } \" of player \" { player . Nickname } \" ( { player . ClearUserId } ) to \" { amount } \" ." ) ;
37+ this . ForEachExecute ( players , player =>
38+ {
39+ player . Ammo . SetCustomAmmo ( ammoId , amount ) ;
40+ return $ "&3 { ammoId } &r set to &3 { amount } &r" ;
41+ } ) ;
5142 }
5243
53- /// <summary>
54- /// Adds a specified amount of custom ammo to a player's inventory.
55- /// </summary>
56- /// <param name="ammoId">The identifier of the custom ammo type to add. Cannot be null or empty.</param>
57- /// <param name="amount">The number of ammo units to add. Must be greater than zero.</param>
58- /// <param name="target">The player who will receive the ammo. If null, the command sender is used.</param>
5944 [ CommandOverload ( "add" , "Adds a specific amount of custom ammo to a player's inventory." , null ) ]
60- public void AddCommand (
45+ private void AddCommand (
6146 [ CommandParameter ( "ID" , "ID of the ammo." ) ] string ammoId ,
6247 [ CommandParameter ( "Amount" , "Amount to add." ) ] int amount ,
63- [ CommandParameter ( "Target " , "The target player ." ) ] ExPlayer ? target = null )
48+ [ CommandParameter ( "Targets " , "The target players ." ) ] List < ExPlayer > players )
6449 {
65- var player = target ?? Sender ;
66- var current = player . Ammo . AddCustomAmmo ( ammoId , amount ) ;
67-
68- Ok ( $ "Added \" { amount } \" of ammo \" { ammoId } \" to player \" { player . Nickname } \" ({ player . ClearUserId } ), new amount: \" { current } \" .") ;
50+ this . ForEachExecute ( players , player =>
51+ {
52+ var newAmmo = player . Ammo . AddCustomAmmo ( ammoId , amount ) ;
53+ return $ "added &3{ amount } &r of &3{ ammoId } &r, now: &3{ newAmmo } &r";
54+ } ) ;
6955 }
7056
71- /// <summary>
72- /// Removes a specified amount of custom ammunition from a player's inventory.
73- /// </summary>
74- /// <param name="ammoId">The identifier of the custom ammo type to remove. Cannot be null or empty.</param>
75- /// <param name="amount">The number of ammo units to remove. Must be greater than zero.</param>
76- /// <param name="target">The player from whose inventory the ammo will be removed. If null, the command sender is used.</param>
77- [ CommandOverload ( "Remove" , "Removes a specific amount of custom ammo from a player's inventory." , null ) ]
78- public void RemoveCommand (
57+ [ CommandOverload ( "remove" , "Removes a specific amount of custom ammo from a player's inventory." , null ) ]
58+ private void RemoveCommand (
7959 [ CommandParameter ( "ID" , "ID of the ammo." ) ] string ammoId ,
8060 [ CommandParameter ( "Amount" , "Amount to remove." ) ] int amount ,
81- [ CommandParameter ( "Target " , "The target player ." ) ] ExPlayer ? target = null )
61+ [ CommandParameter ( "Targets " , "The target players ." ) ] List < ExPlayer > players )
8262 {
83- var player = target ?? Sender ;
84- var current = player . Ammo . RemoveCustomAmmo ( ammoId , amount ) ;
85-
86- Ok ( $ "Removed \" { amount } \" of ammo \" { ammoId } \" from player \" { player . Nickname } \" ({ player . ClearUserId } ), new amount: \" { current } \" .") ;
63+ this . ForEachExecute ( players , player =>
64+ {
65+ var newAmmo = player . Ammo . RemoveCustomAmmo ( ammoId , amount ) ;
66+ return $ "removed &3{ amount } &r of &3{ ammoId } &r, now: &3{ newAmmo } &r";
67+ } ) ;
8768 }
8869
89- /// <summary>
90- /// Removes all custom ammo from the specified player's inventory.
91- /// </summary>
92- /// <param name="target">The player whose custom ammo inventory will be cleared. If null, the command sender's inventory is cleared.</param>
9370 [ CommandOverload ( "clear" , "Removes all custom ammo from a player's inventory." , null ) ]
94- public void ClearCommand (
95- [ CommandParameter ( "Target " , "The target player ." ) ] ExPlayer ? target = null )
71+ private void ClearCommand (
72+ [ CommandParameter ( "Targets " , "The target players ." ) ] List < ExPlayer > players )
9673 {
97- var player = target ?? Sender ;
98-
99- player . Ammo . ClearCustomAmmo ( ) ;
100-
101- Ok ( $ "Cleared Custom Ammo inventory of \" { player . Nickname } \" ( { player . ClearUserId } )." ) ;
74+ this . ForEachExecute ( players , player =>
75+ {
76+ player . Ammo . ClearCustomAmmo ( ) ;
77+ return "&6all custom ammo cleared&r" ;
78+ } ) ;
10279 }
10380}
0 commit comments