예제 #1
0
        public MyPromoteLevel ParseMyPromoteLevel(string stringValue)
        {
            MyPromoteLevel myPromoteLevel = new MyPromoteLevel();

            switch (stringValue)
            {
            case "None":
                myPromoteLevel = MyPromoteLevel.None;
                break;

            case "Scripter":
                myPromoteLevel = MyPromoteLevel.SpaceMaster;
                break;

            case "SpaceMaster":
                myPromoteLevel = MyPromoteLevel.SpaceMaster;
                break;

            case "Moderator":
                myPromoteLevel = MyPromoteLevel.Moderator;
                break;

            case "Admin":
                myPromoteLevel = MyPromoteLevel.Admin;
                break;
            }
            return(myPromoteLevel);
        }
예제 #2
0
        static IEnumerable <PropertyInfo> GetConfigurableProperties(object config, MyPromoteLevel promoLevel)
        {
            var properties = config.GetType().GetProperties();

            foreach (var property in properties)
            {
                if (!IsParseablePrimitive(property.PropertyType))
                {
                    continue;
                }
                if (property.GetSetMethod() == null)
                {
                    continue;
                }
                if (property.HasAttribute <ConfigPropertyIgnoreAttribute>())
                {
                    continue;
                }

                if (property.TryGetAttribute(out ConfigPropertyAttribute prop))
                {
                    if (!prop.IsVisibleTo(promoLevel))
                    {
                        continue;
                    }
                }

                yield return(property);
            }
        }
        protected static void ShowPromoteMessage(MyPromoteLevel promoteLevel, bool promote)
        {
            ClearPromoteNotificaions();
            switch (promoteLevel)
            {
            case MyPromoteLevel.None:
                MyHud.Notifications.Add(MyNotificationSingletons.PlayerDemotedNone);
                break;

            case MyPromoteLevel.Scripter:
                MyHud.Notifications.Add(promote ? MyNotificationSingletons.PlayerPromotedScripter : MyNotificationSingletons.PlayerDemotedScripter);
                break;

            case MyPromoteLevel.Moderator:
                MyHud.Notifications.Add(promote ? MyNotificationSingletons.PlayerPromotedModerator : MyNotificationSingletons.PlayerDemotedModerator);
                break;

            case MyPromoteLevel.SpaceMaster:
                MyHud.Notifications.Add(promote ? MyNotificationSingletons.PlayerPromotedSpaceMaster : MyNotificationSingletons.PlayerDemotedSpaceMaster);
                break;

            case MyPromoteLevel.Admin:
                MyHud.Notifications.Add(MyNotificationSingletons.PlayerPromotedAdmin);
                break;

            case MyPromoteLevel.Owner:
                break;

            default:
                throw new ArgumentOutOfRangeException("promoteLevel", promoteLevel, null);
            }
        }
예제 #4
0
 public Command(params string[] names)
 {
     Names              = names;
     m_namedArguments   = new Dictionary <string, NamedArgumentWrapper>();
     m_orderedArguments = new List <Argument>();
     AllowedSessionType = SessionType.ServerDecider;
     MinimumLevel       = MyPromoteLevel.None;
 }
        public bool IsVisibleTo(MyPromoteLevel promoLevel)
        {
            if (promoLevel == MyPromoteLevel.None &&
                Type != ConfigPropertyType.VisibleToPlayers)
            {
                return(false);
            }

            return(true);
        }
예제 #6
0
 public static void PromotePrefix(ulong steamId, MyPromoteLevel level)
 {
     if (ServerManager is MultiplayerManagerDedicated d)
     {
         d.RaisePromoteChanged(steamId, level);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
예제 #7
0
        public void List(string NameOrSteamID)
        {
            if (!Plugin.Config.PluginEnabled)
            {
                return;
            }

            Chat chat = new Chat(Context, true);


            if (Utils.AdminTryGetPlayerSteamID(NameOrSteamID, chat, out ulong SteamID))
            {
                GridMethods methods = new GridMethods(SteamID, Plugin.Config.FolderDirectory);

                if (!methods.LoadInfoFile(out PlayerInfo Data))
                {
                    return;
                }

                if (Data.Grids == null || Data.Grids.Count == 0)
                {
                    chat.Respond("There are no grids in the hangar!");
                    return;
                }


                int MaxStorage = Plugin.Config.NormalHangarAmount;
                if (MySession.Static.PromotedUsers.ContainsKey(SteamID))
                {
                    //prob redundant but ill leave it incase some future leveling system
                    MyPromoteLevel level = MySession.Static.PromotedUsers[SteamID];
                    if (level >= MyPromoteLevel.Scripter)
                    {
                        MaxStorage = Plugin.Config.ScripterHangarAmount;
                    }
                }


                var sb = new StringBuilder();

                sb.AppendLine("Player has " + Data.Grids.Count() + "/" + MaxStorage + " stored grids:");
                //sb.AppendLine("Player has " + Data.Grids.Count() +" stored grids:");
                int count = 1;
                foreach (var grid in Data.Grids)
                {
                    sb.AppendLine(" [" + count + "] - " + grid.GridName);
                    count++;
                }

                chat.Respond(sb.ToString());
            }
        }
        protected void AddPlayer(ulong userId)
        {
            //string playerName = SteamAPI.Instance.Friends.GetPersonaName(userId);
            string playerName = MyMultiplayer.Static.GetMemberName(userId);

            if (String.IsNullOrEmpty(playerName))
            {
                return;
            }

            var row = new MyGuiControlTable.Row(userData: userId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(playerName), userData: playerName));

            var playerId = Sync.Players.TryGetIdentityId(userId);
            var faction  = MySession.Static.Factions.GetPlayerFaction(playerId);

            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Tag : "")));
            row.AddCell(new MyGuiControlTable.Cell(text: new StringBuilder(faction != null ? faction.Name : "")));

            // cell with/without mute checkbox
            MyGuiControlTable.Cell cell = new MyGuiControlTable.Cell(text: new StringBuilder(""));
            row.AddCell(cell);

            if (MyPerGameSettings.EnableMutePlayer && userId != Sync.MyId)
            {
                MyGuiControlCheckbox check = new MyGuiControlCheckbox(toolTip: "", visualStyle: MyGuiControlCheckboxStyleEnum.Muted);
                check.IsChecked         = MySandboxGame.Config.MutedPlayers.Contains(userId);
                check.IsCheckedChanged += IsMuteCheckedChanged;
                check.UserData          = userId;
                cell.Control            = check;

                m_playersTable.Controls.Add(check);
            }

            // cell with admin marker
            StringBuilder  adminString = new StringBuilder();
            MyPromoteLevel userLevel   = MySession.Static.GetUserPromoteLevel(userId);

            for (int i = 0; i < (int)userLevel; i++)
            {
                adminString.Append("*");
            }

            row.AddCell(new MyGuiControlTable.Cell(adminString));
            m_playersTable.Add(row);
        }
예제 #9
0
        private void GetMaxHangarSlot(ulong SteamID)
        {
            MyPromoteLevel UserLvl = MySession.Static.GetUserPromoteLevel(SteamID);

            MaxHangarSlots = Config.NormalHangarAmount;
            if (UserLvl == MyPromoteLevel.Scripter)
            {
                MaxHangarSlots = Config.ScripterHangarAmount;
            }
            else if (UserLvl == MyPromoteLevel.Moderator)
            {
                MaxHangarSlots = Config.ScripterHangarAmount * 2;
            }
            else if (UserLvl >= MyPromoteLevel.Admin)
            {
                MaxHangarSlots = Config.ScripterHangarAmount * 10;
            }
        }
        protected static void Promote(ulong playerId, bool promote)
        {
            if (!MyEventContext.Current.IsLocallyInvoked && !MySession.Static.IsUserAdmin(MyEventContext.Current.Sender.Value))
            {
                MyEventContext.ValidationFailed();
                return;
            }

            MyPromoteLevel targetUserLevel = MySession.Static.GetUserPromoteLevel(playerId);

            if (promote)
            {
                targetUserLevel++;
                if (!MySession.Static.EnableScripterRole && targetUserLevel == MyPromoteLevel.Scripter)
                {
                    targetUserLevel++;
                }
                MySession.Static.PromotedUsers[playerId] = targetUserLevel;
            }
            else
            {
                targetUserLevel--;
                if (!MySession.Static.EnableScripterRole && targetUserLevel == MyPromoteLevel.Scripter)
                {
                    targetUserLevel--;
                }
                if (targetUserLevel > MyPromoteLevel.None)
                {
                    MySession.Static.PromotedUsers[playerId] = targetUserLevel;
                }
                else
                {
                    MySession.Static.PromotedUsers.Remove(playerId);
                }
            }

            if (Sync.IsServer)
            {
                MyMultiplayer.RaiseStaticEvent(x => ShowPromoteMessage, targetUserLevel, promote, new EndpointId(playerId));
            }
            Refresh();
        }
예제 #11
0
 private void GetMaxHangarSlot()
 {
     if (MaxHangarSlots.HasValue)
     {
         _MaxHangarSlots = MaxHangarSlots.Value;
     }
     else
     {
         MyPromoteLevel UserLvl = MySession.Static.GetUserPromoteLevel(SteamID);
         _MaxHangarSlots = Config.NormalHangarAmount;
         if (UserLvl == MyPromoteLevel.Scripter)
         {
             _MaxHangarSlots = Config.ScripterHangarAmount;
         }
         else if (UserLvl == MyPromoteLevel.Moderator)
         {
             _MaxHangarSlots = Config.ScripterHangarAmount * 2;
         }
         else if (UserLvl >= MyPromoteLevel.Admin)
         {
             _MaxHangarSlots = Config.ScripterHangarAmount * 10;
         }
     }
 }
예제 #12
0
 public bool CanPromotionLevelUse(MyPromoteLevel level)
 {
     return(level >= MinimumLevel);
 }
예제 #13
0
 internal void RaisePromoteChanged(ulong steamId, MyPromoteLevel level)
 {
     PlayerPromoted?.Invoke(steamId, level);
 }
예제 #14
0
 static IEnumerable <CommandAttribute> GetCommandMethods(this CommandModule self, MyPromoteLevel maxLevel)
 {
     foreach (var method in self.GetType().GetMethods())
     {
         if (!method.TryGetAttribute <CommandAttribute>(out var command))
         {
             continue;
         }
         if (!method.TryGetAttribute <PermissionAttribute>(out var permission))
         {
             continue;
         }
         if (permission.PromoteLevel > maxLevel)
         {
             continue;
         }
         yield return(command);
     }
 }
예제 #15
0
        public void HandleChatCommand(ulong steamId, string command)
        {
            MyPromoteLevel level = MyAPIGateway.Session.GetUserPromoteLevel(steamId);

            ServerJumpClass.Instance.SomeLog($"Got chat command from {steamId} : {command}");

            if (command.Equals("!join", StringComparison.CurrentCultureIgnoreCase))
            {
                InitJump(steamId);

                return;
            }

            if (command.StartsWith("!join", StringComparison.CurrentCultureIgnoreCase))
            {
                int ind = command.IndexOf(" ");
                if (ind == -1)
                {
                    Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                    return;
                }

                string     numtex = command.Substring(ind);
                ServerItem server;
                int        num;
                if (!int.TryParse(numtex, out num))
                {
                    Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                    return;
                }

                if (!Servers.TryGetValue(num - 1, out server))
                {
                    Communication.SendServerChat(steamId, $"Couldn't find server {num}");
                    return;
                }

                if (!server.CanJoin)
                {
                    Communication.SendServerChat(steamId, "Sorry, this server is not open to new members. Please try another.");
                    return;
                }

                IMyPlayer player = Utilities.GetPlayerBySteamId(steamId);

                var         block = player?.Controller?.ControlledEntity?.Entity as IMyCubeBlock;
                IMyCubeGrid grid  = block?.CubeGrid;
                if (grid == null)
                {
                    Communication.SendServerChat(steamId, "Can't find your ship. Make sure you're seated in the ship you want to take with you.");
                    return;
                }

                var blocks = new List <IMySlimBlock>();
                grid.GetBlocks(blocks);

                if (blocks.Count > Settings.MaxBlockCount)
                {
                    Communication.SendServerChat(steamId, $"Your ship has {blocks.Count} blocks. The limit for this server is {Settings.MaxBlockCount}");
                    return;
                }

                byte[] payload = Utilities.SerializeAndSign(grid, Utilities.GetPlayerBySteamId(steamId), block.Position);
                Communication.SegmentAndSend(Communication.MessageType.ClientGridPart, payload, MyAPIGateway.Multiplayer.ServerId, steamId);

                server.Join(steamId);

                var timer = new Timer(10000);
                timer.AutoReset = false;
                timer.Elapsed  += (a, b) => MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.Close());
                timer.Start();
                return;
            }

            if (command.Equals("!hub", StringComparison.CurrentCultureIgnoreCase))
            {
                if (Settings.Hub)
                {
                    Communication.SendServerChat(steamId, "You're already in the hub!");
                    return;
                }
                Communication.RedirectClient(steamId, Settings.HubIP);
                return;
            }

            if (level >= MyPromoteLevel.Moderator)
            {
                if (command.StartsWith("!spectate", StringComparison.CurrentCultureIgnoreCase))
                {
                    int ind = command.IndexOf(" ");
                    if (ind == -1)
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    string     numtex = command.Substring(ind);
                    ServerItem server;
                    int        num;
                    if (!int.TryParse(numtex, out num))
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    if (!Servers.TryGetValue(num - 1, out server))
                    {
                        Communication.SendServerChat(steamId, $"Couldn't find server {num}");
                        return;
                    }

                    ServerJumpClass.Instance.SomeLog("DeleteFileInLocalStorage");
                    //  MyAPIGateway.Utilities.DeleteFileInLocalStorage("Ship.bin", typeof(ServerJump));
                    Communication.RedirectClient(steamId, server.IP);
                    return;
                }
            }

            if (level >= MyPromoteLevel.Admin)
            {
                if (command.Equals("!reload", StringComparison.CurrentCultureIgnoreCase))
                {
                    //Settings.LoadSettings();
                    Communication.SendServerChat(steamId, "Okay.");
                    return;
                }

                if (command.Equals("!save", StringComparison.CurrentCultureIgnoreCase))
                {
                    // Settings.SaveSettings();
                    Communication.SendServerChat(steamId, "Okay.");
                    return;
                }

                if (command.StartsWith("!reset", StringComparison.CurrentCultureIgnoreCase))
                {
                    int ind = command.IndexOf(" ");
                    if (ind == -1)
                    {
                        foreach (var s in Servers.Values)
                        {
                            s.Reset();
                        }
                        Communication.SendServerChat(steamId, "Reset all servers");
                        return;
                    }

                    string     numtex = command.Substring(ind);
                    ServerItem server;
                    int        num;
                    if (!int.TryParse(numtex, out num))
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    if (Servers.TryGetValue(num - 1, out server))
                    {
                        server.Reset();
                        Communication.SendServerChat(steamId, $"Reset server {num}");
                    }
                }
            }

            if (command.Equals("!help", StringComparison.CurrentCultureIgnoreCase))
            {
                if (level >= MyPromoteLevel.Admin)
                {
                    Communication.SendServerChat(steamId, ADMIN_HELP);
                }
                else
                {
                    if (level >= MyPromoteLevel.Moderator)
                    {
                        Communication.SendServerChat(steamId, MODERATOR_HELP);
                    }
                    else
                    {
                        Communication.SendServerChat(steamId, HELP_TEXT);
                    }
                }
            }
        }
예제 #16
0
        /// <summary>
        ///     Enforces grid rules in hub
        /// </summary>
        private void ProcessEnforcement()
        {
            _entityCache.Clear();
            MyAPIGateway.Entities.GetEntities(_entityCache);

            MyAPIGateway.Parallel.ForEach(_entityCache, entity =>
            {
                var grid = entity as IMyCubeGrid;
                if (grid?.Physics == null)
                {
                    return;
                }

                ulong id = 0;
                if (grid.BigOwners.Any())
                {
                    id = MyAPIGateway.Players.TryGetSteamId(grid.BigOwners[0]);
                }

                MyPromoteLevel level = MyAPIGateway.Session.GetUserPromoteLevel(id);
                if (level < MyPromoteLevel.Admin)
                {
                    if (grid.Physics.LinearVelocity.LengthSquared() > 0.1)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.Physics.LinearVelocity = Vector3.Zero);
                    }
                    if (grid.Physics.AngularVelocity.LengthSquared() > 0.1)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.Physics.AngularVelocity = Vector3.Zero);
                    }

                    if (!grid.IsStatic)
                    {
                        MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.IsStatic = true);
                    }
                }

                var blocks = new List <IMySlimBlock>();
                grid.GetBlocks(blocks);

                var toRaze = new HashSet <IMySlimBlock>();

                foreach (IMySlimBlock slim in blocks)
                {
                    IMyCubeBlock block = slim?.FatBlock;
                    if (block == null)
                    {
                        continue;
                    }

                    if (block is IMyAttachableTopBlock)
                    {
                        toRaze.Add(slim);
                    }

                    if (block is IMyMechanicalConnectionBlock)
                    {
                        toRaze.Add(slim);
                    }

                    var gun = block as IMyUserControllableGun;
                    if (gun != null)
                    {
                        if (gun.Enabled)
                        {
                            gun.Enabled = false;
                        }
                    }

                    var warhead = block as IMyWarhead;
                    if (warhead != null)
                    {
                        if (!warhead.GetValueBool("Safety"))
                        {
                            warhead.SetValueBool("Safety", true);
                        }
                    }
                }

                if (toRaze.Any())
                {
                    Communication.SendServerChat(id, $"The ship {grid.DisplayName} has violated block rules. Some blocks have been removed to enforce rules.");
                }

                blocks.Clear();
                grid.GetBlocks(blocks);
                if (blocks.Count > Settings.Instance.MaxBlockCount)
                {
                    Communication.SendServerChat(id, $"The ship {grid.DisplayName} has gone over the max block count of {Settings.Instance.MaxBlockCount}. Blocks will be removed to enforce rules.");

                    toRaze.UnionWith(blocks.GetRange(Settings.Instance.MaxBlockCount - 1, blocks.Count - Settings.Instance.MaxBlockCount - 1));
                }

                if (toRaze.Any())
                {
                    List <Vector3I> l = toRaze.Select(b => b.Position).ToList();
                    toRaze.Clear();
                    MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.RazeBlocks(l));
                }
            });
        }
예제 #17
0
        public void HandleChatCommand(ulong steamId, string command)
        {
            MyPromoteLevel level = MyAPIGateway.Session.GetUserPromoteLevel(steamId);

            Logging.Instance.WriteLine($"Got chat command from {steamId} : {command}");

            if (command.Equals("!join", StringComparison.CurrentCultureIgnoreCase))
            {
                if (!Settings.Instance.Hub)
                {
                    Communication.SendServerChat(steamId, "Join commands are not valid in battle servers!");
                    return;
                }
                Communication.SendServerChat(steamId, $"There are {Servers.Count} battle servers. Please select the one you want by sending '!join [number]'");
                List <int> availableServers = (from server in Servers.Values where server.CanJoin select server.Index + 1).ToList();

                if (availableServers.Count < Servers.Count)
                {
                    Communication.SendServerChat(steamId, $"These servers are ready for matches: {string.Join(", ", availableServers)}");
                }
                else
                {
                    Communication.SendServerChat(steamId, $"All {Servers.Count} servers are available for new matches!");
                }

                return;
            }

            if (command.StartsWith("!join", StringComparison.CurrentCultureIgnoreCase))
            {
                int ind = command.IndexOf(" ");
                if (ind == -1)
                {
                    Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                    return;
                }

                string     numtex = command.Substring(ind);
                ServerItem server;
                int        num;
                if (!int.TryParse(numtex, out num))
                {
                    Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                    return;
                }

                if (!Servers.TryGetValue(num - 1, out server))
                {
                    Communication.SendServerChat(steamId, $"Couldn't find server {num}");
                    return;
                }

                if (!server.CanJoin)
                {
                    Communication.SendServerChat(steamId, "Sorry, this server is not open to new members. Please try another.");
                    return;
                }

                IMyPlayer player = Utilities.GetPlayerBySteamId(steamId);

                var         block = player?.Controller?.ControlledEntity?.Entity as IMyCubeBlock;
                IMyCubeGrid grid  = block?.CubeGrid;
                if (grid == null)
                {
                    Communication.SendServerChat(steamId, "Can't find your ship. Make sure you're seated in the ship you want to take with you.");
                    return;
                }

                var blocks = new List <IMySlimBlock>();
                grid.GetBlocks(blocks);

                if (blocks.Count > Settings.Instance.MaxBlockCount)
                {
                    Communication.SendServerChat(steamId, $"Your ship has {blocks.Count} blocks. The limit for this server is {Settings.Instance.MaxBlockCount}");
                    return;
                }

                byte[] payload = Utilities.SerializeAndSign(grid, Utilities.GetPlayerBySteamId(steamId), block.Position);
                Communication.SegmentAndSend(Communication.MessageType.ClientGridPart, payload, MyAPIGateway.Multiplayer.ServerId, steamId);

                server.Join(steamId);

                var timer = new Timer(10000);
                timer.AutoReset = false;
                timer.Elapsed  += (a, b) => MyAPIGateway.Utilities.InvokeOnGameThread(() => grid.Close());
                timer.Start();
                return;
            }

            if (command.Equals("!hub", StringComparison.CurrentCultureIgnoreCase))
            {
                if (Settings.Instance.Hub)
                {
                    Communication.SendServerChat(steamId, "You're already in the hub!");
                    return;
                }
                Communication.RedirectClient(steamId, Settings.Instance.HubIP);
                return;
            }

            if (level >= MyPromoteLevel.Moderator)
            {
                if (command.StartsWith("!spectate", StringComparison.CurrentCultureIgnoreCase))
                {
                    int ind = command.IndexOf(" ");
                    if (ind == -1)
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    string     numtex = command.Substring(ind);
                    ServerItem server;
                    int        num;
                    if (!int.TryParse(numtex, out num))
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    if (!Servers.TryGetValue(num - 1, out server))
                    {
                        Communication.SendServerChat(steamId, $"Couldn't find server {num}");
                        return;
                    }

                    MyAPIGateway.Utilities.DeleteFileInLocalStorage("Ship.bin", typeof(LinkModCore));
                    Communication.RedirectClient(steamId, server.IP);
                    return;
                }
            }

            if (level >= MyPromoteLevel.Admin)
            {
                if (command.Equals("!endjoin", StringComparison.CurrentCultureIgnoreCase))
                {
                    _lobbyTimer.Stop();
                    _lobbyRunning = false;
                    _matchRunning = true;
                    Communication.SendNotification(0, "MATCH START!", MyFontEnum.Green);
                    Logging.Instance.WriteLine("Starting match");
                    _matchTimer.Start();
                    return;
                }

                if (command.Equals("!endmatch", StringComparison.CurrentCultureIgnoreCase))
                {
                    _matchTimer.Stop();
                    _matchRunning = false;
                    Communication.SendNotification(0, "MATCH OVER!", MyFontEnum.Red, 10000);
                    Logging.Instance.WriteLine("Ending match");
                    Utilities.ScrubServer();
                    return;
                }

                if (command.Equals("!reload", StringComparison.CurrentCultureIgnoreCase))
                {
                    Settings.LoadSettings();
                    Communication.SendServerChat(steamId, "Okay.");
                    return;
                }

                if (command.Equals("!save", StringComparison.CurrentCultureIgnoreCase))
                {
                    Settings.SaveSettings();
                    Communication.SendServerChat(steamId, "Okay.");
                    return;
                }

                if (command.StartsWith("!reset", StringComparison.CurrentCultureIgnoreCase))
                {
                    int ind = command.IndexOf(" ");
                    if (ind == -1)
                    {
                        foreach (var s in Servers.Values)
                        {
                            s.Reset();
                        }
                        Communication.SendServerChat(steamId, "Reset all servers");
                        return;
                    }

                    string     numtex = command.Substring(ind);
                    ServerItem server;
                    int        num;
                    if (!int.TryParse(numtex, out num))
                    {
                        Communication.SendServerChat(steamId, "Couldn't parse your server selection!");
                        return;
                    }

                    if (Servers.TryGetValue(num - 1, out server))
                    {
                        server.Reset();
                        Communication.SendServerChat(steamId, $"Reset server {num}");
                    }
                }
            }

            if (command.Equals("!help", StringComparison.CurrentCultureIgnoreCase))
            {
                if (level >= MyPromoteLevel.Admin)
                {
                    Communication.SendServerChat(steamId, ADMIN_HELP);
                }
                else
                {
                    if (level >= MyPromoteLevel.Moderator)
                    {
                        Communication.SendServerChat(steamId, MODERATOR_HELP);
                    }
                    else
                    {
                        Communication.SendServerChat(steamId, HELP_TEXT);
                    }
                }
            }
        }
예제 #18
0
 public static bool IsAllowedSpecialOperations(MyPromoteLevel level)
 {
     return(level == MyPromoteLevel.SpaceMaster || level == MyPromoteLevel.Admin || level == MyPromoteLevel.Owner);
 }
예제 #19
0
 private void OnPlayerPromoted(ulong arg1, MyPromoteLevel arg2)
 {
     Dispatcher.InvokeAsync(() => PlayerList.Items.Refresh());
 }
예제 #20
0
 public PermissionAttribute(MyPromoteLevel promoteLevel)
 {
     PromoteLevel = promoteLevel;
 }
예제 #21
0
 public Command PromotedOnly(MyPromoteLevel level)
 {
     MinimumLevel = level;
     return(this);
 }