Decompiled source of ServerClock v1.0.1

ServerClock.dll

Decompiled a month ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ServerClock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ServerClock")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f04816f8-c67c-44dc-bd52-46b80dadc4a7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ServerClock;

[BepInPlugin("com.kingrabbit_serverclock", "Server Clock", "1.0.0")]
public class ServerClockMod : BaseUnityPlugin
{
	private float broadcastTimer = 0f;

	private const float broadcastInterval = 3f;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.kingrabbit_serverclock");
		val.PatchAll();
		Debug.Log((object)"[Server Clock] Server Clock 1.0.0 have been sucessfully loaded");
	}

	private void Update()
	{
		if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
		{
			broadcastTimer += Time.deltaTime;
			if (broadcastTimer >= 3f)
			{
				broadcastTimer = 0f;
				BroadcastToAll();
			}
		}
	}

	private void BroadcastToAll()
	{
		float dayFraction = EnvMan.instance.GetDayFraction();
		float num = dayFraction * 24f;
		int num2 = Mathf.FloorToInt(num);
		int num3 = Mathf.FloorToInt((num - (float)num2) * 60f);
		string text = $"Time: {num2:D2}:{num3:D2}\n";
		List<ZNetPeer> peers = ZNet.instance.GetPeers();
		foreach (ZNetPeer item in peers)
		{
			if (item.IsReady())
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(item.m_uid, "ShowMessage", new object[2] { 1, text });
			}
		}
		ZRoutedRpc.instance.InvokeRoutedRPC(ZDOMan.GetSessionID(), "ShowMessage", new object[2] { 1, text });
		Debug.Log((object)"[Server Clock] Server Clock is broadcasting");
	}
}