-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
6a9c4b5
commit ac042a2
Showing
17 changed files
with
286 additions
and
61 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
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
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,39 @@ | ||
using CommandSystem; | ||
using Exiled.Permissions.Extensions; | ||
using System; | ||
using System.Text; | ||
|
||
namespace SCPUtils.Commands | ||
{ | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
[CommandHandler(typeof(GameConsoleCommandHandler))] | ||
internal class BroadcastList : ICommand | ||
{ | ||
public string Command { get; } = "scputils_broadcast_list"; | ||
|
||
public string[] Aliases { get; } = new[] { "sbcl", "bcl", "su_bcl", "scpu_bcl" }; | ||
|
||
public string Description { get; } = "List of all registred broadcast"; | ||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
if (!sender.CheckPermission("scputils.broadcastlist")) | ||
{ | ||
response = "<color=red> You need a higher administration level to use this command!</color>"; | ||
return false; | ||
} | ||
StringBuilder broadcastList = new StringBuilder("[Broadcast List]"); | ||
broadcastList.AppendLine(); | ||
foreach (BroadcastDb databaseBroadcast in Database.LiteDatabase.GetCollection<BroadcastDb>().FindAll()) | ||
{ | ||
broadcastList.AppendLine($"ID: {databaseBroadcast.Id}"); | ||
broadcastList.AppendLine($"Created by: {databaseBroadcast.CreatedBy}"); | ||
broadcastList.AppendLine($"Default duration: {databaseBroadcast.Seconds}"); | ||
broadcastList.AppendLine($"Text: {databaseBroadcast.Text}"); | ||
broadcastList.AppendLine("---------"); | ||
} | ||
response = $"{broadcastList}"; | ||
return true; | ||
} | ||
} | ||
} |
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,57 @@ | ||
using CommandSystem; | ||
using Exiled.Permissions.Extensions; | ||
using System; | ||
|
||
namespace SCPUtils.Commands | ||
{ | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
[CommandHandler(typeof(GameConsoleCommandHandler))] | ||
internal class CreateBroadcast : ICommand | ||
{ | ||
public string Command { get; } = "scputils_broadcast_create"; | ||
|
||
public string[] Aliases { get; } = new[] { "cbc", "su_cbc", "scpu_cbc" }; | ||
|
||
public string Description { get; } = "Allows to create custom broadcasts"; | ||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
if (!sender.CheckPermission("scputils.broadcastcreate")) | ||
{ | ||
response = "<color=red> You need a higher administration level to use this command!</color>"; | ||
return false; | ||
} | ||
|
||
else if (arguments.Count < 3) | ||
{ | ||
response = $"<color=yellow>Usage: {Command} <id> <duration> <text>"; | ||
return false; | ||
} | ||
else | ||
{ | ||
if (int.TryParse(arguments.Array[2].ToString(), out int duration)) | ||
{ | ||
if (Database.LiteDatabase.GetCollection<BroadcastDb>().Exists(broadcast => broadcast.Id == arguments.Array[1].ToString())) | ||
{ | ||
response = "Id already exist!"; | ||
return false; | ||
} | ||
else | ||
{ | ||
var broadcast = string.Join(" ", arguments.Array, 3, arguments.Array.Length - 3); | ||
ScpUtils.StaticInstance.DatabasePlayerData.AddBroadcast(arguments.Array[1].ToString(), sender.LogName, duration, broadcast.ToString()); | ||
response = "Success!"; | ||
return true; | ||
} | ||
} | ||
else | ||
{ | ||
response = "Broadcast duration must be an integer"; | ||
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,47 @@ | ||
using CommandSystem; | ||
using Exiled.Permissions.Extensions; | ||
using System; | ||
|
||
namespace SCPUtils.Commands | ||
{ | ||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
[CommandHandler(typeof(GameConsoleCommandHandler))] | ||
internal class DeleteBroadcast : ICommand | ||
{ | ||
public string Command { get; } = "scputils_broadcast_delete"; | ||
|
||
public string[] Aliases { get; } = new[] { "dbc", "su_dbc", "scpu_dbc" }; | ||
|
||
public string Description { get; } = "Allows to delete custom broadcastes"; | ||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
if (!sender.CheckPermission("scputils.broadcastdelete")) | ||
{ | ||
response = "<color=red> You need a higher administration level to use this command!</color>"; | ||
return false; | ||
} | ||
|
||
else if (arguments.Count < 1) | ||
{ | ||
response = $"<color=yellow>Usage: {Command} <id>"; | ||
return false; | ||
} | ||
else | ||
{ | ||
|
||
if (Database.LiteDatabase.GetCollection<BroadcastDb>().Exists(broadcast => broadcast.Id == arguments.Array[1].ToString())) | ||
{ | ||
Database.LiteDatabase.GetCollection<BroadcastDb>().Delete(arguments.Array[1].ToString()); | ||
response = "Success!"; | ||
return true; | ||
} | ||
else | ||
{ | ||
response = "Id does not exist!"; | ||
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
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
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
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,10 @@ | ||
namespace SCPUtils | ||
{ | ||
public class BroadcastDb | ||
{ | ||
public string Id { get; set; } | ||
public string CreatedBy { get; set; } | ||
public int Seconds { get; set; } | ||
public string Text { get; set; } | ||
} | ||
} |
Oops, something went wrong.