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

FREE GatherBlocking : 1.0.1 1.0.1

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Oxide.Plugins
{
    [Info("GatherBlocking", "DylanSMR", "1.0.1", ResourceId = 2552)]
    [Description("A plugin to block gathering via certain tools.")]

    class GatherBlocking : RustPlugin
    {
        #region Configuration
        static Configuration config;

        public class Configuration
        {
            [JsonProperty(PropertyName = "The list of tools that cannot gather.Based on their item name.")]
            public List<string> BlockedItems;

            public static Configuration DefaultConfig()
            {
                return new Configuration
                {
                    BlockedItems = new List<string>(){ "knife.bone", "bone.club" },
                };
            }
        }
        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config == null)
                {
                    LoadDefaultConfig();
                    SaveConfig();
                }
            }
            catch
            {
                PrintWarning($"Creating new config file.");
                LoadDefaultConfig();
            }
        }
        protected override void LoadDefaultConfig() => config = Configuration.DefaultConfig();
        protected override void SaveConfig() => Config.WriteObject(config);
        #endregion
        #region Gather
        void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
        {
            if (entity.ToPlayer() == null) return;
            if (config.BlockedItems.Contains(entity.ToPlayer().GetHeldEntity().GetItem().info.shortname))
            {
                item.amount = 0;
                SendReply(entity.ToPlayer(), string.Format(lang.GetMessage("CannotGather", this, entity.ToPlayer().UserIDString), entity.ToPlayer().GetHeldEntity().GetItem().info.displayName.english));
            }
        }
        void Loaded() => lang.RegisterMessages(new Dictionary<string, string>() { { "CannotGather", "You may not gather with the tool of: {0}" } }, this);
        #endregion
    }
}

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