This repository has been archived by the owner on Jan 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="Parent.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.CustomModules.API.Commands.CustomTeams | ||
{ | ||
using System; | ||
|
||
using CommandSystem; | ||
|
||
/// <summary> | ||
/// The main parent command for custom teams. | ||
/// </summary> | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
[CommandHandler(typeof(GameConsoleCommandHandler))] | ||
internal sealed class Parent : ParentCommand | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Parent"/> class. | ||
/// </summary> | ||
public Parent() | ||
{ | ||
LoadGeneratedCommands(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override string Command { get; } = "teams"; | ||
|
||
/// <inheritdoc/> | ||
public override string[] Aliases { get; } = { "tms" }; | ||
|
||
/// <inheritdoc/> | ||
public override string Description { get; } = string.Empty; | ||
|
||
/// <inheritdoc/> | ||
public override void LoadGeneratedCommands() | ||
{ | ||
RegisterCommand(Spawn.Instance); | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
response = "Invalid subcommand! Available: "; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="Spawn.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.CustomModules.API.Commands.CustomTeams | ||
{ | ||
using System; | ||
using System.Linq; | ||
|
||
using CommandSystem; | ||
using Exiled.API.Features; | ||
using Exiled.CustomModules.API.Features.CustomRoles; | ||
using Exiled.Permissions.Extensions; | ||
using PlayerRoles; | ||
|
||
/// <summary> | ||
/// The command to spawn a custom team. | ||
/// </summary> | ||
internal sealed class Spawn : ICommand | ||
{ | ||
private Spawn() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the <see cref="Spawn"/> instance. | ||
/// </summary> | ||
public static Spawn Instance { get; } = new(); | ||
|
||
/// <inheritdoc/> | ||
public string Command { get; } = "spawn"; | ||
|
||
/// <inheritdoc/> | ||
public string[] Aliases { get; } = { "s" }; | ||
|
||
/// <inheritdoc/> | ||
public string Description { get; } = "Spawns the specified custom team."; | ||
|
||
/// <inheritdoc/> | ||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
try | ||
{ | ||
if (!sender.CheckPermission("customteams.spawn")) | ||
{ | ||
response = "Permission denied, customteams.spawn is required."; | ||
return false; | ||
} | ||
|
||
if (arguments.Count < 1) | ||
{ | ||
response = "spawn <Custom Team ID>"; | ||
return false; | ||
} | ||
|
||
if (!CustomTeam.TryGet(arguments.At(0), out CustomTeam team) && (!uint.TryParse(arguments.At(0), out uint id) || !CustomTeam.TryGet(id, out team)) && team is null) | ||
{ | ||
response = $"Custom Team {arguments.At(0)} not found!"; | ||
return false; | ||
} | ||
|
||
if (!Player.Get(Team.Dead).Any()) | ||
{ | ||
response = "There are no dead players to spawn the custom team."; | ||
return false; | ||
} | ||
|
||
team.Respawn(true); | ||
|
||
response = $"Custom Team {team.Name} has been spawned."; | ||
return true; | ||
} | ||
catch (Exception ex) | ||
{ | ||
Log.Error(ex); | ||
response = "An error occurred when executing the command, check server console for more details."; | ||
return false; | ||
} | ||
} | ||
} | ||
} |