static string ToIRCColors(string input) { input = Colors.Escape(input); input = LineWrapper.CleanupColors(input, true, false); StringBuilder sb = new StringBuilder(input); for (int i = 0; i < ircColors.Length; i++) { sb.Replace(ircReplacements[i], ircColors[i]); } return(sb.ToString()); }
public static string ConvertMCToIRC(string input) { if (input == null) { throw new ArgumentNullException("input"); } input = Escape(input); input = LineWrapper.CleanupColors(input, true, false); StringBuilder sb = new StringBuilder(input); for (int i = 0; i < ircColors.Length; i++) { sb.Replace(ircReplacements[i], ircColors[i]); } return(sb.ToString()); }
public void SendCpeMessage(CpeMessageType type, string message) { if (type != CpeMessageType.Normal && !Supports(CpeExt.MessageTypes)) { if (type == CpeMessageType.Announcement) { type = CpeMessageType.Normal; } else { return; } } message = Chat.Format(message, this); message = LineWrapper.CleanupColors(message, this); Send(Packet.Message(message, type, hasCP437)); }
public virtual void Message(byte type, string message) { // Message should start with server color if no initial color if (message.Length > 0 && !(message[0] == '&' || message[0] == '%')) { message = Server.Config.DefaultColor + message; } message = Chat.Format(message, this); OnMessageRecievedEvent.Call(this, message); if (cancelmessage) { cancelmessage = false; return; } try { message = LineWrapper.CleanupColors(message, this); SendLines(LineWrapper.Wordwrap(message, hasEmoteFix), type); } catch (Exception e) { Logger.LogError(e); } }
static void SpawnRaw(Player dst, byte id, Entity e, Position pos, Orientation rot, string skin, string name, string model) { // NOTE: Fix for standard clients if (id == Entities.SelfID) { pos.Y -= 22; } name = LineWrapper.CleanupColors(name, dst); if (dst.Supports(CpeExt.ExtPlayerList, 2)) { dst.Send(Packet.ExtAddEntity2(id, skin, name, pos, rot, dst.hasCP437, dst.hasExtPositions)); } else if (dst.hasExtList) { dst.Send(Packet.ExtAddEntity(id, skin, name, dst.hasCP437)); dst.Send(Packet.Teleport(id, pos, rot, dst.hasExtPositions)); } else { dst.Send(Packet.AddEntity(id, name, pos, rot, dst.hasCP437, dst.hasExtPositions)); } if (dst.hasChangeModel) { OnSendingModelEvent.Call(e, ref model, dst); if (!model.CaselessEq("humanoid")) { SendModel(dst, id, model); } } if (dst.Supports(CpeExt.EntityProperty)) { dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX))); dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ))); SendModelScales(dst, id, e); } }
/// <summary> Adds the given player to that player's tab list (if their client supports it). </summary> public static void Add(Player dst, Player p, byte id) { if (!dst.hasExtList) { return; } byte grpPerm = (byte)(offset - p.Rank); if (!Server.Config.TablistRankSorted) { grpPerm = 0; } string name, group; GetEntry(p, dst, out name, out group); name = Colors.Escape(name); // for nicks name = LineWrapper.CleanupColors(name, dst); group = LineWrapper.CleanupColors(group, dst); dst.Send(Packet.ExtAddPlayerName(id, p.truename, name, group, grpPerm, dst.hasCP437)); }
static void SpawnRaw(Player dst, byte id, Entity e, Position pos, Orientation rot, string skin, string name, string model) { name = LineWrapper.CleanupColors(name, dst); dst.Session.SendSpawnEntity(id, name, skin, pos, rot); if (dst.hasChangeModel) { OnSendingModelEvent.Call(e, ref model, dst); if (!model.CaselessEq("humanoid")) { dst.Session.SendChangeModel(id, model); } } if (dst.Supports(CpeExt.EntityProperty)) { dst.Send(Packet.EntityProperty(id, EntityProp.RotX, Orientation.PackedToDegrees(rot.RotX))); dst.Send(Packet.EntityProperty(id, EntityProp.RotZ, Orientation.PackedToDegrees(rot.RotZ))); SendModelScales(dst, id, e); } }
public virtual void Message(byte type, string message) { // Message should start with server color if no initial color if (message.Length > 0 && !(message[0] == '&' || message[0] == '%')) { message = "&S" + message; } message = Chat.Format(message, this); bool cancel = false; OnMessageRecievedEvent.Call(this, ref message, ref cancel); if (cancel) { return; } try { message = LineWrapper.CleanupColors(message, this); Session.SendChat(message); } catch (Exception e) { Logger.LogError(e); } }