C#:
using System;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Oxide.Core;
// Created by https://codefling.com/neko
// https://codefling.com/plugins/wipe-settings
// Last Updated: 24.07.2025
//
// Changelog
// 1.0.2:
// - Now remembers the original hostname/description and reverts to it on unload
// - Fixed incorrect hook method
// - Removed unnecessary code
// 1.0.1:
// - Introduced {just} placeholder text to allow custom JUST WIPED placement
namespace Oxide.Plugins
{
[Info("WipeSettings", "Kitty", "1.0.2")]
[Description("A simple plugin to set your hostname & description when your server wipes.")]
public class WipeSettings : RustPlugin
{
#region Decs
private Configuration _Config;
private Data _Data;
private Timer _Loop;
private string _originalHostname;
private string _originalDescription;
#endregion
#region Config
private class Configuration
{
[JsonProperty("Date Format (dd, mm)")] public string DateFormat = "dd/mm";
[JsonProperty("How many days counts as 'Just Wiped'?")] public int JustWipedDays = 1;
[JsonProperty("What text should be added if the server is 'Just Wiped'?")] public string JustWipedText = "JUST WIPED ";
[JsonProperty("Hostname ({wipe} goes where you want the wipe text, {just} goes where JUST WIPED should go)")] public string Hostname = "{just}My Server | Active Admins | {wipe}";
[JsonProperty("Description ({wipe} goes where you want the wipe text, 'Just Wiped' will not be added here)")] public string Description = "Welcome to XXYY, join our discord: discord.gg/abcdef\nLast wipe was on {wipe}";
[JsonProperty("Hostname Update Interval (seconds)")] public int Interval = 3600;
}
protected override void LoadDefaultConfig() => _Config = new Configuration();
protected override void LoadConfig()
{
base.LoadConfig();
try
{
_Config = Config.ReadObject<Configuration>();
if (_Config == null)
{
throw new JsonException();
}
}
catch
{
Puts("Config file is invalid, loading defaults instead");
LoadDefaultConfig();
}
}
protected override void SaveConfig()
{
Config.WriteObject(_Config, true);
}
#endregion
#region Data
private void LoadData() => _Data = Interface.Oxide.DataFileSystem.ReadObject<Data>(Name);
private void SaveData() => Interface.Oxide.DataFileSystem.WriteObject(Name, _Data);
private class Data
{
[JsonProperty("Last Wipe")] public string LastWipe;
}
#endregion
#region Hooks
[UsedImplicitly]
private void Loaded()
{
_originalHostname = ConVar.Server.hostname;
_originalDescription = ConVar.Server.description;
LoadData();
SaveData();
if (_Config.Interval > 0) _Loop = timer.Every(_Config.Interval, UpdateConvars);
UpdateConvars();
}
[UsedImplicitly]
private void Unload()
{
SaveData();
if (_Config.Interval > 0) _Loop.Destroy();
ConVar.Server.hostname = _originalHostname;
ConVar.Server.description = _originalDescription;
}
[UsedImplicitly]
private void OnNewSave()
{
_Data.LastWipe = CurrentDate();
UpdateConvars();
SaveData();
}
#endregion
#region Helpers
private static DateTime GetDate(string date)
{
return DateTime.ParseExact(date, "G", null);
}
private static string CurrentDate() => DateTime.Now.ToString("G");
private string FormatText(string text, bool insertJustWipedText = false)
{
// Oxide fails to compile ??= so just do it the old fashioned way
if (_Data.LastWipe == null)
{
_Data.LastWipe = CurrentDate();
SaveData();
}
var wipeDate = GetDate(_Data.LastWipe);
var dateFmt = _Config.DateFormat.Replace("dd", wipeDate.Day.ToString()).Replace("mm", wipeDate.Month.ToString());
if (!insertJustWipedText)
return text.Replace("{wipe}", dateFmt);
var justWiped = (DateTime.Now - wipeDate).Days <= _Config.JustWipedDays ? _Config.JustWipedText : "";
return text.Replace("{wipe}", dateFmt).Replace("{just}", justWiped);
}
private void UpdateConvars()
{
ConVar.Server.hostname = FormatText(_Config.Hostname, true);
ConVar.Server.description = FormatText(_Config.Description);
}
#endregion
}
}