Skip to content

Commit 5f694a2

Browse files
committed
fixed true-color formatting with unity rich text and added permissions to all commands
1 parent d6a33f9 commit 5f694a2

38 files changed

+376
-182
lines changed

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.", null)]
24+
[CommandOverload("random", "Randomizes all attachments of a firearm.", "attachments.random")]
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.", null)]
42+
[CommandOverload("clear", "Clears all attachments on a firearm.", "attachments.clear")]
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.", null)]
64+
[CommandOverload("disable", "Disables a list of attachments on a firearm.", "attachments.disable")]
6565
public void Disable(
6666
[CommandParameter(Name = "Serial", Description = "The serial number of the firearm.")] ushort firearmSerial,
6767
[CommandParameter(Name = "Attachments", Description = "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.", null)]
88+
[CommandOverload("enable", "Enables a list of attachments on a firearm.", "attachments.enable")]
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.", null)]
112+
[CommandOverload("serial", "Lists all attachments on a specific firearm.", "attachments.serial")]
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.", null)]
166+
[CommandOverload("item", "Shows all attachments on an item.", "attachments.item")]
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
@@ -16,7 +16,7 @@ namespace LabExtended.Commands.Custom.CustomAmmo;
1616
[Command("customammo", "Custom Ammo management.", "cammo")]
1717
public class CustomAmmoCommand : CommandBase, IServerSideCommand
1818
{
19-
[CommandOverload("get", "Gets the amount of custom ammo in a player's inventory.", null)]
19+
[CommandOverload("get", "Gets the amount of custom ammo in a player's inventory.", "customammo.get")]
2020
private void GetCommand(
2121
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
2222
[CommandParameter("Targets", "The target players.")] List<ExPlayer> players)
@@ -28,7 +28,7 @@ private void GetCommand(
2828
});
2929
}
3030

31-
[CommandOverload("set", "Sets a specific amount of custom ammo in a player's inventory.", null)]
31+
[CommandOverload("set", "Sets a specific amount of custom ammo in a player's inventory.", "customammo.set")]
3232
private void SetCommand(
3333
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
3434
[CommandParameter("Amount", "Amount to set.")] int amount,
@@ -41,7 +41,7 @@ private void SetCommand(
4141
});
4242
}
4343

44-
[CommandOverload("add", "Adds a specific amount of custom ammo to a player's inventory.", null)]
44+
[CommandOverload("add", "Adds a specific amount of custom ammo to a player's inventory.", "customammo.add")]
4545
private void AddCommand(
4646
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
4747
[CommandParameter("Amount", "Amount to add.")] int amount,
@@ -54,7 +54,7 @@ private void AddCommand(
5454
});
5555
}
5656

57-
[CommandOverload("remove", "Removes a specific amount of custom ammo from a player's inventory.", null)]
57+
[CommandOverload("remove", "Removes a specific amount of custom ammo from a player's inventory.", "customammo.remove")]
5858
private void RemoveCommand(
5959
[CommandParameter("ID", "ID of the ammo.")] string ammoId,
6060
[CommandParameter("Amount", "Amount to remove.")] int amount,
@@ -67,7 +67,7 @@ private void RemoveCommand(
6767
});
6868
}
6969

70-
[CommandOverload("clear", "Removes all custom ammo from a player's inventory.", null)]
70+
[CommandOverload("clear", "Removes all custom ammo from a player's inventory.", "customammo.clear")]
7171
private void ClearCommand(
7272
[CommandParameter("Targets", "The target players.")] List<ExPlayer> players)
7373
{

LabExtended/Commands/Custom/CustomEffects/CustomEffectsCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class CustomEffectsCommand : CommandBase, IServerSideCommand
2020
/// </summary>
2121
/// <param name="target">The target player whose registered custom effects will be listed. If null, lists all available custom effects
2222
/// instead.</param>
23-
[CommandOverload("list", "Lists all available Custom Effects.", null)]
23+
[CommandOverload("list", "Lists all available Custom Effects.", "customeffect.list")]
2424
public void ListCommand(
2525
[CommandParameter("Target", "The target player. Specifying a " +
2626
"target will list of effects registered on a player.")] ExPlayer? target = null)
@@ -65,7 +65,7 @@ public void ListCommand(
6565
/// effects.</remarks>
6666
/// <param name="effectName">The name of the Custom Effect to enable. Must correspond to a registered effect.</param>
6767
/// <param name="target">The player on whom to enable the effect. If not specified, the effect is enabled on the command sender.</param>
68-
[CommandOverload("enable", "Enables an inactive Custom Effect.", null)]
68+
[CommandOverload("enable", "Enables an inactive Custom Effect.", "customeffect.enable")]
6969
public void EnableCommand(
7070
[CommandParameter("Name", "Name of the Custom Effect.")] string effectName,
7171
[CommandParameter("Target", "The target player (defaults to you).")] ExPlayer? target = null)
@@ -102,7 +102,7 @@ public void EnableCommand(
102102
/// will fail with an appropriate message. Use the "customeffect list" command to view available effects.</remarks>
103103
/// <param name="effectName">The name of the Custom Effect to disable. This must match the name of an existing effect.</param>
104104
/// <param name="target">The player on whom to disable the effect. If not specified, the effect is disabled on the command sender.</param>
105-
[CommandOverload("disable", "Disables an active Custom Effect.", null)]
105+
[CommandOverload("disable", "Disables an active Custom Effect.", "customeffect.disable")]
106106
public void DisableCommand(
107107
[CommandParameter("Name", "Name of the Custom Effect")] string effectName,
108108
[CommandParameter("Target", "The target player (defaults to you).")] ExPlayer? target = null)
@@ -136,7 +136,7 @@ public void DisableCommand(
136136
/// Disables all active custom effects for the specified player.
137137
/// </summary>
138138
/// <param name="target">The player whose custom effects will be cleared. If null, the command sender is used.</param>
139-
[CommandOverload("clear", "Clears all Custom Effects.", null)]
139+
[CommandOverload("clear", "Clears all Custom Effects.", "customeffect.clear")]
140140
public void ClearCommand(ExPlayer? target = null)
141141
{
142142
var player = target ?? Sender;

LabExtended/Commands/Custom/CustomGamemodes/CustomGamemodeCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace LabExtended.Commands.Custom.CustomGamemodes
1313
[Command("customgamemode", "Management commands for the Custom Gamemode API.", "cg")]
1414
public class CustomGamemodeCommand : CommandBase, IServerSideCommand
1515
{
16-
[CommandOverload("list", "Lists all registered gamemodes.", null)]
16+
[CommandOverload("list", "Lists all registered gamemodes.", "customgamemode.list")]
1717
private void List()
1818
{
1919
if (CustomGamemode.RegisteredObjects.Count < 1)
@@ -33,7 +33,7 @@ private void List()
3333
});
3434
}
3535

36-
[CommandOverload("detail", "Shows detailed state information about a specific active gamemode.", null)]
36+
[CommandOverload("detail", "Shows detailed state information about a specific active gamemode.", "customgamemode.detail")]
3737
private void Detail(
3838
[CommandParameter("ID", "The ID of the mod to show the state of.")] string id)
3939
{
@@ -62,7 +62,7 @@ private void Detail(
6262
});
6363
}
6464

65-
[CommandOverload("active", "Lists all currently active gamemodes (and the queue).", null)]
65+
[CommandOverload("active", "Lists all currently active gamemodes (and the queue).", "customgamemode.active")]
6666
private void Active()
6767
{
6868
Ok(x =>
@@ -84,7 +84,7 @@ private void Active()
8484
});
8585
}
8686

87-
[CommandOverload("enable", "Enables a new gamemode.", null)]
87+
[CommandOverload("enable", "Enables a new gamemode.", "customgamemode.enable")]
8888
private void Enable(
8989
[CommandParameter("ID", "The ID of the gamemode to enable.")] string id)
9090
{
@@ -125,7 +125,7 @@ private void Enable(
125125
Ok($"Started gamemode '{gamemode.Id}'");
126126
}
127127

128-
[CommandOverload("disable", "Disables a specific or all active gamemode(s).", null)]
128+
[CommandOverload("disable", "Disables a specific or all active gamemode(s).", "customgamemode.disable")]
129129
private void Disable(
130130
[CommandParameter("ID", "The ID of the gamemode to disable (specify * or all for all).")] string id)
131131
{

LabExtended/Commands/Custom/CustomItems/CustomItemsCommand.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using InventorySystem;
22
using InventorySystem.Items;
33
using InventorySystem.Items.Pickups;
4-
4+
using LabApi.Features.Permissions;
55
using LabExtended.API;
66
using LabExtended.API.Custom.Items;
77

@@ -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.", null)]
29+
[CommandOverload("inv", "Lists all active custom instances owned by a specific player.", "customitem.inventory")]
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.", null)]
102+
[CommandOverload("list", "Lists all registered custom items.", "customitem.list")]
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.", null)]
128+
[CommandOverload("active", "Lists all active custom item instances.", "customitem.active")]
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.", null)]
187+
[CommandOverload("destroy", "Destroys an active instance of a custom item.", "customitem.destroy")]
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.", null)]
256-
[CommandOverload("give", null, null)]
255+
[CommandOverload("add", "Adds a custom item to a player's inventory.", "customitem.give")]
256+
[CommandOverload("give", "Adds a custom item to a player's inventory.", "customitem.give")]
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)
@@ -272,6 +272,12 @@ public void Add(
272272
return;
273273
}
274274

275+
if (!Sender.HasAnyPermission("customitem.give.all", $"customitem.give.{itemId}"))
276+
{
277+
Fail($"You do not have permission to give this custom item.");
278+
return;
279+
}
280+
275281
var addedItem = customItem.AddItem(target);
276282

277283
if (addedItem != null)
@@ -287,7 +293,7 @@ public void Add(
287293
/// <summary>
288294
/// Spawns a custom item at a specific position.
289295
/// </summary>
290-
[CommandOverload("spawn", "Spawns a custom item at a specific position.", null)]
296+
[CommandOverload("spawn", "Spawns a custom item at a specific position.", "customitem.spawn")]
291297
public void Spawn(
292298
[CommandParameter("ID", "The ID of the custom item to spawn.")] string itemId,
293299
[CommandParameter("Position", "The position to spawn the item at.")] Vector3 position)
@@ -304,6 +310,12 @@ public void Spawn(
304310
return;
305311
}
306312

313+
if (!Sender.HasAnyPermission("customitem.spawn.all", $"customitem.spawn.{itemId}"))
314+
{
315+
Fail($"You do not have permission to give this custom item.");
316+
return;
317+
}
318+
307319
var spawnedItem = customItem.SpawnItem(position, Sender.Rotation);
308320

309321
if (spawnedItem != null)

LabExtended/Commands/Custom/CustomRoles/CustomRolesCommand.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using LabExtended.API;
1+
using LabApi.Features.Permissions;
2+
using LabApi.Features.Wrappers;
3+
using LabExtended.API;
24
using LabExtended.API.Custom.Roles;
3-
45
using LabExtended.Commands.Attributes;
56
using LabExtended.Commands.Interfaces;
67

@@ -12,7 +13,7 @@ namespace LabExtended.Commands.Custom.CustomRoles
1213
[Command("customroles", "Manages custom roles.", "cr")]
1314
public class CustomRolesCommand : CommandBase, IServerSideCommand
1415
{
15-
[CommandOverload("list", "Lists all registered custom roles.", null)]
16+
[CommandOverload("list", "Lists all registered custom roles.", "customrole.list")]
1617
private void List()
1718
{
1819
if (CustomRole.RegisteredObjects.Count == 0)
@@ -30,7 +31,7 @@ private void List()
3031
});
3132
}
3233

33-
[CommandOverload("active", "Displays the currently active custom role of a player.", null)]
34+
[CommandOverload("active", "Displays the currently active custom role of a player.", "customrole.active")]
3435
private void Active(ExPlayer? target = null)
3536
{
3637
target ??= Sender;
@@ -44,7 +45,7 @@ private void Active(ExPlayer? target = null)
4445
Ok($"Player {target.ToCommandString()} has the '{target.Role.CustomRole.Name}' ({target.Role.CustomRole.Id}) custom role active.");
4546
}
4647

47-
[CommandOverload("set", "Sets the custom role of a player.", null)]
48+
[CommandOverload("set", "Sets the custom role of a player.", "customrole.set")]
4849
private void Set(ExPlayer target, string roleId)
4950
{
5051
if (!CustomRole.TryGet(roleId, out var role))
@@ -53,6 +54,12 @@ private void Set(ExPlayer target, string roleId)
5354
return;
5455
}
5556

57+
if (!Sender.HasAnyPermission("customrole.set.all", $"customrole.set.{roleId}"))
58+
{
59+
Fail($"You do not have permission to set this custom role.");
60+
return;
61+
}
62+
5663
if (target.Role.CustomRole == role)
5764
{
5865
Fail($"Player {target.ToLogString()} already has the '{role.Name}' ({role.Id}) custom role active.");
@@ -65,7 +72,7 @@ private void Set(ExPlayer target, string roleId)
6572
Fail($"Could not set custom role '{role.Name}' ({role.Id}) to player {target.ToCommandString()}");
6673
}
6774

68-
[CommandOverload("remove", "Removes the custom role of a player.", null)]
75+
[CommandOverload("remove", "Removes the custom role of a player.", "customrole.remove")]
6976
private void Remove(ExPlayer? target = null)
7077
{
7178
target ??= Sender;

0 commit comments

Comments
 (0)