diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index 8cf79f9b..d0c32fca 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -1027,5 +1027,30 @@ namespace TShockAPI return resp; } } + + /// + /// Colors the given text by correctly applying the color chat tag. + /// + /// The text to color. + /// The color to apply. + /// The , surrounded by the color tag with the appropriated hex code. + public string ColorTag(string text, Color color) + { + return String.Format("[c/{0}:{1}]", color.Hex3(), text); + } + + /// + /// Converts an item into its text representation using the item chat tag. + /// + /// The item to convert. + /// The NetID surrounded by the item tag with proper stack/prefix data. + public string ItemTag(Item item) + { + int netID = item.netID; + int stack = item.stack; + int prefix = item.prefix; + string options = stack > 1 ? "/s" + stack : prefix != 0 ? "/p" + prefix : ""; + return String.Format("[i{0}:{1}]", options, netID); + } } }