C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using System;
using System.ComponentModel;
namespace Oxide.Plugins
{
[Info("Version", "Wulf/lukespragg", "2.1.0", ResourceId = 763)]
[Description("Shows the current Oxide and Rust version info.")]
class Version : RustPlugin
{
// Do NOT edit this file, instead edit Version.json in server/<identity>/oxide/config
#region Configuration
string ChatCommand => GetConfig("ChatCommand", "version");
string Message => GetConfig("Message", "<size=15>Server is running <b><color=#FFB658>Oxide {oxide}</color></b>"
+ " and <b><color=#EE715C>Rust {protocol}</color></b>\n<b>Build:</b> <i>{build}, {date}</i></size>");
protected override void LoadDefaultConfig()
{
Config["ChatCommand"] = ChatCommand;
Config["Message"] = Message;
SaveConfig();
}
#endregion
#region Initialization
void Loaded()
{
LoadDefaultConfig();
cmd.AddChatCommand(ChatCommand, this, "VersionChatCmd");
}
#endregion
#region Chat Command
void VersionChatCmd(BasePlayer player)
{
var oxide = Core.OxideMod.Version.ToString();
var protocol = Rust.Protocol.printable;
var build = BuildInformation.VersionStampDays;
var date = BuildInformation.VersionStampString;
SendReply(player, StringFormat(Message, new { oxide, protocol, build, date }));
}
#endregion
#region Helper Methods
T GetConfig<T>(string name, T defaultValue)
{
if (Config[name] == null) return defaultValue;
return (T)Convert.ChangeType(Config[name], typeof(T));
}
static string StringFormat(string input, object p)
{
foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(p))
input = input.Replace("{" + prop.Name + "}", (prop.GetValue(p) ?? "(null)").ToString());
return input;
}
#endregion
}
}