[Fix] More fixes (#487)
* fix criminal console foobar * fix tts volume * log reputation
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
Access="Public"
|
Access="Public"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
VerticalExpand="False"
|
VerticalExpand="False"
|
||||||
ToolTip="foobar"
|
ToolTip="{Loc 'criminal-login-in-desc'}"
|
||||||
TooltipDelay="0.25">
|
TooltipDelay="0.25">
|
||||||
<BoxContainer Orientation="Horizontal" >
|
<BoxContainer Orientation="Horizontal" >
|
||||||
<TextureRect Access="Public" Name="LIcon"
|
<TextureRect Access="Public" Name="LIcon"
|
||||||
|
|||||||
@@ -100,9 +100,12 @@ public sealed class TTSSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnPlayTTS(PlayTTSEvent ev)
|
private void OnPlayTTS(PlayTTSEvent ev)
|
||||||
{
|
{
|
||||||
var volume = 0f;
|
if (_volume <= -20f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var volume = _volume;
|
||||||
if (ev.BoostVolume)
|
if (ev.BoostVolume)
|
||||||
volume = 5f;
|
volume += 5f;
|
||||||
if (!TryCreateAudioSource(ev.Data, out var source, volume))
|
if (!TryCreateAudioSource(ev.Data, out var source, volume))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ public sealed class ModifyReputationCommand : IConsoleCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
var uid = playerData.UserId;
|
var uid = playerData.UserId;
|
||||||
|
var admin = playerData.UserName;
|
||||||
|
|
||||||
repManager.ModifyPlayerReputation(uid, value);
|
repManager.ModifyPlayerReputation(uid, value, admin);
|
||||||
|
|
||||||
shell.WriteLine($"Added {args[1]} to the reputation of {args[0]}.");
|
shell.WriteLine($"Added {args[1]} to the reputation of {args[0]}.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ public sealed class SetReputationCommand : IConsoleCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
var uid = playerData.UserId;
|
var uid = playerData.UserId;
|
||||||
|
var admin = playerData.UserName;
|
||||||
|
|
||||||
repManager.SetPlayerReputation(uid, value);
|
repManager.SetPlayerReputation(uid, value, admin);
|
||||||
|
|
||||||
shell.WriteLine($"Set reputation of {args[0]} to {args[1]}.");
|
shell.WriteLine($"Set reputation of {args[0]} to {args[1]}.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.Administration;
|
||||||
using Content.Server.Database;
|
using Content.Server.Database;
|
||||||
using Content.Server.GameTicking;
|
using Content.Server.GameTicking;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
@@ -16,10 +17,15 @@ public sealed class ReputationManager : EntitySystem
|
|||||||
[Dependency] private readonly IServerDbManager _db = default!;
|
[Dependency] private readonly IServerDbManager _db = default!;
|
||||||
[Dependency] private readonly IServerNetManager _netMgr = default!;
|
[Dependency] private readonly IServerNetManager _netMgr = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
[Dependency] private readonly ILogManager _logManager = default!;
|
||||||
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
||||||
|
|
||||||
private readonly Dictionary<NetUserId, ReputationInfo> _cacheReputation = new();
|
private readonly Dictionary<NetUserId, ReputationInfo> _cacheReputation = new();
|
||||||
private readonly Dictionary<NetUserId, DateTime> _playerConnectionTime = new();
|
private readonly Dictionary<NetUserId, DateTime> _playerConnectionTime = new();
|
||||||
|
|
||||||
|
private ISawmill _sawmill = default!;
|
||||||
|
private const string SawmillId = "reputation.logs";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
@@ -95,18 +101,30 @@ public sealed class ReputationManager : EntitySystem
|
|||||||
|
|
||||||
#region PublicApi
|
#region PublicApi
|
||||||
|
|
||||||
public async void SetPlayerReputation(NetUserId player, float value)
|
public async void SetPlayerReputation(NetUserId player, float value, string? admin = null)
|
||||||
{
|
{
|
||||||
|
var preValue = await GetPlayerReputation(player);
|
||||||
|
if (preValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var guid = player.UserId;
|
var guid = player.UserId;
|
||||||
await SetPlayerReputationTask(guid, value);
|
await SetPlayerReputationTask(guid, value);
|
||||||
|
|
||||||
RaiseLocalEvent(new UpdateCachedReputationEvent(player));
|
RaiseLocalEvent(new UpdateCachedReputationEvent(player));
|
||||||
|
await LogReputationChange(player, preValue.Value, false, admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ModifyPlayerReputation(NetUserId player, float value)
|
public async void ModifyPlayerReputation(NetUserId player, float value, string? admin = null)
|
||||||
{
|
{
|
||||||
|
var preValue = await GetPlayerReputation(player);
|
||||||
|
if (preValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
var guid = player.UserId;
|
var guid = player.UserId;
|
||||||
await ModifyPlayerReputationTask(guid, value);
|
await ModifyPlayerReputationTask(guid, value);
|
||||||
|
|
||||||
RaiseLocalEvent(new UpdateCachedReputationEvent(player));
|
RaiseLocalEvent(new UpdateCachedReputationEvent(player));
|
||||||
|
await LogReputationChange(player, preValue.Value, true, admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<float?> GetPlayerReputation(NetUserId player)
|
public async Task<float?> GetPlayerReputation(NetUserId player)
|
||||||
@@ -217,5 +235,25 @@ public sealed class ReputationManager : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LogReputationChange(NetUserId user, float preValue, bool modify, string? admin = null)
|
||||||
|
{
|
||||||
|
var located = await _locator.LookupIdAsync(user);
|
||||||
|
if (located == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var newValue = await GetPlayerReputation(user);
|
||||||
|
if (newValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var adminName = admin != null ? $" by {admin}" : "";
|
||||||
|
|
||||||
|
var msg = modify
|
||||||
|
? $"Reputation of {located.Username} was modified from {preValue} to {newValue.Value}{adminName}."
|
||||||
|
: $"Reputation of {located.Username} was set from {preValue} to {newValue.Value}{adminName}.";
|
||||||
|
|
||||||
|
_sawmill = _logManager.GetSawmill(SawmillId);
|
||||||
|
_sawmill.Info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user