Add GetPlayerByName to IMultiplayer interface
This commit is contained in:
@@ -17,5 +17,6 @@ namespace Torch.API
|
|||||||
void KickPlayer(ulong id);
|
void KickPlayer(ulong id);
|
||||||
void BanPlayer(ulong id, bool banned = true);
|
void BanPlayer(ulong id, bool banned = true);
|
||||||
IMyPlayer GetPlayerBySteamId(ulong id);
|
IMyPlayer GetPlayerBySteamId(ulong id);
|
||||||
|
IMyPlayer GetPlayerByName(string name);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,15 +9,23 @@ namespace Torch.Commands
|
|||||||
{
|
{
|
||||||
public class CommandContext
|
public class CommandContext
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin that added this command.
|
||||||
|
/// </summary>
|
||||||
public ITorchPlugin Plugin { get; }
|
public ITorchPlugin Plugin { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// The current Torch instance.
|
||||||
|
/// </summary>
|
||||||
public ITorchBase Torch { get; }
|
public ITorchBase Torch { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// The player who ran the command.
|
||||||
|
/// </summary>
|
||||||
public IMyPlayer Player { get; }
|
public IMyPlayer Player { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// The command arguments split by spaces and quotes. Ex. "this is" a command -> {this is, a, command}
|
||||||
|
/// </summary>
|
||||||
public List<string> Args { get; }
|
public List<string> Args { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Splits the argument by single words and quoted blocks.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public CommandContext(ITorchBase torch, ITorchPlugin plugin, IMyPlayer player, List<string> args = null)
|
public CommandContext(ITorchBase torch, ITorchPlugin plugin, IMyPlayer player, List<string> args = null)
|
||||||
{
|
{
|
||||||
Torch = torch;
|
Torch = torch;
|
||||||
@@ -28,7 +36,7 @@ namespace Torch.Commands
|
|||||||
|
|
||||||
public void Respond(string message, string sender = "Server", string font = MyFontEnum.Blue)
|
public void Respond(string message, string sender = "Server", string font = MyFontEnum.Blue)
|
||||||
{
|
{
|
||||||
Torch.Multiplayer.SendMessage(message, Player.IdentityId, sender, font);
|
Torch.Multiplayer.SendMessage(message, sender, Player.IdentityId, font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -63,9 +63,9 @@ namespace Torch.Managers
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMyPlayer GetPlayerByDisplayName(string displayName)
|
public IMyPlayer GetPlayerByName(string name)
|
||||||
{
|
{
|
||||||
return _onlinePlayers.FirstOrDefault(x => x.Value.DisplayName == displayName).Value;
|
return _onlinePlayers.FirstOrDefault(x => x.Value.DisplayName == name).Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMyPlayer GetPlayerBySteamId(ulong steamId)
|
public IMyPlayer GetPlayerBySteamId(ulong steamId)
|
||||||
|
Reference in New Issue
Block a user