Skip to content

Commit 08a0f53

Browse files
committed
Command fixes
1 parent 765ebb6 commit 08a0f53

39 files changed

Lines changed: 77 additions & 68 deletions

LabExtended/Commands/Attributes/CommandOverloadAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CommandOverloadAttribute : Attribute
2626
/// <summary>
2727
/// Creates a new <see cref="CommandOverloadAttribute"/> instance.
2828
/// </summary>
29-
public CommandOverloadAttribute(string description = "No description", string? permission = null)
29+
public CommandOverloadAttribute(string? description, string? permission)
3030
{
3131
isDefaultOverload = true;
3232

@@ -40,7 +40,7 @@ public CommandOverloadAttribute(string description = "No description", string? p
4040
/// <param name="name">Name of the overload.</param>
4141
/// <param name="description">Description of the overload.</param>
4242
/// <param name="permission">Sets the permission required to invoke the overload.</param>
43-
public CommandOverloadAttribute(string name, string description = "No description", string? permission = null)
43+
public CommandOverloadAttribute(string name, string? description, string? permission)
4444
{
4545
Name = name;
4646
Description = description;

LabExtended/Commands/CommandManager.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public static List<CommandData> RegisterCommands(this Assembly assembly)
104104
if (method.IsStatic)
105105
continue;
106106

107+
var overloadDescription = string.Empty;
108+
107109
foreach (var commandOverloadAttribute in method.GetCustomAttributes<CommandOverloadAttribute>(false))
108110
{
109111
if (method.ReturnType != typeof(void)
@@ -120,7 +122,13 @@ public static List<CommandData> RegisterCommands(this Assembly assembly)
120122

121123
overload.Name = commandOverloadAttribute.Name;
122124
overload.Permission = commandOverloadAttribute.Permission;
123-
overload.Description = commandOverloadAttribute.Description;
125+
126+
if (overloadDescription == string.Empty && commandOverloadAttribute.Description?.Length > 0)
127+
overloadDescription = commandOverloadAttribute.Description;
128+
129+
overload.Description = commandOverloadAttribute.Description?.Length > 0
130+
? commandOverloadAttribute.Description
131+
: overloadDescription;
124132

125133
if (commandOverloadAttribute.isDefaultOverload)
126134
{

LabExtended/Commands/Custom/Attachments/AttachmentsCommand.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class AttachmentsCommand : CommandBase, IServerSideCommand
2121
/// <summary>
2222
/// Randomizes all attachments.
2323
/// </summary>
24-
[CommandOverload("random", "Randomizes all attachments of a firearm.")]
24+
[CommandOverload("random", "Randomizes all attachments of a firearm.", null)]
2525
public void Random(ushort firearmSerial)
2626
{
2727
if (!InventoryExtensions.ServerTryGetItemWithSerial(firearmSerial, out var item)
@@ -39,7 +39,7 @@ public void Random(ushort firearmSerial)
3939
/// <summary>
4040
/// Clears all attachments.
4141
/// </summary>
42-
[CommandOverload("clear", "Clears all attachments on a firearm.")]
42+
[CommandOverload("clear", "Clears all attachments on a firearm.", null)]
4343
public void Clear(ushort firearmSerial)
4444
{
4545
if (!InventoryExtensions.ServerTryGetItemWithSerial(firearmSerial, out var item)
@@ -61,7 +61,7 @@ public void Clear(ushort firearmSerial)
6161
/// <summary>
6262
/// Disables selected attachments.
6363
/// </summary>
64-
[CommandOverload("disable", "Disables a list of attachments on a firearm.")]
64+
[CommandOverload("disable", "Disables a list of attachments on a firearm.", null)]
6565
public void Disable(
6666
[CommandParameter("Serial", "The serial of the target firearm.")] ushort firearmSerial,
6767
[CommandParameter("Attachments", "List of attachments to disable.")] List<AttachmentName> attachments)
@@ -85,7 +85,7 @@ public void Disable(
8585
/// <summary>
8686
/// Enables selected attachments.
8787
/// </summary>
88-
[CommandOverload("enable", "Enables a list of attachments on a firearm.")]
88+
[CommandOverload("enable", "Enables a list of attachments on a firearm.", null)]
8989
public void Enable(
9090
[CommandParameter("Serial", "The serial of the target firearm.")] ushort firearmSerial,
9191
[CommandParameter("Attachments", "List of attachments to enable.")] List<AttachmentName> attachments)
@@ -109,7 +109,7 @@ public void Enable(
109109
/// <summary>
110110
/// Lists all attachments on a specific firearm.
111111
/// </summary>
112-
[CommandOverload("serial", "Lists all attachments on a specific firearm.")]
112+
[CommandOverload("serial", "Lists all attachments on a specific firearm.", null)]
113113
public void Serial(
114114
[CommandParameter("Serial", "The serial number of the firearm item.")] ushort firearmSerial)
115115
{
@@ -163,7 +163,7 @@ public void Serial(
163163
/// <summary>
164164
/// Lists all available attachments on a firearm.
165165
/// </summary>
166-
[CommandOverload("item", "Shows all attachments on an item.")]
166+
[CommandOverload("item", "Shows all attachments on an item.", null)]
167167
public void Item(
168168
[CommandParameter("Type", "The type of the firearm.")] ItemType type)
169169
{

LabExtended/Commands/Custom/CustomAmmo/CustomAmmoCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace LabExtended.Commands.Custom.CustomAmmo;
88
[Command("customammo", "Custom Ammo management.", "cammo")]
99
public class CustomAmmoCommand : CommandBase, IServerSideCommand
1010
{
11-
[CommandOverload("get", "Gets the amount of custom ammo in a player's inventory.")]
11+
[CommandOverload("get", "Gets the amount of custom ammo in a player's inventory.", null)]
1212
public void GetCommand(
1313
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
1414
[CommandParameter("Target", "The target player.")] ExPlayer? target = null)
@@ -19,7 +19,7 @@ public void GetCommand(
1919
Ok($"Player \"{player.Nickname}\" ({player.ClearUserId}) has \"{amount}\" of ammo \"{ammoId}\".");
2020
}
2121

22-
[CommandOverload("set", "Sets a specific amount of custom ammo in a player's inventory.")]
22+
[CommandOverload("set", "Sets a specific amount of custom ammo in a player's inventory.", null)]
2323
public void SetCommand(
2424
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
2525
[CommandParameter("Amount", "Amount to set.")] int amount,
@@ -32,7 +32,7 @@ public void SetCommand(
3232
Ok($"Set ammo \"{ammoId}\" of player \"{player.Nickname}\" ({player.ClearUserId}) to \"{amount}\".");
3333
}
3434

35-
[CommandOverload("add", "Adds a specific amount of custom ammo to a player's inventory.")]
35+
[CommandOverload("add", "Adds a specific amount of custom ammo to a player's inventory.", null)]
3636
public void AddCommand(
3737
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
3838
[CommandParameter("Amount", "Amount to add.")] int amount,
@@ -44,7 +44,7 @@ public void AddCommand(
4444
Ok($"Added \"{amount}\" of ammo \"{ammoId}\" to player \"{player.Nickname}\" ({player.ClearUserId}), new amount: \"{current}\".");
4545
}
4646

47-
[CommandOverload("Remove", "Removes a specific amount of custom ammo from a player's inventory.")]
47+
[CommandOverload("Remove", "Removes a specific amount of custom ammo from a player's inventory.", null)]
4848
public void RemoveCommand(
4949
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
5050
[CommandParameter("Amount", "Amount to remove.")] int amount,
@@ -56,7 +56,7 @@ public void RemoveCommand(
5656
Ok($"Removed \"{amount}\" of ammo \"{ammoId}\" from player \"{player.Nickname}\" ({player.ClearUserId}), new amount: \"{current}\".");
5757
}
5858

59-
[CommandOverload("clear", "Removes all custom ammo from a player's inventory.")]
59+
[CommandOverload("clear", "Removes all custom ammo from a player's inventory.", null)]
6060
public void ClearCommand(
6161
[CommandParameter("Target", "The target player.")] ExPlayer? target = null)
6262
{

LabExtended/Commands/Custom/CustomEffects/CustomEffectsCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace LabExtended.Commands.Custom.CustomEffects;
88
[Command("customeffect", "Manages Custom Effects", "ceffect")]
99
public class CustomEffectsCommand : CommandBase, IServerSideCommand
1010
{
11-
[CommandOverload("list", "Lists all available Custom Effects.")]
11+
[CommandOverload("list", "Lists all available Custom Effects.", null)]
1212
public void ListCommand(
1313
[CommandParameter("Target", "The target player. Specifying a " +
1414
"target will list of effects registered on a player.")] ExPlayer? target = null)
@@ -45,7 +45,7 @@ public void ListCommand(
4545
}
4646
}
4747

48-
[CommandOverload("enable", "Enables an inactive Custom Effect.")]
48+
[CommandOverload("enable", "Enables an inactive Custom Effect.", null)]
4949
public void EnableCommand(
5050
[CommandParameter("Name", "Name of the Custom Effect.")] string effectName,
5151
[CommandParameter("Target", "The target player (defaults to you).")] ExPlayer? target = null)
@@ -75,7 +75,7 @@ public void EnableCommand(
7575
Ok($"Enabled effect \"{effect.GetType().Name}\" on \"{player.Nickname}\" ({player.ClearUserId}).");
7676
}
7777

78-
[CommandOverload("disable", "Disables an active Custom Effect.")]
78+
[CommandOverload("disable", "Disables an active Custom Effect.", null)]
7979
public void DisableCommand(
8080
[CommandParameter("Name", "Name of the Custom Effect")] string effectName,
8181
[CommandParameter("Target", "The target player (defaults to you).")] ExPlayer? target = null)
@@ -105,7 +105,7 @@ public void DisableCommand(
105105
Ok($"Disabled effect \"{effect.GetType().Name}\" on \"{player.Nickname}\" ({player.ClearUserId}).");
106106
}
107107

108-
[CommandOverload("clear", "Clears all Custom Effects.")]
108+
[CommandOverload("clear", "Clears all Custom Effects.", null)]
109109
public void ClearCommand(ExPlayer? target = null)
110110
{
111111
var player = target ?? Sender;

LabExtended/Commands/Custom/CustomItems/CustomItemsCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class CustomItemsCommand : CommandBase, IServerSideCommand
2626
/// <summary>
2727
/// Lists all active custom item instances owned by a specific player.
2828
/// </summary>
29-
[CommandOverload("inv", "Lists all active custom instances owned by a specific player.")]
29+
[CommandOverload("inv", "Lists all active custom instances owned by a specific player.", null)]
3030
public void Inventory(
3131
[CommandParameter("Player", "The targeted player (defaults to you).")] ExPlayer? target = null)
3232
{
@@ -99,7 +99,7 @@ public void Inventory(
9999
/// <summary>
100100
/// Lists all registered custom items.
101101
/// </summary>
102-
[CommandOverload("list", "Lists all registered custom items.")]
102+
[CommandOverload("list", "Lists all registered custom items.", null)]
103103
public void List()
104104
{
105105
if (CustomItem.RegisteredObjects.Count == 0)
@@ -125,7 +125,7 @@ public void List()
125125
/// <summary>
126126
/// Lists all active custom item instances.
127127
/// </summary>
128-
[CommandOverload("active", "Lists all active custom item instances.")]
128+
[CommandOverload("active", "Lists all active custom item instances.", null)]
129129
public void Active()
130130
{
131131
if (CustomItem.RegisteredObjects.Count == 0)
@@ -184,7 +184,7 @@ public void Active()
184184
/// <summary>
185185
/// Destroys an active instance of a custom item.
186186
/// </summary>
187-
[CommandOverload("destroy", "Destroys an active instance of a custom item.")]
187+
[CommandOverload("destroy", "Destroys an active instance of a custom item.", null)]
188188
public void Destroy(
189189
[CommandParameter("Serial", "The serial number of the item to destroy. Specify 0 to destroy all.")] ushort itemSerial)
190190
{
@@ -252,8 +252,8 @@ public void Destroy(
252252
/// <summary>
253253
/// Adds a custom item to a player's inventory.
254254
/// </summary>
255-
[CommandOverload("add", "Adds a custom item to a player's inventory.")]
256-
[CommandOverload("give", "Adds a custom item to a player's inventory.")]
255+
[CommandOverload("add", "Adds a custom item to a player's inventory.", null)]
256+
[CommandOverload("give", null, null)]
257257
public void Add(
258258
[CommandParameter("ID", "The ID of the custom item to add.")] string itemId,
259259
[CommandParameter("Target", "The player to add the item to (defaults to you).")] ExPlayer? target = null)
@@ -287,7 +287,7 @@ public void Add(
287287
/// <summary>
288288
/// Spawns a custom item at a specific position.
289289
/// </summary>
290-
[CommandOverload("spawn", "Spawns a custom item at a specific position.")]
290+
[CommandOverload("spawn", "Spawns a custom item at a specific position.", null)]
291291
public void Spawn(
292292
[CommandParameter("ID", "The ID of the custom item to spawn.")] string itemId,
293293
[CommandParameter("Position", "The position to spawn the item at.")] Vector3 position)

LabExtended/Commands/Custom/CustomTeams/CustomTeamsCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace LabExtended.Commands.Custom.CustomTeams;
1212
[Command("customteam", "Manages the CustomTeams API", "ct")]
1313
public class CustomTeamsCommand : CommandBase, IServerSideCommand
1414
{
15-
[CommandOverload("list", "Lists all custom teams.")]
15+
[CommandOverload("list", "Lists all custom teams.", null)]
1616
public void List()
1717
{
1818
if (CustomTeamRegistry.RegisteredHandlers.Count == 0)
@@ -32,7 +32,7 @@ public void List()
3232
});
3333
}
3434

35-
[CommandOverload("waves", "Lists all spawned waves of a team.")]
35+
[CommandOverload("waves", "Lists all spawned waves of a team.", null)]
3636
public void Waves(
3737
[CommandParameter("Name", "Name of the team.")] string name)
3838
{
@@ -61,7 +61,7 @@ public void Waves(
6161
});
6262
}
6363

64-
[CommandOverload("wave", "Shows information about an active wave.")]
64+
[CommandOverload("wave", "Shows information about an active wave.", null)]
6565
public void Wave(
6666
[CommandParameter("Name", "Name of the team.")] string name,
6767
[CommandParameter("ID", "ID of the wave.")] int id)
@@ -116,7 +116,7 @@ public void Wave(
116116
});
117117
}
118118

119-
[CommandOverload("spawn", "Spawns a new wave of a custom team.")]
119+
[CommandOverload("spawn", "Spawns a new wave of a custom team.", null)]
120120
public void Spawn(
121121
[CommandParameter("Name", "Name of the team to spawn.")] string name)
122122
{
@@ -137,7 +137,7 @@ public void Spawn(
137137
Ok($"Spawned a new wave of '{handler.GetType().Name}' with '{instance.AlivePlayers.Count}' player(s) (ID: {instance.Id})");
138138
}
139139

140-
[CommandOverload("despawn", "Despawns an active wave of a custom team.")]
140+
[CommandOverload("despawn", "Despawns an active wave of a custom team.", null)]
141141
public void Despawn(
142142
[CommandParameter("Name", "Name of the team to despawn.")] string name,
143143
[CommandParameter("ID", "ID of the instance to despawn (or * for all).")] string id)

LabExtended/Commands/Custom/Despawn/DespawnCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void RaycastOverload(
7070
}
7171
}
7272

73-
[CommandOverload("id", "Despawns a network object by it's ID.")]
73+
[CommandOverload("id", "Despawns a network object by it's ID.", null)]
7474
public void NetworkIdOverload(
7575
[CommandParameter("ID", "ID of the network object.")] uint id)
7676
{

LabExtended/Commands/Custom/Enum/EnumCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using LabExtended.Commands.Attributes;
22
using LabExtended.Commands.Interfaces;
3+
34
using LabExtended.Commands.Parameters;
45
using LabExtended.Commands.Parameters.Parsers;
56

@@ -15,7 +16,7 @@ public class EnumCommand : CommandBase, IAllCommand
1516
/// Invokes the command.
1617
/// </summary>
1718
/// <param name="enumName">Name of the enum</param>
18-
[CommandOverload]
19+
[CommandOverload(null, null)]
1920
public void Invoke(string enumName)
2021
{
2122
var enumParser = default(EnumParameterParser);

LabExtended/Commands/Custom/Image/ImageCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace LabExtended.Commands.Custom.Image;
88
[Command("image", "Image API commands.")]
99
public class ImageCommand : CommandBase, IServerSideCommand
1010
{
11-
[CommandOverload("reload", "Reloads a specified image file.")]
11+
[CommandOverload("reload", "Reloads a specified image file.", null)]
1212
public void Reload(
1313
[CommandParameter("Name", "Name of the image to reload.")]
1414
string name)

0 commit comments

Comments
 (0)