Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Новые команды setallbalance и setbalance #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
95 changes: 95 additions & 0 deletions Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using Content.Shared.Administration;
using Robust.Shared.Console;
using Content.Server.Database;
using System.Threading;
using Content.Shared.Preferences;
using Content.Shared.Preferences.Loadouts;

namespace Content.Server.Administration.Commands;

[AdminCommand(AdminFlags.Host)]
public sealed class SetAllBalanceCommand : IConsoleCommand
{
[Dependency] private readonly IServerDbManager _dbManager = default!;

public string Command => "setallbalance";
public string Description => Loc.GetString("set-all-balance-command-description");
public string Help => Loc.GetString("set-all-balance-command-help-text", ("command",Command));

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var loc = IoCManager.Resolve<ILocalizationManager>();

if (args.Length == 1 && int.TryParse(args[0], out var set_balance))
{
_dbManager.SetAllBalance(set_balance);
return;
}
else if (args.Length == 1)
{
shell.WriteLine(Loc.GetString("shell-argument-number-invalid", ("index", "1")));
return;
}
else
{
_dbManager.SetAllBalance(25000);
return;
}
}
}

[AdminCommand(AdminFlags.Host)]
public sealed class SetZeroBalanceCommand : IConsoleCommand
{
[Dependency] private readonly IServerDbManager _dbManager = default!;

public string Command => "setzerobalance";
public string Description => Loc.GetString("set-balance-command-description");
public string Help => Loc.GetString("set-balance-command-help-text", ("command", Command));

public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var loc = IoCManager.Resolve<ILocalizationManager>();
if (args.Length == 1)
{
var _userId = await _dbManager.GetPlayerRecordByUserName(args[0], new CancellationToken());
if (_userId is not null) {
var userId = _userId.UserId;
var _profile = await _dbManager.GetPlayerPreferencesAsync(userId, new CancellationToken());
if (_profile is not null) {
foreach (var item in _profile.Characters)
{
if (item.Value is HumanoidCharacterProfile profile)
{
var newProfile = new HumanoidCharacterProfile(
profile.Name,
profile.FlavorText,
profile.Species,
profile.Age,
profile.Sex,
profile.Gender,
0,
profile.Appearance,
profile.SpawnPriority,
profile.JobPriorities,

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'

Check failure on line 74 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 10: cannot convert from 'System.Collections.Generic.IReadOnlyDictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>' to 'System.Collections.Generic.Dictionary<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.JobPrototype>, Content.Shared.Preferences.JobPriority>'
profile.PreferenceUnavailable,
profile.AntagPreferences,

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'

Check failure on line 76 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 12: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Roles.AntagPrototype>>'
profile.TraitPreferences,

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'

Check failure on line 77 in Content.Server/Administration/Commands/CorvaxSetBalanceCommand.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Argument 13: cannot convert from 'System.Collections.Generic.IReadOnlySet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>' to 'System.Collections.Generic.HashSet<Robust.Shared.Prototypes.ProtoId<Content.Shared.Traits.TraitPrototype>>'
new Dictionary<string, RoleLoadout>(profile.Loadouts));
await _dbManager.SaveCharacterSlotAsync(userId, newProfile, item.Key);
}
}
}
return;
} else {
shell.WriteLine(Loc.GetString("shell-target-player-does-not-exist "));
return;
}
}
else
{
shell.WriteLine(Loc.GetString("shell-need-exactly-one-argument"));
return;
}
}
}
7 changes: 7 additions & 0 deletions Content.Server/Database/ServerDbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ private static HumanoidCharacterProfile ConvertProfiles(Profile profile)
);
}

public async Task SetAllBalance(int set_balance)
{
await using var db = await GetDb();
await db.DbContext.Database.ExecuteSqlAsync($"""UPDATE profile SET bank_balance = {set_balance}""");
await db.DbContext.SaveChangesAsync();
Comment on lines +267 to +269
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL инъекции привет передают

Copy link
Collaborator

@JerryImMouse JerryImMouse Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var parameters = new[]
{
        new SqlParameter("@balance", setBalance),
};
await db.DbContext.Database.ExecuteSqlRawAsync(query, parameters);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JerryImMouse а ты видишь какие параметры передаются в функцию? Как ты строку в инт передашь?

}

private static Profile ConvertProfiles(HumanoidCharacterProfile humanoid, int slot, Profile? profile = null)
{
profile ??= new Profile();
Expand Down
11 changes: 11 additions & 0 deletions Content.Server/Database/ServerDbManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public Task EditServerRoleBan(
/// <param name="updates">The list of all updates to apply to the database.</param>
Task UpdatePlayTimes(IReadOnlyCollection<PlayTimeUpdate> updates);

/// <summary>
/// Change balance in db
/// </summary>
/// <param name="money">The list of all updates to apply to the database.</param>
user424242420 marked this conversation as resolved.
Show resolved Hide resolved
Task SetAllBalance(int set_balance);

#endregion

#region Player Records
Expand Down Expand Up @@ -519,6 +525,11 @@ public Task UpdatePlayerRecordAsync(
return RunDbCommand(() => _db.UpdatePlayerRecord(userId, userName, address, hwId));
}

public Task SetAllBalance(int set_balance) {
DbWriteOpsMetric.Inc();
return RunDbCommand(() => _db.SetAllBalance(set_balance));
}

public Task<PlayerRecord?> GetPlayerRecordByUserName(string userName, CancellationToken cancel = default)
{
DbReadOpsMetric.Inc();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set-all-balance-command-description = Комманда которая ставит баланс у всех.
set-all-balance-command-help-text = Записывает данные в базу данных напрямую. ИСПОЛЬЗОВАТЬ ТОЛЬКО В ЛОББИ И ПОСЛЕ ЧЕГО ПЕРЕЗАПУСТИТЬ СЕРВЕР.

set-balance-command-description = Команда которая устанавливает баланс по ckey/username.
set-balance-command-help-text = Записывает данные в базу данных напрямую. Первый аргумент - username, Второй не обязательный - значение баланса, если ничего нет ставит 0. ИСПОЛЬЗОВАТЬ ТОЛЬКО В ЛОББИ И ПОСЛЕ ЧЕГО ПЕРЕЗАПУСТИТЬ СЕРВЕР.
Loading