Skip to content

Commit

Permalink
Update TextCommand.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardosnt committed Sep 26, 2016
1 parent a4d125d commit a5340c3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Core/Command/TextCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal class TextCommand : ICommand {
public AllowedSource AllowedSource { get; set; }

private readonly List<CommandEntry> _commands;
private readonly List<TextEntry> _texts;
private readonly List<TextEntry> _texts;

public TextCommand(TextCommands.TextCommandData data) {
_texts = new List<TextEntry>();
Expand Down Expand Up @@ -78,15 +78,19 @@ public TextCommand(TextCommands.TextCommandData data) {

public CommandResult OnExecute(ICommandSource src, ICommandArgs args) {
foreach (var entry in _texts) {
src.SendMessage(entry.Text, entry.Color);
src.SendMessage(ReplaceVariables(entry.Text, src, args), entry.Color);
}
foreach (var entry in _commands) {
var source = entry.IsConsoleExecutor ? UEssentials.ConsoleSource : src;
source.DispatchCommand(entry.Command);
source.DispatchCommand(ReplaceVariables(entry.Command, src, args));
}
return CommandResult.Success();
}

private string ReplaceVariables(string text, ICommandSource src, ICommandArgs args) {
return text.Replace("%sender%", src.DisplayName);
}

private struct TextEntry {
public string Text;
public Color Color;
Expand Down

0 comments on commit a5340c3

Please sign in to comment.