-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
380 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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31919.166 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BetterBroadcasts", "BetterBroadcasts\BetterBroadcasts.csproj", "{CCE7614A-8432-4AD7-894C-54DB99399BC2}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CCE7614A-8432-4AD7-894C-54DB99399BC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CCE7614A-8432-4AD7-894C-54DB99399BC2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CCE7614A-8432-4AD7-894C-54DB99399BC2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CCE7614A-8432-4AD7-894C-54DB99399BC2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {F0170391-C0C4-4C68-8522-3B1CCEF65D96} | ||
EndGlobalSection | ||
EndGlobal |
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,61 @@ | ||
namespace BetterBroadcasts | ||
{ | ||
using CommandSystem; | ||
using Exiled.API.Features; | ||
using Exiled.Permissions.Extensions; | ||
using System; | ||
using System.Linq; | ||
|
||
[CommandHandler(typeof(RemoteAdminCommandHandler))] | ||
public class BetterBroadcastCommand : ICommand, IUsageProvider | ||
{ | ||
public string[] Usage { get; } = new string[] | ||
{ | ||
"Duration", | ||
"Message" | ||
}; | ||
public string Command => "BetterBroadcast"; | ||
|
||
public string[] Aliases => new string[] { "bbc", "betterbc" }; | ||
|
||
public string Description => "Broadcasts a message with replaced variables"; | ||
|
||
|
||
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) | ||
{ | ||
if (!Plugin.Singleton.Config.UniquePermission && !sender.CheckPermission(global::PlayerPermissions.Broadcasting, out response)) | ||
{ | ||
return false; | ||
} | ||
else if (Plugin.Singleton.Config.UniquePermission && !sender.CheckPermission("bbc.broadcast")) | ||
{ | ||
response = "Missing permission: bbc.broadcast"; | ||
return false; | ||
} | ||
if (arguments.Count < 2) | ||
{ | ||
response = "To execute this command provide at least 2 arguments!\nUsage: " + arguments.Array[0] + " " + this.DisplayCommandUsage(); | ||
return false; | ||
} | ||
if (!ushort.TryParse(arguments.At(0), out ushort num) || num < 1) | ||
{ | ||
response = string.Concat(new string[] | ||
{ | ||
"Invalid argument for duration: ", | ||
arguments.At(0), | ||
" Usage: ", | ||
arguments.Array[0], | ||
" ", | ||
this.DisplayCommandUsage() | ||
}); | ||
return false; | ||
} | ||
string text = Utils.RAUtils.FormatArguments(arguments, 1); | ||
text = Plugin.Singleton.Config.BroadcastVariables.Aggregate(text, (result, s) => result.Replace(s.Key, s.Value)); | ||
Map.Broadcast(ushort.Parse(arguments.At(0)), text, global::Broadcast.BroadcastFlags.Normal, false); | ||
Log.Debug("Broadcast content = " + text, Plugin.Singleton.Config.DebugMode); | ||
response = "Broadcast sent."; | ||
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,109 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{CCE7614A-8432-4AD7-894C-54DB99399BC2}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>BetterBroadcasts</RootNamespace> | ||
<AssemblyName>BetterBroadcasts</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="0Harmony"> | ||
<HintPath>C:\Users\fijal\Desktop\Exiled (14)\EXILED\Plugins\dependencies\0Harmony.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-Publicized"> | ||
<HintPath>C:\Users\fijal\Desktop\Assembly-CSharp-Publicized.dll</HintPath> | ||
</Reference> | ||
<Reference Include="CommandSystem.Core"> | ||
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.API, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Bootstrap, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.Bootstrap.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.CreditTags, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.CreditTags.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.CustomItems, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.CustomItems.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.CustomRoles, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.CustomRoles.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Events, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.Events.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Loader, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.Loader.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Permissions, Version=4.1.2.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.Permissions.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Updater, Version=3.1.1.0, Culture=neutral, processorArchitecture=AMD64"> | ||
<HintPath>..\packages\EXILED.4.1.2\lib\net472\Exiled.Updater.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NorthwoodLib"> | ||
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\NorthwoodLib.dll</HintPath> | ||
</Reference> | ||
<Reference Include="SemVer"> | ||
<HintPath>C:\Users\fijal\Desktop\Exiled (14)\EXILED\Plugins\dependencies\SemVer.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="YamlDotNet"> | ||
<HintPath>C:\Users\fijal\Desktop\Exiled (14)\EXILED\Plugins\dependencies\YamlDotNet.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="BetterBroadcastCommand.cs" /> | ||
<Compile Include="BroadcastHandler.cs" /> | ||
<Compile Include="Config.cs" /> | ||
<Compile Include="Plugin.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="BroadcastObjects\RepeatedBroadcast.cs" /> | ||
<Compile Include="BroadcastObjects\TimedBroadcast.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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 @@ | ||
namespace BetterBroadcasts | ||
{ | ||
using Exiled.API.Features; | ||
using Exiled.Events.EventArgs; | ||
using MEC; | ||
using System.Collections.Generic; | ||
|
||
internal sealed class BroadcastHandler | ||
{ | ||
public static List<CoroutineHandle> BroadcastCoroutines = new List<CoroutineHandle>(); | ||
public void OnRoundStarted() | ||
{ | ||
foreach (var timedbc in Plugin.Singleton.Config.TimedBroadcasts) | ||
{ | ||
Log.Debug($"Dleay: {timedbc.Delay}, Duration: {timedbc.Duration}, Text: {timedbc.Text}", Plugin.Singleton.Config.DebugMode); | ||
Timing.CallDelayed(timedbc.Delay, () => | ||
{ | ||
Map.Broadcast(timedbc.Duration, timedbc.Text); | ||
Log.Debug($"Timed Broadcast fired: Dleay: {timedbc.Delay}, Duration: {timedbc.Duration}, Text: {timedbc.Text}", Plugin.Singleton.Config.DebugMode); | ||
}); | ||
} | ||
foreach (var repeatedbc in Plugin.Singleton.Config.RepeatedBroadcasts) | ||
{ | ||
Log.Debug($"Interval: {repeatedbc.Interval}, Duration: {repeatedbc.Duration}, Text: {repeatedbc.Text}", Plugin.Singleton.Config.DebugMode); | ||
BroadcastCoroutines.Add(Timing.RunCoroutine(CallBroadcastRepetitively(repeatedbc.Interval, repeatedbc.Duration, repeatedbc.Text))); | ||
|
||
} | ||
} | ||
public void OnRoundEnded(RoundEndedEventArgs ev) | ||
{ | ||
foreach (CoroutineHandle coroutine in BroadcastCoroutines) | ||
{ | ||
Timing.KillCoroutines(coroutine); | ||
} | ||
BroadcastCoroutines.Clear(); | ||
} | ||
public IEnumerator<float> CallBroadcastRepetitively(float interval, ushort duration, string text) | ||
{ | ||
for (; ; ) | ||
{ | ||
Map.Broadcast(duration, text, global::Broadcast.BroadcastFlags.Normal, true); | ||
Log.Debug($"Repeated Broadcast fired: Interval: {interval}, Duration: {duration}, Text: {text}", Plugin.Singleton.Config.DebugMode); | ||
yield return Timing.WaitForSeconds(interval); | ||
} | ||
} | ||
} | ||
} |
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,9 @@ | ||
namespace BetterBroadcasts.BroadcastObjects | ||
{ | ||
public class RepeatedBroadcast | ||
{ | ||
public float Interval { get; set; } | ||
public ushort Duration { get; set; } | ||
public string Text { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace BetterBroadcasts.BroadcastObjects | ||
{ | ||
public class TimedBroadcast | ||
{ | ||
public string Text { get; set; } | ||
public float Delay { get; set; } | ||
public ushort Duration { get; set; } | ||
} | ||
} |
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,38 @@ | ||
namespace BetterBroadcasts | ||
{ | ||
using BetterBroadcasts.BroadcastObjects; | ||
using Exiled.API.Interfaces; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
public sealed class Config : IConfig | ||
{ | ||
public bool IsEnabled { get; set; } = true; | ||
public bool DebugMode { get; private set; } = false; | ||
[Description("Plugin is using basegame Broadcast Permission. If set to true, you need to grant bbc.broadcast permission for command to work")] | ||
public bool UniquePermission { get; private set; } = false; | ||
[Description("When you use variables in BetterBroadcast Command they are replaced with provided text")] | ||
public Dictionary<string, string> BroadcastVariables { get; private set; } = new Dictionary<string, string> | ||
{ | ||
{ "%variable%", "this is a test variable" } | ||
}; | ||
public List<TimedBroadcast> TimedBroadcasts { get; private set; } = new List<TimedBroadcast> | ||
{ | ||
new TimedBroadcast | ||
{ | ||
Delay = 10f, | ||
Duration = 10, | ||
Text = "Test Timed Broadcast" | ||
} | ||
}; | ||
public List<RepeatedBroadcast> RepeatedBroadcasts { get; private set; } = new List<RepeatedBroadcast> | ||
{ | ||
new RepeatedBroadcast | ||
{ | ||
Interval = 100f, | ||
Duration = 10, | ||
Text = "Test Repeated Broadcast" | ||
} | ||
}; | ||
} | ||
} |
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,42 @@ | ||
namespace BetterBroadcasts | ||
{ | ||
using Exiled.API.Features; | ||
using System; | ||
using Server = Exiled.Events.Handlers.Server; | ||
public class Plugin : Plugin<Config> | ||
{ | ||
private BroadcastHandler broadcastHandler; | ||
|
||
public override string Author => "Cegla"; | ||
public override string Name => "BetterBroadcast"; | ||
public override string Prefix => "bbc"; | ||
public override Version Version => new Version(1, 0, 0); | ||
public override Version RequiredExiledVersion => new Version(4, 0, 0); | ||
|
||
public static Plugin Singleton; | ||
public override void OnEnabled() | ||
{ | ||
Singleton = this; | ||
RegisterEvents(); | ||
base.OnEnabled(); | ||
} | ||
public override void OnDisabled() | ||
{ | ||
UnregisterEvents(); | ||
Singleton = null; | ||
base.OnDisabled(); | ||
} | ||
private void RegisterEvents() | ||
{ | ||
broadcastHandler = new BroadcastHandler(); | ||
Server.RoundStarted += broadcastHandler.OnRoundStarted; | ||
Server.RoundEnded += broadcastHandler.OnRoundEnded; | ||
} | ||
private void UnregisterEvents() | ||
{ | ||
Server.RoundStarted -= broadcastHandler.OnRoundStarted; | ||
Server.RoundEnded -= broadcastHandler.OnRoundEnded; | ||
broadcastHandler = null; | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Ogólne informacje o zestawie są kontrolowane poprzez następujący | ||
// zestaw atrybutów. Zmień wartości tych atrybutów, aby zmodyfikować informacje | ||
// powiązane z zestawem. | ||
[assembly: AssemblyTitle("BetterBroadcasts")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("BetterBroadcasts")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Ustawienie elementu ComVisible na wartość false sprawia, że typy w tym zestawie są niewidoczne | ||
// dla składników COM. Jeśli potrzebny jest dostęp do typu w tym zestawie z | ||
// COM, ustaw wartość true dla atrybutu ComVisible tego typu. | ||
[assembly: ComVisible(false)] | ||
|
||
// Następujący identyfikator GUID jest identyfikatorem biblioteki typów w przypadku udostępnienia tego projektu w modelu COM | ||
[assembly: Guid("cce7614a-8432-4ad7-894c-54db99399bc2")] | ||
|
||
// Informacje o wersji zestawu zawierają następujące cztery wartości: | ||
// | ||
// Wersja główna | ||
// Wersja pomocnicza | ||
// Numer kompilacji | ||
// Poprawka | ||
// | ||
// Możesz określić wszystkie wartości lub użyć domyślnych numerów kompilacji i poprawki | ||
// przy użyciu symbolu „*”, tak jak pokazano poniżej: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="EXILED" version="4.1.2" targetFramework="net472" /> | ||
</packages> |