From ab7cb2d2348e8cb440867ec3698cdf33254ddc8c Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 13 Jun 2024 19:50:50 +0200 Subject: [PATCH] Fix version label --- Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs b/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs index fcbdab09..629898fe 100644 --- a/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs +++ b/Fika.Core/UI/Patches/FikaVersionLabel_Patch.cs @@ -15,20 +15,23 @@ namespace Fika.Core.EssentialPatches /// public class FikaVersionLabel_Patch : ModulePatch { - private static string _versionLabel; + private static string versionLabel; - protected override MethodBase GetTargetMethod() => PatchConstants.EftTypes.Single(x => x.GetField("Taxonomy", BindingFlags.Public | BindingFlags.Instance) != null).GetMethod("Create", BindingFlags.Public | BindingFlags.Static); + protected override MethodBase GetTargetMethod() + { + return typeof(VersionNumberClass).GetMethod(nameof(VersionNumberClass.Create), BindingFlags.Static | BindingFlags.Public); + } [PatchPostfix] internal static void PatchPostfix(string major, object __result) { FikaPlugin.EFTVersionMajor = major; - if (string.IsNullOrEmpty(_versionLabel)) + if (string.IsNullOrEmpty(versionLabel)) { string json = RequestHandler.GetJson("/singleplayer/settings/version"); - _versionLabel = Json.Deserialize(json).Version; - Logger.LogInfo($"Server version: {_versionLabel}"); + versionLabel = Json.Deserialize(json).Version; + Logger.LogInfo($"Server version: {versionLabel}"); } string fikaVersion = Assembly.GetAssembly(typeof(FikaVersionLabel_Patch)).GetName().Version.ToString(); @@ -36,8 +39,8 @@ internal static void PatchPostfix(string major, object __result) Traverse preloaderUiTraverse = Traverse.Create(MonoBehaviourSingleton.Instance); preloaderUiTraverse.Field("_alphaVersionLabel").Property("LocalizationKey").SetValue("{0}"); - preloaderUiTraverse.Field("string_2").SetValue($"Fika {fikaVersion} |"); - Traverse.Create(__result).Field("Major").SetValue($"FIKA BETA {fikaVersion} | {_versionLabel}"); + preloaderUiTraverse.Field("string_2").SetValue($"FIKA BETA {fikaVersion} | {versionLabel}"); + Traverse.Create(__result).Field("Major").SetValue($"{fikaVersion} {versionLabel}"); } } } \ No newline at end of file