예제 #1
0
        public void HasCommandPermission(Command command, IMyPlayer player, bool hasPermission, ref bool?hasPermissionOverride)
        {
            if (!EssentialsPlugin.Instance.Config.EnableRanks)
            {
                return;
            }

            string playersRank = PlayerAccountModule.GetRank(player.SteamUserId);
            string cmd         = "";

            foreach (var part in command.Path)
            {
                cmd += part + " ";
            }
            cmd = cmd.TrimEnd();
            bool hasPerm = RankHasPermission(playersRank, cmd, player.SteamUserId);

            if (!debug)
            {
                Log.Error($"HasPerm returned {hasPerm}");
            }

            if (EssentialsPlugin.Instance.Config.OverrideVanillaPerms && hasPerm)
            {
                hasPermissionOverride = hasPerm;
            }

            if (hasPermission && !hasPerm)
            {
                hasPermissionOverride = hasPerm;
                Log.Info($"{player.DisplayName} tried to use the blocked command '{cmd}'");
                ModCommunication.SendMessageTo(new NotificationMessage($"You do not have permission to use that command!", 10000, "Red"), player.SteamUserId);
            }
        }