Added /broadcast and /bc

Admin chat color and prefix are now optional
This commit is contained in:
Lucas Nicodemus 2011-07-01 03:35:24 -06:00
parent d62068eacf
commit a66d016fcb
4 changed files with 21 additions and 1 deletions

View file

@ -146,6 +146,8 @@ namespace TShockAPI
ChatCommands.Add(new Command("displaylogs", "logs", Rules));
ChatCommands.Add(new Command("user", "manageusers", ManageUsers));
ChatCommands.Add(new Command("login", "", AttemptLogin));
ChatCommands.Add(new Command("broadcast", "cfg", Broadcast));
ChatCommands.Add(new Command("bc", "cfg", Broadcast));
if (ConfigurationManager.DistributationAgent != "terraria-online")
{
ChatCommands.Add(new Command("kill", "kill", Kill));
@ -516,6 +518,19 @@ namespace TShockAPI
#region Server Maintenence Commands
private static void Broadcast(CommandArgs args)
{
string message = "";
for (int i = 0; i < args.Parameters.Count; i++)
{
message += args.Parameters[i];
}
Tools.Broadcast("(Server Broadcast) " + message, Color.Red);
return;
}
private static void Off(CommandArgs args)
{
Tools.ForceKickAll("Server shutting down!");

View file

@ -61,5 +61,7 @@ namespace TShockAPI
public bool AutoSave = true;
public int MaximumLoginAttempts = 3;
public bool EnableOptionalAlwaysOnAdminChatColor = true;
}
}

View file

@ -58,6 +58,7 @@ namespace TShockAPI
public static bool RememberLeavePos = false;
public static int TileThreshold = 20;
public static int MaximumLoginAttempts = 3;
public static bool AdminChatOptional = true;
/// <summary>
/// Don't allow pvp changing for x seconds.
@ -122,6 +123,7 @@ namespace TShockAPI
BanOnHardcoreDeath = cfg.BanOnHardcoreOnlyDeath;
AutoSave = cfg.AutoSave;
MaximumLoginAttempts = cfg.MaximumLoginAttempts;
AdminChatOptional = cfg.EnableOptionalAlwaysOnAdminChatColor;
}
public static void WriteJsonConfiguration()
@ -161,6 +163,7 @@ namespace TShockAPI
cfg.KickOnHardcoreOnlyDeath = KickOnHardcoreDeath;
cfg.AutoSave = AutoSave;
cfg.MaximumLoginAttempts = MaximumLoginAttempts;
cfg.EnableOptionalAlwaysOnAdminChatColor = AdminChatOptional;
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
TextWriter tr = new StreamWriter(FileTools.ConfigPath);
tr.Write(json);

View file

@ -315,7 +315,7 @@ namespace TShockAPI
return;
}
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/"))
if (tsplr.Group.HasPermission("adminchat") && !text.StartsWith("/") && ConfigurationManager.AdminChatOptional)
{
Tools.Broadcast(ConfigurationManager.AdminChatPrefix + "<" + tsplr.Name + "> " + text,
(byte)ConfigurationManager.AdminChatRGB[0], (byte)ConfigurationManager.AdminChatRGB[1], (byte)ConfigurationManager.AdminChatRGB[2]);