// This is called by the mod runner before connecting to the game server during startup. public void Start(IGameServerConnection gameServerConnection) { // figure out the path to the setting file in the same folder where this DLL is located. var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "DiscordBotMod_Settings.yaml"; // save connection to game server for later use _gameServerConnection = gameServerConnection; // This deserializes the yaml config file _config = EmpyrionModApi.BaseConfiguration.GetConfiguration <Configuration>(configFilePath); // Tell the string to use for "!MODS" command. _gameServerConnection.AddVersionString(k_versionString); _discordClient = new DiscordClient(new DiscordConfiguration { Token = _config.DiscordToken, TokenType = TokenType.Bot }); // Subscribe for the chat event _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _discordClient.MessageCreated += async e => { DSharpPlus.Entities.DiscordChannel discordChannel; lock (_discordClient) { discordChannel = _discordChannel; } if (e.Author != _discordClient.CurrentUser) { if (e.Message.Content == "cb:get_online_users") { // build list of online players: string onlinePlayers = string.Join("\n", from player in _gameServerConnection.GetOnlinePlayers().Values select player.DisplayName); var dmUserChannel = await _discordClient.CreateDmAsync(e.Author); await _discordClient.SendMessageAsync(dmUserChannel, $"Online Players:\n{onlinePlayers}"); } else if (e.Channel == discordChannel) { await _gameServerConnection.SendChatMessageToAll(string.Format(_config.FromDiscordFormattingString, e.Author.Username, e.Message.Content)); } } }; _discordClient.ConnectAsync() .ContinueWith(async t => { var channel = await _discordClient.GetChannelAsync(_config.ChannelId); lock (_discordClient) { _discordChannel = channel; } }); }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); _gameServerConnection = gameServerConnection; _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ConsoleCommand += OnEvent_ConsoleCommand; }
public void Start(IGameServerConnection gameServerConnection) { var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "FactionPlayfieldKickerMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_Player_ChangedPlayfield += OnEvent_Player_ChangedPlayfield; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "ShipBuyingMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "VotingRewardMod_Settings.yaml"; _traceSource.TraceEvent(TraceEventType.Verbose, 3, "Loaded configuration."); _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _voteLogPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\VoteLog"; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "NoKillZonesMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _jailLocation = new WorldPosition(_gameServerConnection, _config.JailLocation); _jailExitLocation = new WorldPosition(_gameServerConnection, _config.JailExitLocation); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _gameServerConnection.Event_PlayerDied += OnEvent_PlayerDied; }
// This is called by the mod runner before connecting to the game server during startup. public void Start(IGameServerConnection gameServerConnection) { // figure out the path to the setting file in the same folder where this DLL is located. var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "SellToServerMod_Settings.yaml"; // save connection to game server for later use _gameServerConnection = gameServerConnection; // This deserializes the yaml config file _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); // Tell the string to use for "!MODS" command. _gameServerConnection.AddVersionString(k_versionString); // Subscribe for the chat event _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "FactionStorageConverterMod_Settings.yaml"; _fileStoragePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\SavedData"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); //--- Load Server Config Items LoadServerConfigItems(); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "StructureOwnershipMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _factionRewardTimer = new Timer(_config.CaptureRewardPeriodInMinutes * 1000.0 * 60.0); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_Faction_Changed += OnEvent_Faction_Changed; _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _factionRewardTimer.Elapsed += OnFactionRewardTimer_Elapsed; if (!_factionRewardTimer.Enabled) { _factionRewardTimer.Start(); } }