Added AdminChatPrefix configuration option.

Added AdminChatRGB configuration option.
Tweaked how broadcast works, now clamps RGB values to prevent overflows.
Added a new permission, "adminchat," that defines who is affected by the AdminChatPrefix and the new AdminChatRGB (which is a rgb color spectrum for the chat color of admin's text).
Closes #72
This commit is contained in:
Shank 2011-06-14 02:56:04 -06:00
parent 49ca8fcd1a
commit 6411e71cee
4 changed files with 25 additions and 1 deletions

View file

@ -41,5 +41,7 @@ namespace TShockAPI
public bool RangeChecks = true;
public bool SpamChecks = false;
public bool DisableBuild = false;
public float[] AdminChatRGB = {255, 0, 0};
public string AdminChatPrefix = "(Admin) ";
}
}

View file

@ -52,6 +52,8 @@ namespace TShockAPI
public static int maxSlots = 8;
public static bool spamChecks = false;
public static bool disableBuild = false;
public static float[] adminChatRGB = {255, 0, 0};
public static string adminChatPrefix = "(Admin) ";
public enum NPCList
{
@ -90,6 +92,8 @@ namespace TShockAPI
disableBuild = cfg.DisableBuild;
NPC.maxSpawns = defaultMaxSpawns;
NPC.defaultSpawnRate = defaultSpawnRate;
adminChatRGB = cfg.AdminChatRGB;
adminChatPrefix = cfg.AdminChatPrefix;
}
public static void WriteJsonConfiguration()
@ -121,6 +125,8 @@ namespace TShockAPI
cfg.RangeChecks = rangeChecks;
cfg.SpamChecks = spamChecks;
cfg.DisableBuild = disableBuild;
cfg.AdminChatRGB = adminChatRGB;
cfg.AdminChatPrefix = adminChatPrefix;
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
tr.Write(json);

View file

@ -600,6 +600,13 @@ namespace TShockAPI
return;
}
if (players[ply].group.HasPermission("adminchat") && !text.StartsWith("/"))
{
Tools.Broadcast(ConfigurationManager.adminChatPrefix + "<" + Main.player[ply].name + "> " + text, ConfigurationManager.adminChatRGB);
e.Handled = true;
return;
}
int x = (int)Main.player[ply].position.X;
int y = (int)Main.player[ply].position.Y;

View file

@ -105,7 +105,16 @@ namespace TShockAPI
{
for (int i = 0; i < Main.player.Length; i++)
{
SendMessage(i, msg, red, green, blue);
SendMessage(i, msg, Tools.Clamp(red, 255, 0), Tools.Clamp(green, 255, 0), Tools.Clamp(blue, 255, 0));
}
Log.Info(string.Format("Broadcast: {0}", msg));
}
public static void Broadcast(string msg, float[] colors)
{
for (int i = 0; i < Main.player.Length; i++)
{
SendMessage(i, msg, Tools.Clamp(colors[0], 255, 0), Tools.Clamp(colors[1], 255, 0), Tools.Clamp(colors[2], 255, 0));
}
Log.Info(string.Format("Broadcast: {0}", msg));
}