mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-19 15:51:52 +00:00
Add ability to count votes in force skip command
This commit is contained in:
1 parent
01204b96f6
commit
0b8f284676
5 files changed
+50
-13
No files matched your search
@@ -1,5 +1,7 @@
|
||||
using BetterAmongUs.Attributes;
|
||||
using BetterAmongUs.Commands.Arguments;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Utilities.Extension;
|
||||
|
||||
namespace BetterAmongUs.Commands;
|
||||
|
||||
@@ -25,12 +27,42 @@ internal sealed class ForceSkipCommand : BaseCommand
|
||||
return base.CanRunCommand(out reason);
|
||||
}
|
||||
|
||||
public ForceSkipCommand()
|
||||
{
|
||||
_boolArgument = new BoolArgument(this, "{count votes}");
|
||||
Arguments = [_boolArgument];
|
||||
}
|
||||
private readonly BoolArgument _boolArgument;
|
||||
|
||||
internal override void Run()
|
||||
{
|
||||
if (!_boolArgument.TryParse(out var countVotes))
|
||||
return;
|
||||
|
||||
if (GameState.IsHost)
|
||||
{
|
||||
var states = Array.Empty<MeetingHud.VoterState>();
|
||||
MeetingHud.Instance.RpcVotingComplete(states, null, false);
|
||||
if (!countVotes)
|
||||
{
|
||||
var states = Array.Empty<MeetingHud.VoterState>();
|
||||
MeetingHud.Instance.RpcVotingComplete(states, null, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dictionary = MeetingHud.Instance.CalculateVotes();
|
||||
var max = dictionary.MaxPair(out bool tie);
|
||||
NetworkedPlayerInfo? networkedPlayerInfo = GameData.Instance.AllPlayers.FirstOrDefaultIl2Cpp((NetworkedPlayerInfo v) => !tie && v.PlayerId == max.Key);
|
||||
MeetingHud.VoterState[] array = new MeetingHud.VoterState[MeetingHud.Instance.playerStates.Length];
|
||||
for (int i = 0; i < MeetingHud.Instance.playerStates.Length; i++)
|
||||
{
|
||||
PlayerVoteArea playerVoteArea = MeetingHud.Instance.playerStates[i];
|
||||
array[i] = new MeetingHud.VoterState
|
||||
{
|
||||
VoterId = playerVoteArea.TargetPlayerId,
|
||||
VotedForId = playerVoteArea.VotedFor
|
||||
};
|
||||
}
|
||||
MeetingHud.Instance.RpcVotingComplete(array, networkedPlayerInfo, tie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,8 +34,7 @@ internal sealed class KickCommand : BaseCommand
|
||||
if (!_playerArgument.TryParse(out var player))
|
||||
return;
|
||||
|
||||
var isBan = _boolArgument.TryParse(out var ban);
|
||||
if (!isBan)
|
||||
if (!_boolArgument.TryParse(out var ban))
|
||||
return;
|
||||
|
||||
if (!player.IsHost())
|
||||
|
||||
@@ -26,13 +26,16 @@ internal sealed class RemovePlayerCommand : BaseCommand
|
||||
|
||||
internal override void Run()
|
||||
{
|
||||
if (BetterDataManager.RemovePlayer(_identifierArgument.Arg) == true)
|
||||
if (_identifierArgument.TryParse(out var identifierArgument))
|
||||
{
|
||||
Utils.AddChatPrivate($"{_identifierArgument.Arg} successfully removed from local <color=#4f92ff>Anti-Cheat</color> data!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.AddChatPrivate($"{_identifierArgument.Arg} Could not find player data from identifier");
|
||||
if (BetterDataManager.RemovePlayer(identifierArgument) == true)
|
||||
{
|
||||
Utils.AddChatPrivate($"{identifierArgument} successfully removed from local <color=#4f92ff>Anti-Cheat</color> data!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.AddChatPrivate($"{identifierArgument} Could not find player data from identifier");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,10 @@ internal sealed class SetPrefixCommand : BaseCommand
|
||||
internal override void Run()
|
||||
{
|
||||
var oldPrefix = BAUConfigs.CommandPrefix.Value;
|
||||
var prefix = _prefixArgument.Arg.ToCharArray()?.First().ToString();
|
||||
if (!_prefixArgument.TryParse(out var prefix))
|
||||
return;
|
||||
|
||||
prefix = prefix.ToCharArray()?.First().ToString();
|
||||
if (!string.IsNullOrEmpty(prefix))
|
||||
{
|
||||
BAUConfigs.CommandPrefix.Value = prefix;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using BetterAmongUs.Commands;
|
||||
using BetterAmongUs.Data.Config;
|
||||
using BetterAmongUs.Utilities;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.Support;
|
||||
using BetterAmongUs.Utilities;
|
||||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -194,7 +194,7 @@ internal static class ChatCommandsPatch
|
||||
// Red text if command cannot be run
|
||||
if (!closestCommand.CanRunCommand(out string _))
|
||||
{
|
||||
fullSuggestion = fullSuggestion.ToColor("#FF0300".HexToColor());
|
||||
fullSuggestion = fullSuggestion.ToColor("#FF0300");
|
||||
}
|
||||
|
||||
// Update UI elements
|
||||
|
||||
Reference in new issue
Block a user