From 79c97c7415bd0513f7ef84ed23dfce3c12b7c5fa Mon Sep 17 00:00:00 2001 From: CyberL1 Date: Sun, 22 Sep 2024 08:31:02 +0200 Subject: [PATCH] fix: check if world's motd is longer than the limit first (idk some C# shenanigans) --- MyMcRealms/Controllers/WorldsController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MyMcRealms/Controllers/WorldsController.cs b/MyMcRealms/Controllers/WorldsController.cs index 0cc4d78..3106cc8 100644 --- a/MyMcRealms/Controllers/WorldsController.cs +++ b/MyMcRealms/Controllers/WorldsController.cs @@ -54,10 +54,16 @@ namespace MyMcRealms.Controllers } if (SemVersion.Parse(gameVerision, SemVersionStyles.OptionalPatch).ComparePrecedenceTo(SemVersion.Parse("1.19.4", SemVersionStyles.OptionalPatch)) < 0) { - world.Motd = world.Motd.Remove(32); // Pre 1.19.4 MOTD limit + if (world.Motd.Length > 32) + { + world.Motd = world.Motd.Remove(32); // Pre 1.19.4 MOTD limit + } } else { - world.Motd = world.Motd.Remove(52); // Post 1.19.4 MOTD limit + if (world.Motd.Length > 52) + { + world.Motd = world.Motd.Remove(52); // Post 1.19.4 MOTD limit + } } WorldResponse response = new()