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

FREE FasterComposters : 1.0.0 1.0.0

Нет прав для скачивания
C#:
using Newtonsoft.Json;
using System;
using System.Linq;
using UnityEngine;

namespace Oxide.Plugins
{
	[Info("Faster Composters", "Tacman", "1.0.0")]
	[Description("Control composters speed with permission")]
    internal class FasterComposters : RustPlugin
    {
		private string permName = "fastercomposters.use";
        #region Config
		static Configuration config;
		public class Configuration
		{
			[JsonProperty(PropertyName = "This is the speed controller, it may take some fine tuning to get the right speed for your server.")]
			public int smeltSpeed;

			public static Configuration DefaultConfig()
			{
				return new Configuration
				{
					smeltSpeed = 10
				};
			}
		}

		protected override void LoadConfig()
		{
			base.LoadConfig();
			try
			{
				config = Config.ReadObject<Configuration>();
				if (config == null) LoadDefaultConfig();
				SaveConfig();
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
				PrintWarning("Creating new configuration file.");
				LoadDefaultConfig();
			}
		}

		protected override void LoadDefaultConfig() => config = Configuration.DefaultConfig();
		protected override void SaveConfig() => Config.WriteObject(config);
		#endregion
		#region Hooks

		void Init()
		{
			permission.RegisterPermission(permName, this);
		}
		void OnEntitySpawned(Composter c)
		{
			if (c == null) return;
			if (config == null) return;
			if (c.OwnerID == 0) return;
			if (!permission.UserHasPermission(c.OwnerID.ToString(), permName)) return;
			c.smeltSpeed = config.smeltSpeed;
		}

		void OnServerInitialized(bool initial)
		{
			foreach (var c in BaseNetworkable.serverEntities.OfType<Composter>())
			{
				if (permission.UserHasPermission(c.OwnerID.ToString(), permName))
					c.smeltSpeed = config.smeltSpeed;
			}
		}
		#endregion
	}
}

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