protected void HandleChat(byte[] message) { if (!isLoggedIn) return; string incomingText = enc.GetString(message, 1, 64).Trim(); byte incomingID = message[0]; if (incomingID != 0xFF && incomingID != id && incomingID != 0) { //TODO Player.GlobalMessageOps("Player sent a malformed packet!"); Kick("Hacked Client!"); return; } incomingText = Regex.Replace(incomingText, @"\s\s+", " "); foreach (char ch in incomingText) { if (ch < 32 || ch >= 127 || ch == '&') { Kick("Illegal character in chat message!"); return; } } if (incomingText.Length == 0) return; //Get rid of whitespace while (incomingText.Contains(" ")) incomingText.Replace(" ", " "); if (incomingText[0] == '/') { incomingText = incomingText.Remove(0, 1); string[] args = incomingText.Split(' '); HandleCommand(args); return; } if (nextChat != null) { ThreadPool.QueueUserWorkItem(delegate { nextChat.Invoke(this, incomingText, PassBackData); }); nextChat = null; PassBackData = null; return; } Server.Log("<" + USERNAME + "> " + incomingText); UniversalChat(USERNAME + ": &f" + incomingText); }
public void CatchNextChat(NextChatDelegate chat, object data) { PassBackData = data; blockChange = null; nextChat = chat; }
public void CatchNextBlockchange(BlockChangeDelegate change, object data) { if (!ExtraData.ContainsKey("PassBackData")) ExtraData.Add("PassBackData", null); ExtraData["PassBackData"] = data; nextChat = null; blockChange = change; }
public void CatchNextBlockchange(BlockChangeDelegate change, object data) { PassBackData = data; nextChat = null; blockChange = change; }
protected void HandleChat(byte[] message) { if (!isLoggedIn) return; string incomingText = enc.GetString(message, 1, 64).Trim(); byte incomingID = message[0]; if (incomingID != 0xFF && incomingID != id && incomingID != 0) { //TODO Player.GlobalMessageOps("Player sent a malformed packet!"); Kick("Hacked Client!"); return; } incomingText = Regex.Replace(incomingText, @"\s\s+", " "); foreach (char ch in incomingText) { if (ch < 32 || ch >= 127 || ch == '&') { Kick("Illegal character in chat message!"); return; } } if (incomingText.Length == 0) return; //Get rid of whitespace while (incomingText.Contains(" ")) incomingText.Replace(" ", " "); if (incomingText[0] == '/') { incomingText = incomingText.Remove(0, 1); string[] args = incomingText.Split(' '); HandleCommand(args); return; } if (ServerSettings.Appending == true) { if (storedMessage != "") { if (!incomingText.EndsWith(">") && !incomingText.EndsWith("<")) { incomingText = storedMessage.Replace("|>|", " ").Replace("|<|", "") + incomingText; storedMessage = ""; } } if (incomingText.EndsWith(">")) { storedMessage += incomingText.Replace(">", "|>|"); SendMessage("Message appended!"); return; } else if (incomingText.EndsWith("<")) { storedMessage += incomingText.Replace("<", "|<|"); SendMessage("Message appended!"); return; } } if (nextChat != null) { NextChatDelegate tempNextChat = nextChat; object tempPassBack = PassBackData; nextChat = null; PassBackData = null; ThreadPool.QueueUserWorkItem(delegate { tempNextChat.Invoke(this, incomingText, tempPassBack); }); return; } if (Server.voting) { if (Server.kickvote && Server.kicker == this) { SendMessage("You're not allowed to vote!"); return; } if (voted) { SendMessage("You have already voted..."); return; } string vote = incomingText.ToLower(); if (vote == "yes" || vote == "y") { Server.YesVotes++; voted = true; SendMessage("Thanks for voting!"); return; } else if (vote == "no" || vote == "n") { Server.NoVotes++; voted = true; SendMessage("Thanks for voting!"); return; } else { SendMessage("Use either %aYes " + Server.DefaultColor + "or %cNo " + Server.DefaultColor + " to vote!"); } } Server.Log("<" + USERNAME + "> " + incomingText); UniversalChat(USERNAME + ": &f" + incomingText); }