Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
844e894
docs
Bluscream Sep 27, 2023
edcd5ba
docs
Bluscream Sep 27, 2023
3c0a6ac
docs
Bluscream Sep 27, 2023
8a2385d
Merge branch 'main' of https://github.com/bluscreams-battlebit-module…
Bluscream Oct 2, 2023
c9a2da0
rename role templates
Bluscream Oct 2, 2023
50eb013
Merge branch 'main' of https://github.com/bluscreams-battlebit-module…
Bluscream Oct 13, 2023
5db2319
ahh lol why
Bluscream Oct 14, 2023
e5acc83
Merge branch 'main' of https://github.com/bluscreams-battlebit-module…
Bluscream Oct 14, 2023
51d796b
add SteamApi name fix to ChatOverwrites
Bluscream Oct 14, 2023
093baad
small improvement + add ChatOverwrite.Normal config
Bluscream Oct 14, 2023
37b0f9a
added more default PermissionRoles
Bluscream Oct 14, 2023
1003ff6
commandhandler update + chatoverwrite handle whitespace
Bluscream Oct 14, 2023
abd2eec
add color reset
Bluscream Oct 14, 2023
0bddfe2
add maptime + use richtext
Bluscream Oct 15, 2023
98c6380
prep for commandhandler rewrite
Bluscream Oct 15, 2023
1643e95
make BasicProgression gr8 again
Bluscream Oct 17, 2023
fc8b3eb
rw chatoverwrite for timestamp
Bluscream Oct 19, 2023
bda33ab
merge from base
Bluscream Oct 19, 2023
f42bd11
Code Cleanup (Profile 1)
Bluscream Oct 19, 2023
3b4d8bd
Code Cleanup (Code Maid)
Bluscream Oct 19, 2023
362483b
fix basic progression
Bluscream Oct 19, 2023
24c0924
merge pr
Bluscream Oct 21, 2023
261097a
a fix
Bluscream Oct 22, 2023
2750c09
update from website
Bluscream Oct 22, 2023
1830585
#BasicProgression
Bluscream Oct 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Allowlist.cs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 1 Modules in Allowlist.cs

| Description | Version |
|:-------------------------------------------------------------------|:----------|
| Block players who are not on the allowlist from joining the server | 1.0.0 |

## Commands
| Command | Function Name | Description | Allowed Roles | Parameters | Defaults |
|:-------------|:----------------|:------------------------------------|:----------------|:------------------------------------------------|:-----------|
| allow add | void | Adds a player to the allowlist | Moderator | ['RunnerPlayer commandSource', 'ulong steamID'] | {} |
| allow remove | void | Removes a player from the allowlist | Moderator | ['RunnerPlayer commandSource', 'ulong steamID'] | {} |

## Public Methods
| Function Name | Parameters | Defaults |
|:----------------|:-------------------------------------------------|:-----------|
| | | |
| | | |
| | | |
| Task | ['ulong steamID', 'PlayerJoiningArguments args'] | {} |
| AllowAdd | ['RunnerPlayer commandSource', 'ulong steamID'] | {} |
| AllowRemove | ['RunnerPlayer commandSource', 'ulong steamID'] | {} |
| | | |
| | | |
54 changes: 19 additions & 35 deletions Announcements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,48 @@
namespace BattleBitBaseModules;

[Module("Periodically execute announcements and messages based on configurable delays and conditions", "1.0.0")]
public class Announcements : BattleBitModule
{
public class Announcements : BattleBitModule {
public AnnouncementsConfiguration Configuration { get; set; } = null!;
public AnnouncementStore Store { get; set; } = null!;

public override Task OnConnected()
{
public override Task OnConnected() {
Task.Run(announcements);

return Task.CompletedTask;
}

private async void announcements()
{
while (this.IsLoaded && this.Server.IsConnected)
{
private async void announcements() {
while (this.IsLoaded && this.Server.IsConnected) {
int lastItem = this.doAnnouncement(this.Configuration.AnnounceLongDelay, this.Store.lastAnnounceLong, this.Store.lastAnnounceLongItem, this.Configuration.AnnounceLong, this.Server.AnnounceLong);
if (lastItem != -1)
{
if (lastItem != -1) {
this.Store.lastAnnounceLong = DateTime.Now;
this.Store.lastAnnounceLongItem = lastItem;
}

lastItem = this.doAnnouncement(this.Configuration.AnnounceShortDelay, this.Store.lastAnnounceShort, this.Store.lastAnnounceShortItem, this.Configuration.AnnounceShort, this.Server.AnnounceShort);
if (lastItem != -1)
{
if (lastItem != -1) {
this.Store.lastAnnounceShort = DateTime.Now;
this.Store.lastAnnounceShortItem = lastItem;
}

lastItem = this.doAnnouncement(this.Configuration.UILogOnServerDelay, this.Store.lastUILogOnServer, this.Store.lastUILogOnServerItem, this.Configuration.UILogOnServer, message => this.Server.UILogOnServer(message, this.Configuration.UILogOnserverTimeout));
if (lastItem != -1)
{
if (lastItem != -1) {
this.Store.lastUILogOnServer = DateTime.Now;
this.Store.lastUILogOnServerItem = lastItem;
}

lastItem = this.doAnnouncement(this.Configuration.MessageToPlayerDelay, this.Store.lastMessageToPlayer, this.Store.lastMessageToPlayerItem, this.Configuration.MessageToPlayer, message =>
{
foreach (RunnerPlayer player in this.Server.AllPlayers)
{
lastItem = this.doAnnouncement(this.Configuration.MessageToPlayerDelay, this.Store.lastMessageToPlayer, this.Store.lastMessageToPlayerItem, this.Configuration.MessageToPlayer, message => {
foreach (RunnerPlayer player in this.Server.AllPlayers) {
player.Message(message, this.Configuration.MessageToPlayerTimeout);
}
});
if (lastItem != -1)
{
if (lastItem != -1) {
this.Store.lastMessageToPlayer = DateTime.Now;
this.Store.lastMessageToPlayerItem = lastItem;
}

lastItem = this.doAnnouncement(this.Configuration.SayToAllChatDelay, this.Store.lastSayToAllChat, this.Store.lastSayToAllChatItem, this.Configuration.SayToAllChat, this.Server.SayToAllChat);
if (lastItem != -1)
{
if (lastItem != -1) {
this.Store.lastSayToAllChat = DateTime.Now;
this.Store.lastSayToAllChatItem = lastItem;
}
Expand All @@ -68,20 +57,16 @@ private async void announcements()
}
}

private int doAnnouncement(int delay, DateTime lastAnnounce, int lastItem, string[] messages, Action<string> action)
{
if (messages.Length == 0)
{
private int doAnnouncement(int delay, DateTime lastAnnounce, int lastItem, string[] messages, Action<string> action) {
if (messages.Length == 0) {
return -1;
}

if (DateTime.Now.Subtract(lastAnnounce).TotalSeconds < delay)
{
if (DateTime.Now.Subtract(lastAnnounce).TotalSeconds < delay) {
return -1;
}

if (lastItem >= messages.Length)
{
if (lastItem >= messages.Length) {
lastItem = 0;
}

Expand All @@ -91,8 +76,7 @@ private int doAnnouncement(int delay, DateTime lastAnnounce, int lastItem, strin
}
}

public class AnnouncementsConfiguration : ModuleConfiguration
{
public class AnnouncementsConfiguration : ModuleConfiguration {
public int AnnounceLongDelay { get; set; } = 600;
public int AnnounceShortDelay { get; set; } = 300;
public int UILogOnServerDelay { get; set; } = 60;
Expand All @@ -105,15 +89,15 @@ public class AnnouncementsConfiguration : ModuleConfiguration
public string[] AnnounceShort { get; set; } = Array.Empty<string>();
public string[] UILogOnServer { get; set; } = Array.Empty<string>();
public string[] MessageToPlayer { get; set; } = Array.Empty<string>();

public string[] SayToAllChat { get; set; } = new[]
{
"We hope you enjoy our server!",
"Feel free to write feedback in the chat!"
};
}

public class AnnouncementStore : ModuleConfiguration
{
public class AnnouncementStore : ModuleConfiguration {
public DateTime lastAnnounceLong { get; set; } = DateTime.MinValue;
public DateTime lastAnnounceShort { get; set; } = DateTime.MinValue;
public DateTime lastUILogOnServer { get; set; } = DateTime.MinValue;
Expand All @@ -125,4 +109,4 @@ public class AnnouncementStore : ModuleConfiguration
public int lastUILogOnServerItem { get; set; } = 0;
public int lastMessageToPlayerItem { get; set; } = 0;
public int lastSayToAllChatItem { get; set; } = 0;
}
}
Empty file added Announcements.cs.md
Empty file.
Loading