Merge pull request #712 from miniduikboot/feature/aumi-host-chat-cmds

Add support for host chat cmds
This commit is contained in:
miniduikboot authored and GitHub committed 2026-02-18 07:17:58 +01:00
commit eeb85e4abc
4 files changed
+41 -6

No files matched your search

@@ -1,4 +1,4 @@
namespace Impostor.Api.Events.Player
namespace Impostor.Api.Events.Player
{
public interface IPlayerChatEvent : IPlayerEvent, IEventCancelable
{
@@ -6,5 +6,12 @@
/// Gets the message sent by the player.
/// </summary>
string Message { get; }
/// <summary>
/// Gets or sets a value indicating whether the message is sent to
/// all players (true) or only to the host (false).
/// To not send this message at all, cancel this event instead.
/// </summary>
bool SendToAllPlayers { get; set; }
}
}
@@ -1,4 +1,4 @@
using Impostor.Api.Events.Player;
using Impostor.Api.Events.Player;
using Impostor.Api.Games;
using Impostor.Api.Net;
using Impostor.Api.Net.Inner.Objects;
@@ -24,5 +24,7 @@ namespace Impostor.Server.Events.Player
public string Message { get; }
public bool IsCancelled { get; set; }
public bool SendToAllPlayers { get; set; } = true;
}
}
@@ -1183,9 +1183,35 @@ namespace Impostor.Server.Net.Inner.Objects
private async ValueTask<bool> HandleSendChat(ClientPlayer sender, string message)
{
var @event = new PlayerChatEvent(Game, sender, this, message);
// See https://github.com/Innersloth-LLC/AmongUsModdingInformation?tab=readme-ov-file#chat-commands
// Details not mentioned:
// - If the host sends a message that starts with /cmd, it is sent to all players
// - If the message starts with " /cmd" (note the space) it is sent to all players
if (Game.IsHostAuthoritive && !sender.IsHost && message.StartsWith("/cmd"))
{
@event.SendToAllPlayers = false;
}
await _eventManager.CallAsync(@event);
return !@event.IsCancelled;
if (@event.IsCancelled)
{
return false;
}
else if (@event.SendToAllPlayers == false)
{
if (Game.Host != null)
{
await SendChatToPlayerAsync(message, Game.Host.Character);
}
return false;
}
else
{
return true;
}
}
private async ValueTask HandleStartMeeting(byte targetId)
@@ -101,8 +101,8 @@ namespace Impostor.Server.Net.Manager
return;
}
// Warn when players connect using the +25 flag that disables server authority. The host authority version
// of 2024.6.18 contains various bugs that break the game, so print a message if this mode is in use
// Warn when players connect using the +25 flag that disables server authority.
// This changes game behaviour, so we'd like to know if it's in use.
if (clientVersion.HasDisableServerAuthorityFlag)
{
if (!_compatibilityConfig.AllowHostAuthority)
@@ -112,7 +112,7 @@ namespace Impostor.Server.Net.Manager
return;
}
_logger.LogWarning("Player {Name} connected with server authority disabled, this may cause issues as there are known bugs in this mode. Please mention that this mode is in use when asking for support.", name);
_logger.LogInformation("Player {Name} connected with server authority disabled, please mention that this mode is in use when asking for support.", name);
}
if (name.Length > 10)