From dc4cd0f4eea725fd43f03b1f4bd47fda55247b09 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 15 Oct 2017 20:16:11 +1100 Subject: [PATCH] Discord emotes in custom chat tokens now --- MCGalaxy/Chat/ChatTokens.cs | 17 +++++++++++++---- MCGalaxy/Commands/World/CmdBlockProperties.cs | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/MCGalaxy/Chat/ChatTokens.cs b/MCGalaxy/Chat/ChatTokens.cs index 22515afc4..4b3c89885 100644 --- a/MCGalaxy/Chat/ChatTokens.cs +++ b/MCGalaxy/Chat/ChatTokens.cs @@ -126,11 +126,20 @@ namespace MCGalaxy { char[] colon = new char[] {':'}; foreach (string line in lines) { - if (line.StartsWith("//")) continue; - string[] parts = line.Split(colon, 2); - if (parts.Length == 1) continue; // not a proper line + if (line.StartsWith("//") || line.Length == 0) continue; + // Need to handle special case of :discord: emotes + int offset = 0; + if (line[0] == ':') { + int emoteEnd = line.IndexOf(':', 1); + if (emoteEnd == -1) continue; + offset = emoteEnd + 1; + } - string key = parts[0].Trim(), value = parts[1].Trim(); + int separator = line.IndexOf(':', offset); + if (separator == -1) continue; // not a proper line + + string key = line.Substring(0, separator).Trim(); + string value = line.Substring(separator + 1).Trim(); if (key.Length == 0) continue; Custom.Add(new ChatToken(key, value, null)); } diff --git a/MCGalaxy/Commands/World/CmdBlockProperties.cs b/MCGalaxy/Commands/World/CmdBlockProperties.cs index 21d65ce1f..30d25e1ce 100644 --- a/MCGalaxy/Commands/World/CmdBlockProperties.cs +++ b/MCGalaxy/Commands/World/CmdBlockProperties.cs @@ -270,8 +270,8 @@ namespace MCGalaxy.Commands.World { Player.Message(p, "%HSets various properties for blocks."); Player.Message(p, "%H[scope] can be: %Score, global, level"); - Player.Message(p, "%Hproperties: %Sportal, messageblock, rails, waterkills, " + - "lavakills, door, tdoor, killer, deathmessage, animalai, stackblock, opblock, odoor, drownable"); + Player.Message(p, "%Hproperties: %Sportal, messageblock, rails, waterkills, lavakills, door, tdoor, " + + "killer, deathmessage, animalai, stackblock, opblock, odoor, drownable, grass, block"); Player.Message(p, "%HType %T/Help BlockProps [property] %Hfor more details"); }