Skip to content

Commit

Permalink
Merge branch 'master' into adminchat_in_discord
Browse files Browse the repository at this point in the history
  • Loading branch information
Schrodinger71 authored Dec 29, 2024
2 parents 2b833a3 + 192446b commit c986861
Show file tree
Hide file tree
Showing 178 changed files with 2,374 additions and 491,559 deletions.
3 changes: 0 additions & 3 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public sealed class PostMapInitTest
"Oasis",
"Cog",
// ADT-Start
"ADT_Frontier",
"ADT_Astra",
"ADT_Avrit",
"ADT_Bagel",
Expand All @@ -111,7 +110,6 @@ public sealed class PostMapInitTest
// ADT-End

// ADT-Halloween-Start
"ADT_FrontierHalloween",
"ADT_TrainHalloween",
"ADT_SalternHalloween",
// ADT-Halloween-End
Expand All @@ -121,7 +119,6 @@ public sealed class PostMapInitTest
"ADT_BoxNewYear",
"ADT_Cluster_LegacyNewYear",
"ADT_DeltaNewYear",
"ADT_FrontierNewYear",
"ADT_GeminiNewYear",
"ADT_PieNewYear",
"ADT_SalternNewYear"
Expand Down
19 changes: 12 additions & 7 deletions Content.Server/ADT/Administration/Commands/SendERTCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Numerics;
using Content.Server.Chat.Managers;
using Robust.Shared.ContentPack;
using System.Threading.Tasks;

namespace Content.Server.ADT.Administration.Commands;

Expand All @@ -33,7 +34,8 @@ public sealed class SendERTCommand : IConsoleCommand
public string Command => "sendert";
public string Description => Loc.GetString("send-ert-description");
public string Help => Loc.GetString("send-ert-help");
public void Execute(IConsoleShell shell, string argStr, string[] args)

public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
#region Setup vars
string audioPath = "";
Expand Down Expand Up @@ -158,12 +160,6 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)

if (isAnnounce) // Write announce & play audio
{
if (isSetAlertLevel)
{
if (stationUid == null) { shell.WriteLine(Loc.GetString("sent-ert-invalid-grid")); return; } //We are on station?
_system.GetEntitySystem<AlertLevelSystem>().SetLevel(stationUid.Value, alertLevelCode, false, true, true, true);
}

if (isPlayAudio)
{
Filter filter = Filter.Empty().AddAllPlayers(_playerManager);
Expand All @@ -175,6 +171,15 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
}

_system.GetEntitySystem<ChatSystem>().DispatchGlobalAnnouncement(Loc.GetString($"ert-send-{args[0].ToLower()}-announcement"), Loc.GetString($"ert-send-{args[0].ToLower()}-announcer"), playSound: playAuidoFromAnnouncement, colorOverride: announceColor);

if (args[0].ToLower() != "denial") // Если отказ то задержка нам не нужна
await Task.Delay(10000); // Ставим задержку на 10 секунд

if (isSetAlertLevel)
{
if (stationUid == null) { shell.WriteLine(Loc.GetString("sent-ert-invalid-grid")); return; } //We are on station?
_system.GetEntitySystem<AlertLevelSystem>().SetLevel(stationUid.Value, alertLevelCode, false, true, true, true);
}
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Shared.Administration;
using Robust.Shared.Console;
using Content.Server.Administration;
using Content.Server.ServerUpdates;

namespace Content.Server.ADT.Administration.Commands;


[AdminCommand(AdminFlags.Permissions)]
public sealed class SendUpdateServerCommand : LocalizedCommands
{
[Dependency] private readonly ServerUpdateManager _serverManager = default!;
public override string Command => "send_updateserver_devtest";

public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player == null)
{
shell.WriteError(LocalizationManager.GetString("shell-target-player-does-not-exist"));
return;
}

_serverManager.SendDiscordWebHookUpdateMessage();
}
}
89 changes: 89 additions & 0 deletions Content.Server/ServerUpdates/ServerUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Content.Shared.ADT.CCVar;
using Content.Server.Discord;
using Content.Server.GameTicking;

namespace Content.Server.ServerUpdates;

Expand All @@ -27,6 +30,8 @@ public sealed class ServerUpdateManager : IPostInjectInit
[Dependency] private readonly IBaseServer _server = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly DiscordWebhook _discord = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;

private ISawmill _sawmill = default!;

Expand Down Expand Up @@ -102,6 +107,7 @@ private void WatchdogOnUpdateReceived()
_chatManager.DispatchServerAnnouncement(Loc.GetString("server-updates-received"));
_updateOnRoundEnd = true;
ServerEmptyUpdateRestartCheck("update notification");
SendDiscordWebHookUpdateMessage(); // ADT-Tweak
}

/// <summary>
Expand Down Expand Up @@ -148,4 +154,87 @@ void IPostInjectInit.PostInject()
{
_sawmill = _logManager.GetSawmill("restart");
}
// ADT-Tweak-start: Отправка сообщения в Discord при обновлении сервера
public async void SendDiscordWebHookUpdateMessage()
{
if (!string.IsNullOrWhiteSpace(_cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordServerUpdateWebhook)))
{
var webhookUrl = _cfg.GetCVar(ADTDiscordWebhookCCVars.DiscordServerUpdateWebhook);
if (webhookUrl == null)
return;

if (await _discord.GetWebhook(webhookUrl) is not { } webhookData)
return;

// Получение данных сервера
var serverName = _cfg.GetCVar<string>("game.hostname");
var serverDesc = _cfg.GetCVar<string>("game.desc");
var engineVersion = _cfg.GetCVar<string>("build.engine_version");
var buildVersion = _cfg.GetCVar<string>("build.version");

// Сообщение о перезапуске сервера
var descContent = "Обновление получено, сервер автоматически перезапустится для обновления в конце этого раунда.";

// Определение состояния раунда
var gameTicker = _entitySystemManager.GetEntitySystem<GameTicker>();
var roundDescription = gameTicker.RunLevel switch
{
GameRunLevel.PreRoundLobby => gameTicker.RoundId == 0
? "pre-round lobby after server restart"
: $"pre-round lobby for round {gameTicker.RoundId + 1}",
GameRunLevel.InRound => $"round {gameTicker.RoundId}",
GameRunLevel.PostRound => $"post-round {gameTicker.RoundId}",
_ => throw new ArgumentOutOfRangeException(nameof(gameTicker.RunLevel), $"{gameTicker.RunLevel} was not matched."),
};

// Формирование структуры embed
var embed = new WebhookEmbed
{
Title = "Обновление пришло",
Description = descContent,
Color = 0x0e9c00,
Footer = new WebhookEmbedFooter
{
Text = $"{serverName} ({roundDescription})"
},
Fields = new List<WebhookEmbedField>()
};

// Добавление полей только если они не пустые
AddIfNotEmpty(embed.Fields, "Название сервера", serverName);
AddIfNotEmpty(embed.Fields, "Описание сервера", serverDesc);
AddIfNotEmpty(embed.Fields, "RobustToolbox version", engineVersion);
AddIfNotEmpty(embed.Fields, "Build version", buildVersion);

// Формирование полезной нагрузки
var payload = new WebhookPayload
{
Embeds = new List<WebhookEmbed> { embed },
Username = Loc.GetString("username-webhook-update")
};

// Проверка, нужно ли добавлять пинг
var shouldPingOnUpdate = _cfg.GetCVar(ADTDiscordWebhookCCVars.ShouldPingOnUpdate);
if (shouldPingOnUpdate)
{
// Добавляем пинг в поле Content. Это будет сообщение, которое будет сверху
payload.Content = "<@&1275740664264659017>"; // ID роли "Обновления"
}

// Отправка сообщения в Discord
var identifier = webhookData.ToIdentifier();
payload.AllowedMentions.AllowRoleMentions();
await _discord.CreateMessage(identifier, payload);
}
}

// Вспомогательный метод для добавления полей в embed
private void AddIfNotEmpty(List<WebhookEmbedField> fields, string fieldName, string? fieldValue)
{
if (!string.IsNullOrWhiteSpace(fieldValue))
{
fields.Add(new WebhookEmbedField { Name = fieldName, Value = fieldValue, Inline = true });
}
}
// ADT-Tweak-end
}
18 changes: 16 additions & 2 deletions Content.Shared/ADT/CCVar/CCVars.WebhookDiscord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,25 @@ public sealed class ADTDiscordWebhookCCVars : CVars
/// URL of the Discord webhook which will relay adminwho info to the channel.
/// </summary>
public static readonly CVarDef<string> DiscordAdminwhoWebhook =
CVarDef.Create("discord.adminwho_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL);
CVarDef.Create("discord.adminwho_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL | CVar.ARCHIVE);

/// <summary>
/// URL of the Discord adminchat info to the channel.
/// </summary>
public static readonly CVarDef<string> DiscordAdminchatWebhook =
CVarDef.Create("discord.adminchat_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL);
CVarDef.Create("discord.adminchat_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL | CVar.ARCHIVE);

/// <summary>
/// This constant specifies a webhook that will send a message to Discord when a server updates.
/// </summary>
public static readonly CVarDef<string> DiscordServerUpdateWebhook =
CVarDef.Create("discord.server_update_webhook", string.Empty, CVar.SERVERONLY | CVar.CONFIDENTIAL | CVar.ARCHIVE);

/// <summary>
/// This constant specifies whether a ping should be sent to a specific Discord role
/// when the server update notification is triggered. If set to <c>true</c>, a ping will be sent to the role.
/// If set to <c>false</c>, no ping will be sent.
/// </summary>
public static readonly CVarDef<bool> ShouldPingOnUpdate =
CVarDef.Create("discord.server_update_webhook_ping", true, CVar.SERVERONLY | CVar.ARCHIVE);
}
19 changes: 19 additions & 0 deletions Content.Shared/ADT/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,24 @@ public sealed class SimpleStationCCVars
CVarDef.Create("silicon.npcupdatetime", 1.5f, CVar.SERVERONLY);
#endregion Silicons

/*
* Jetpack
*/
#region Jetpack System

/// <summary>
/// When true, Jetpacks can be enabled anywhere, even in gravity.
/// </summary>
public static readonly CVarDef<bool> JetpackEnableAnywhere =
CVarDef.Create("jetpack.enable_anywhere", false, CVar.REPLICATED);

/// <summary>
/// When true, jetpacks can be enabled on grids that have zero gravity.
/// </summary>
public static readonly CVarDef<bool> JetpackEnableInNoGravity =
CVarDef.Create("jetpack.enable_in_no_gravity", true, CVar.REPLICATED);

#endregion


}
12 changes: 10 additions & 2 deletions Content.Shared/Movement/Systems/SharedJetpackSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Content.Shared.Actions;
using Content.Shared.ADT.CCVar;
using Content.Shared.Gravity;
using Content.Shared.Interaction.Events;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
Expand All @@ -20,6 +22,7 @@ public abstract class SharedJetpackSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly IConfigurationManager _config = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -127,8 +130,13 @@ private bool CanEnableOnGrid(EntityUid? gridUid)
{
// No and no again! Do not attempt to activate the jetpack on a grid with gravity disabled. You will not be the first or the last to try this.
// https://discord.com/channels/310555209753690112/310555209753690112/1270067921682694234
return gridUid == null ||
(!HasComp<GravityComponent>(gridUid));

// ADT Tweak start
if (gridUid == null || !TryComp<GravityComponent>(gridUid, out var comp))
return true;

return !comp.Enabled;
// ADT Tweak End
}

private void OnJetpackGetAction(EntityUid uid, JetpackComponent component, GetItemActionsEvent args)
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Revenant/Components/RevenantComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public sealed partial class RevenantComponent : Component
/// The amount of essence that is needed to use the ability.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("smokeCost")]
public FixedPoint2 SmokeCost = -30;
public FixedPoint2 SmokeCost = 30;

/// <summary>
/// The status effects applied after the ability
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- files: ["30mm_01.ogg"]
license: "CC-BY-SA-3.0"
copyright: "upbeat.io and Highfleet"
source: "https://uppbeat.io/sfx/tag/cannon"

- files: ["30mm_02.ogg"]
license: "CC-BY-SA-3.0"
copyright: "upbeat.io and Highfleet"
source: "https://uppbeat.io/sfx/tag/cannon"

- files: ["30mm_03.ogg"]
license: "CC-BY-SA-3.0"
copyright: "upbeat.io and Highfleet"
source: "https://uppbeat.io/sfx/tag/cannon"

- files: ["100mm.ogg"]
license: "CC-BY-SA-3.0"
copyright: "upbeat.io and Highfleet"
source: "https://uppbeat.io/sfx/tag/cannon"

- files: ["155mm.ogg"]
license: "CC-BY-SA-3.0"
copyright: "upbeat.io and Highfleet"
source: "https://uppbeat.io/sfx/tag/cannon"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["shell_in.ogg"]
license: "CC-BY-SA-3.0"
copyright: "ASMR 152 Reloading SFX From WoT Pc Source Highest Quality by LAKIA_MAX"
source: "https://forblitz.ru/en/modifications/sounds/zvuki-perezaryadki-orudiya/10207?ysclid=m54pjb2mep496587172"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["turret_destroy.ogg"]
license: "CC-BY-SA-3.0"
copyright: "by Сonjurerq"
source: "https://github.com/AdventureTimeSS14/space_station_ADT/blob/91164e5c4b50db6404c89e5d3e2e7df47a5cd84e/Resources/Audio/ADT/ADTGlobalEvents/ShipBattle/Weapons/Guns/turret_destroy.ogg"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions Resources/Audio/ADT/Jukebox/NewYear/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- files: ["roa-music-winter-magic.ogg"]
license: "CC-BY-3.0"
copyright: "by Roa Music | https://soundcloud.com/roa_music1031 Music promoted by https://www.free-stock-music.com. Converted to mono ogg"
source: "https://www.free-stock-music.com/roa-music-winter-magic.html"

- files: ["the-piano-says-yuletide.ogg"]
license: "CC-BY-3.0"
copyright: "by The Piano Says | https://soundcloud.com/thepianosays https://spoti.fi/3uvxbRU Music promoted by https://www.free-stock-music.com. Converted to mono ogg"
source: "https://www.free-stock-music.com/the-piano-says-yuletide.html"

- files: ["maxkomusic-christmas-is-coming.ogg"]
license: "CC-BY-SA-3.0"
copyright: "by MaxKoMusic | https://maxkomusic.com/ Music promoted by https://www.free-stock-music.com. Converted to mono ogg"
source: "https://www.free-stock-music.com/maxkomusic-christmas-is-coming.html"

- files:
- alex-productions-christmas-countdown-deck-the-halls.ogg
- alex-productions-christmas-is-coming.ogg
- alex-productions-christmas-mood.ogg
- alex-productions-christmas-vibes.ogg
license: "CC-BY-3.0"
copyright: "by Alex-Productions | https://onsound.eu/ Music promoted by https://www.free-stock-music.com. Converted to mono ogg"
source: "https://www.free-stock-music.com"
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions Resources/Audio/ADT/Jukebox/attributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@
license: "CC-BY-NC-SA-3.0"
copyright: "Created for ADT by discord: conjurerq"
source: "https://github.com/AdventureTimeSS14/space_station_ADT/pull/800"

- files: ["fsm-team-eagle.ogg"]
license: "CC-BY-4.0"
copyright: "by FSM team https://www.free-stock-music.com. Converted to mono ogg"
source: "https://www.free-stock-music.com/fsm-team-eagle.html"

- files:
- fsm-team-escp-midnight-room.ogg
- fsm-team-escp-neonscapes.ogg
license: "CC-BY-3.0"
copyright: "by | e s c p | https://www.escp.space https://escp-music.bandcamp.com. Converted to mono ogg"
source: "https://www.free-stock-music.com"
Binary file added Resources/Audio/ADT/Jukebox/fsm-team-eagle.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Resources/Audio/Misc/gamma.ogg
Binary file not shown.
Loading

0 comments on commit c986861

Please sign in to comment.