コード例 #1
0
ファイル: RCONManager.cs プロジェクト: KianFitz/ARKDiscordBot
        internal async Task ShutdownServerAsync(string serverName)
        {
            StatusClass server = null;

            server = Globals.Servers.Find(x => x.Connected && x.Name == serverName);

            if (server is null)
            {
                return;
            }

            await server.SendSaveAndShutdownCommand().ConfigureAwait(false);
        }
コード例 #2
0
ファイル: RCONManager.cs プロジェクト: KianFitz/ARKDiscordBot
        private void LoadServerData()
        {
            foreach (var server in _config.GetSection("servers").GetChildren())
            {
                string name         = server.Key;
                string ip           = server["ip"];
                string port         = server["port"];
                string rconpassword = server["password"];
                string mapname      = server["mapname"];

                StatusClass sc = new StatusClass(name, ip, port, rconpassword, mapname, this);
                Globals.Servers.Add(sc);
            }

            _log.Info($"LoadServerData returned {Globals.Servers.Count} entries.");
        }
コード例 #3
0
        public async Task CloseWorld()
        {
            IUser  user = Context.User;
            Player plr  = _storage.Players.Find(x => x.DiscordId == user.Id);

            if (plr is null)
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.DiscordUserNoPlayer(user)).ConfigureAwait(false);

                return;
            }

            Team team = _storage.Teams.Find(x => x.Id == plr.TeamId);

            if (team is null)
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.UserNotOnTeam(plr)).ConfigureAwait(false);

                return;
            }

            if (string.IsNullOrEmpty(team.OpenMap))
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.NoMapOpen(team)).ConfigureAwait(false);

                return;
            }

            await Context.Channel.SendMessageAsync("", false, Embeds.TeamClosedWorld(team));

            StatusClass server = Globals.Servers.Find(x => x.MapName == team.OpenMap);

            server.RemoveTeamFromWhiteList(team);

            try
            {
                server.KickAllTeamPlayers(team).Wait();
            }
            catch (Exception ex)
            {
                _log.Info(ex);
            }

            team.OpenMap = "";
            await _commands.UpdateHoursRemaining(Embeds.TeamCurrency(_storage.Teams));
        }
コード例 #4
0
        public async Task OpenWorld(string serverName)
        {
            IUser  user = Context.User;
            Player plr  = _storage.Players.Find(x => x.DiscordId == user.Id);

            if (plr is null)
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.DiscordUserNoPlayer(user)).ConfigureAwait(false);

                return;
            }
            Team team = _storage.Teams.Find(x => x.Id == plr.TeamId);

            if (team is null)
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.UserNotOnTeam(plr)).ConfigureAwait(false);

                return;
            }
            if (team.MinutesRemaining <= 0)
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.TeamNoTimeLeft(team)).ConfigureAwait(false);

                return;
            }
            if (!string.IsNullOrEmpty(team.OpenMap))
            {
                await Context.Channel.SendMessageAsync("", false, Embeds.MapAlreadyOpen(team)).ConfigureAwait(false);

                return;
            }

            if (ValidateWorldExists(serverName))
            {
                StatusClass server = Globals.Servers.Find(x => x.Name == serverName);
                server.WhiteListTeam(team);
                team.OpenMap = server.MapName;
            }

            await Context.Channel.SendMessageAsync("", false, Embeds.TeamOpenedWorld(team)).ConfigureAwait(false);

            await _commands.UpdateHoursRemaining(Embeds.TeamCurrency(_storage.Teams));
        }