void HandlePlayerAction(Player p, PlayerAction action, string message, bool stealth) { if (!p.level.SeesServerWideChat || action != PlayerAction.Me) { return; } bot.Say("*" + p.DisplayName + " " + message, stealth); }
private void txtInput_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtInput.Text == null || txtInput.Text.Trim() == "") { return; } string text = txtInput.Text.Trim(); string newtext = text; if (txtInput.Text[0] == '#') { newtext = text.Remove(0, 1).Trim(); Player.GlobalMessageOps("Aux Ops -" + Server.DefaultColor + "Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + newtext); Server.s.Log("(OPs): Console: " + newtext); IRCBot.Say("Console: " + newtext, true); // WriteLine("(OPs):<CONSOLE> " + txtInput.Text); txtInput.Clear(); } else { Player.GlobalMessage("Console [&a" + Server.ZallState + Server.DefaultColor + "]: &f" + txtInput.Text); IRCBot.Say("Console [" + Server.ZallState + "]: " + txtInput.Text); WriteLine("<CONSOLE> " + txtInput.Text); txtInput.Clear(); } } }
public static void handleChat(string s) { string st = ""; switch (s[0]) { case '!': case '/': handleComm(s.Remove(0, 1)); break; case '@': st = s.Remove(0, 1).Trim(); string[] words = st.Split(new char[] { ' ' }, 2); Player who = Player.Find(words[0]); if (who == null) { Console.WriteLine("Player could not be found!"); handleChat(Console.ReadLine()); return; } who.SendMessage("&bFrom Console: &f" + words[1]); Server.s.Log("(whispers to " + who.name + ") <CONSOLE> " + words[1]); if (!Server.devs.Contains(who.name.ToLower())) { Player.GlobalMessageDevs("To Devs &f-" + Server.DefaultColor + "Console &b[>] " + who.color + who.name + "&f- " + words[1]); } //AllServerChat.Say("(whispers to " + who.name + ") <CONSOLE> " + words[1]); break; case '#': st = s.Remove(0, 1); Player.GlobalMessageOps("To Ops &f-" + Server.DefaultColor + " Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + st); Server.s.Log("(OPs): Console: " + st); //Server.s.OpLog("Console: " + text); IRCBot.Say("Console [" + Server.ZallState + "]: " + st, true); //AllServerChat.Say("(OPs) Console [" + Server.ZallState + "]: " + st); break; case ';': st = s.Remove(0, 1); Player.GlobalMessageAdmins("To Admins &f-" + Server.DefaultColor + " Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + st); Server.s.Log("(Admins): Console: " + st); //Server.s.OpLog("Console: " + text); //IRCBot.Say("Console [" + Server.ZallState + "]: " + st, true); //AllServerChat.Say("(Admins) Console [" + Server.ZallState + "]: " + st); break; default: Player.GlobalChat(null, "Console [&a" + Server.ZallState + Server.DefaultColor + "]: &f" + s, false); Server.s.Log("<CONSOLE> " + s); IRCBot.Say("Console [" + Server.ZallState + "]: " + s); break; } handleChat(Console.ReadLine()); }
public void WorkerTick(object sender) { if (shouldRun) { User[] activeUsers; lock (Users) { activeUsers = Users.Values.Where(u => u.HasMessages).ToArray(); } foreach (var user in activeUsers) { host.Say(user.Username, user.NextMessage); } } }
public void Blockchange(Player p, ushort x, ushort y, ushort z, byte type) { try { if (x >= width || y > depth || z >= height) { p.Kick("Building outside boundaries!"); return; } if (y == depth) { return; } byte b = GetTile(x, y, z); if (Block.Convert(b) != Block.Convert(type)) //Should save bandwidth sending identical looking blocks, like air/op_air changes. { Player.GlobalBlockchange(this, x, y, z, type); } if (b == Block.sponge && (Physics == Physics.Normal || Physics == Physics.Advanced) && type != Block.sponge) { PhysSpongeRemoved(PosToInt(x, y, z)); } SetTile(x, y, z, type); //Updates server level blocks if (Physics > 0) { if (Block.Physics(type)) { AddCheck(PosToInt(x, y, z)); } } changed = true; } catch (Exception e) { Logger.Log(p.name + " has triggered a block change error in Map on " + name, LogType.Error); Logger.Log(e.Message, LogType.ErrorMessage); Player.GlobalMessageOps(p.name + " has triggered a block change error in level.cs on " + name); IRCBot.Say(p.name + " has triggered a block change error in level.cs on " + name); } }
public void WorkerTick(object sender) { if (shouldRun) { User nextUser = null; lock (_postQueue) { if (_postQueue.Count > 0) { nextUser = _PostQueue.Dequeue(); } } if (nextUser != null) { host.Say(nextUser.Username, nextUser.NextMessage); } } }
public static void handleComm(string s) { if (s == "") { goto handle; } switch (s[0]) { case '/': case '!': // Command string cmd = "", msg = ""; s = s.Remove(0, 1); if (s.IndexOf(' ') != -1) { cmd = s.Split(' ')[0]; msg = s.Substring(s.IndexOf(' ') + 1); } else if (s != "") { cmd = s; } else { WriteLine("CONSOLE: Whitespace commands are not allowed"); goto handle; } try { Command c = Command.all.Find(cmd); if (c != null) { if (c.consoleUsable) { c.Use(null, msg); WriteLine("CONSOLE: USED /" + cmd + " " + msg); } else { WriteLine("CONSOLE: Cannot use /" + cmd); } } else { WriteLine("CONSOLE: Command /" + cmd + " not found"); } } catch (Exception e) { Server.ErrorLog(e); WriteLine("CONSOLE: Failed command"); } break; case '#': // OP Chat s = s.Remove(0, 1); Player.GlobalMessageOps("To Ops &f-" + Server.DefaultColor + "Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + s); Server.s.Log("(OPs): Console: " + s); IRCBot.Say("Console: " + s, true); break; case ';': // Admin Chat s = s.Remove(0, 1); Player.GlobalMessageAdmins("To Admins &f-" + Server.DefaultColor + "Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + s); Server.s.Log("(Admins): Console: " + s); IRCBot.Say("Console: " + s, true); break; case '\\': // Global Chat s = s.Remove(0, 1); Player.GlobalMessageGC(Server.gcColor + "[Global][" + Server.gcNick + "] Console: &f" + s); Server.s.Log("[Global][" + Server.gcNick + "] Console: " + s); GlobalBot.Say("Console: " + s); break; default: // Chat Player.GlobalMessage("Console [&a" + Server.ZallState + Server.DefaultColor + "]: &f" + s); IRCBot.Say("Console [" + Server.ZallState + "]: " + s); WriteLine("<CONSOLE> " + s); break; } handle: handleComm(Console.ReadLine()); // OLD (MCLawl) MESSAGE HANDLING /* * string sentCmd = "", sentMsg = ""; * * if (s.IndexOf(' ') != -1) * { * sentCmd = s.Split(' ')[0]; * sentMsg = s.Substring(s.IndexOf(' ') + 1); * } * else if (s != "") * { * sentCmd = s; * } * else * { * goto talk; * } * * try * { * Command cmd = Command.all.Find(sentCmd); * if (cmd != null) * { * if (cmd.consoleUsable) * { * cmd.Use(null, sentMsg); * WriteLine("CONSOLE: USED /" + sentCmd + " " + sentMsg); * handleComm(Console.ReadLine()); * } * else * { * WriteLine("CONSOLE: Cannot use /" + sentCmd); * handleComm(Console.ReadLine()); * } * return; * } * } * catch (Exception e) * { * Server.ErrorLog(e); * WriteLine("CONSOLE: Failed command."); * handleComm(Console.ReadLine()); * return; * } * * * talk: handleComm("say " + MCSong.Group.findPerm(LevelPermission.Admin).color + "Console: &f" + s); * handleComm(Console.ReadLine()); */ }
public void HandleChat(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter) { string text = txtInput.Text.Trim(); switch (text[0]) { case '/': if (text == "/") { Log("No command entered."); txtInput.Clear(); return; } HandleCommand(text.Remove(0, 1)); break; case '#': text = text.Remove(0, 1); Player.GlobalMessageOps("To Ops &f-" + Server.DefaultColor + " Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + text); //WriteLine("(OPs): Console: " + text); Server.s.Log("(OPs): Console: " + text); //Server.s.OpLog("Console: " + text); IRCBot.Say("Console: " + text, true); //AllServerChat.Say("(OPs) Console [" + Server.ZallState + "]: " + text); MCDawn.Gui.Window.thisWindow.WriteOpLine("<CONSOLE>" + text); break; case ';': text = text.Remove(0, 1); Player.GlobalMessageAdmins("To Admins &f-" + Server.DefaultColor + " Console [&a" + Server.ZallState + Server.DefaultColor + "]&f- " + text); Server.s.Log("(Admins): Console: " + text); //WriteLine("(Admins): Console: " + text); //Server.s.AdminLog("Console: " + text); //IRCBot.Say("Console: " + text, true); //AllServerChat.Say("(Admins) Console [" + Server.ZallState + "]: " + text); MCDawn.Gui.Window.thisWindow.WriteAdminLine("<CONSOLE>" + text); break; case '@': text = text.Remove(0, 1).Trim(); string[] words = text.Split(new char[] { ' ' }, 2); Player who = Player.Find(words[0]); if (who == null) { Server.s.Log("Player could not be found!"); txtInput.Clear(); return; } who.SendMessage("&bFrom Console: &f" + words[1]); Server.s.Log("(whispers to " + who.name + ") <CONSOLE> " + words[1]); //WriteLine("(whispers to " + who.name + ") <CONSOLE> " + words[1]); if (!Server.devs.Contains(who.name.ToLower())) { Player.GlobalMessageDevs("To Devs &f-" + Server.DefaultColor + "Console &b[>] " + who.color + who.name + "&f- " + words[1]); } //AllServerChat.Say("(whispers to " + who.name + ") <CONSOLE> " + words[1]); break; default: if (String.IsNullOrEmpty(text)) { return; } Player.GlobalChat(null, "Console [&a" + Server.ZallState + Server.DefaultColor + "]:&f " + text, false); IRCBot.Say("Console [" + Server.ZallState + "]: " + text); Server.s.Log("<CONSOLE> " + text); //AllServerChat.Say("Console [" + Server.ZallState + "]: " + text); break; } txtInput.Clear(); } } catch (Exception ex) { Server.ErrorLog(ex); } }
void HandleModerationAction(ModAction e) { if (!Server.IRC.Enabled || !e.Announce) { return; } switch (e.Type) { case ModActionType.Warned: Bot.Say(e.FormatMessage(e.TargetName, "&ewarned")); break; case ModActionType.Ban: Bot.Say(e.FormatMessage(e.TargetName, "&8banned")); break; case ModActionType.Unban: Bot.Say(e.FormatMessage(e.TargetName, "&8unbanned")); break; case ModActionType.BanIP: Bot.Say(e.FormatMessage(e.TargetName, "&8IP banned"), true); Bot.Say(e.FormatMessage("An IP", "&8IP banned")); break; case ModActionType.UnbanIP: Bot.Say(e.FormatMessage(e.TargetName, "&8IP unbanned"), true); Bot.Say(e.FormatMessage("An IP", "&8IP unbanned")); break; case ModActionType.Rank: Bot.Say(e.FormatMessage(e.TargetName, GetRankAction(e))); break; } }