public override void GameEvent(IProtocolEventArgs e) { // Unless you specifically want to override some of the plugins default // functionality, you should always call the base method. base.GameEvent(e); // See Potato.Net.GameEventType enum for descriptions of each possible event. if (e.ProtocolEventType == ProtocolEventType.ProtocolChat) { ChatModel chat = e.Now.Chats.First(); String text = chat.Now.Content.First(); PlayerModel talker = chat.Now.Players.First(); Console.WriteLine("Program.GameEvent.GameChat: {0} said \"{1}\"", talker.Name, text); } // else more! }
/// <summary> /// Mocks a call to the protocol event /// </summary> public void MockProtocolEvent(IProtocolEventArgs args) { if (this.ProtocolEvent != null) { this.ProtocolEvent(this, args); } }
public void FireProtocolEvent(IProtocolEventArgs args) { if (this.ProtocolEvent != null) { this.ProtocolEvent(args); } }
public virtual void GameEvent(IProtocolEventArgs e) { // Apply any changes to the protocol state for this plugin if (e.StateDifference != null) { this.ProtocolState.Apply(e.StateDifference); } }
private void Connection_GameEvent(IProtocolEventArgs e) { if (this.ProtocolEventStream != null) { this.ProtocolEventStream.Call(e); } }
/// <summary> /// This function is pretty much a plugin on it's own that only dispatches events from the game. /// /// I might put this into it's own class at some point to seperate the GameConnection from an action Potato is taking. /// </summary> /// <param name="e"></param> private void Protocol_ProtocolEvent(IProtocolEventArgs e) { if (e.StateDifference != null) { this.ProtocolState.Apply(e.StateDifference); } if (this.Shared.Variables.Get<List<String>>(CommonVariableNames.ProtocolEventsIgnoreList).Contains(e.ProtocolEventType.ToString()) == false) { this.Shared.Events.Log(new GenericEvent() { Name = e.ProtocolEventType.ToString(), Then = GenericEventData.Parse(e.Then), Now = GenericEventData.Parse(e.Now), Scope = new CommandData() { Connections = new List<ConnectionModel>() { this.ConnectionModel } }, Stamp = e.Stamp }); } if (e.ProtocolEventType == ProtocolEventType.ProtocolChat) { ChatModel chat = e.Now.Chats.First(); // At least has the first prefix character // and a little something-something to pass to // the parser. if (chat.Now.Content != null && chat.Now.Content.Count > 0 && chat.Now.Content.First().Length >= 2) { String prefix = chat.Now.Content.First().First().ToString(CultureInfo.InvariantCulture); String text = chat.Now.Content.First().Remove(0, 1); bool execute = prefix == this.Shared.Variables.Get<String>(CommonVariableNames.TextCommandPublicPrefix) || prefix == this.Shared.Variables.Get<String>(CommonVariableNames.TextCommandProtectedPrefix) || prefix == this.Shared.Variables.Get<String>(CommonVariableNames.TextCommandPrivatePrefix); if (execute == true) { this.Tunnel(new Command() { Origin = CommandOrigin.Plugin, Authentication = { GameType = this.ConnectionModel.ProtocolType.Type, Uid = chat.Now.Players.First().Uid }, CommandType = CommandType.TextCommandsExecute, Parameters = new List<ICommandParameter>() { new CommandParameter() { Data = { Content = new List<String>() { text } } } } }); } } } if (this.ProtocolEvent != null) { this.ProtocolEvent(e); } }