Иконка ресурса

FREE HideGameTipNames : 1.0.1 1.0.1

Нет прав для скачивания
C#:
using Network;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Oxide.Plugins
{
    [Info("Hide Game Tip Names", "YaMang -w-", "1.0.1")]
    [Description("BLOCKED BY PLAYER 'HIDENAMES'")]
    public class HideGameTipNames : RustPlugin
    {
        #region Fields
        private const string BypassPerm = "hidegametipnames.bypass";
        Regex blockedPattern = new Regex(@"Blocked by Player (.+)", RegexOptions.Compiled);
        #endregion

        #region Hook

        void OnServerInitialized(bool initial)
        {
            permission.RegisterPermission(BypassPerm, this);
        }

        private void OnSendCommand(Connection connection, string command, object[] args)
        {
            if (command != "gametip.showtoast_translated" || args.Length < 3) return;

            var player = connection.player as BasePlayer;
            if (player == null) return;
            if(permission.UserHasPermission(player.UserIDString, BypassPerm)) return;
            var message = args[2].ToString();
            if (!message.Contains("Blocked by Player")) return;

            Match match = blockedPattern.Match(message);
            if (match.Success)
            {
                string sucess = match.Groups[1].Value;
                args[2] = message.Replace(sucess, _config.generalSettings.HideNames.GetRandom());
            }
        }
        #endregion

        #region Config
        private ConfigData _config;
        private class ConfigData
        {
            [JsonProperty(PropertyName = "General Settings")] public GeneralSettings generalSettings { get; set; }
            public Oxide.Core.VersionNumber Version { get; set; }
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            _config = Config.ReadObject<ConfigData>();

            if (_config.Version < Version)
                UpdateConfigValues();

            Config.WriteObject(_config, true);
        }

        protected override void LoadDefaultConfig() => _config = GetBaseConfig();

        private ConfigData GetBaseConfig()
        {
            return new ConfigData
            {
                generalSettings = new GeneralSettings
                {
                    HideNames = new List<string>
                    {
                        "???",
                        "UNKNOWN",
                        "NONAME"
                    },
                    Debug = false
                },
                Version = Version
            };
        }

        public class GeneralSettings
        {
            [JsonProperty(PropertyName = "Hide Names", Order = 1)] public List<string> HideNames { get; set; }

            [JsonProperty(PropertyName = "Debug", Order = 20)] public bool Debug { get; set; }
        }


        protected override void SaveConfig() => Config.WriteObject(_config, true);

        private void UpdateConfigValues()
        {
            PrintWarning("Config update detected! Updating config values...");
            _config.Version = Version;
            PrintWarning("Config update completed!");
        }

        #endregion
    }
}

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху