Merge pull request #504 from CoderCow/patch-1
Some General Improvements
This commit is contained in:
commit
4e7b497ae4
7 changed files with 137 additions and 13 deletions
9
.editorconfig
Normal file
9
.editorconfig
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = crlf
|
||||
insert_final_newline = true
|
||||
|
||||
[*.cs]
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
|
|
@ -244,7 +244,8 @@ namespace TShockAPI
|
|||
add(Permissions.savessi, SaveSSI, "savessi");
|
||||
add(Permissions.savessi, OverrideSSI, "overridessi", "ossi");
|
||||
add(Permissions.xmas, ForceXmas, "forcexmas");
|
||||
add(Permissions.settempgroup, TempGroup, "tempgroup");
|
||||
add(Permissions.settempgroup, TempGroup, "tempgroup");
|
||||
add(null, Aliases, "aliases");
|
||||
//add(null, TestCallbackCommand, "test");
|
||||
|
||||
TShockCommands = new ReadOnlyCollection<Command>(tshockCommands);
|
||||
|
|
@ -282,7 +283,7 @@ namespace TShockAPI
|
|||
{
|
||||
if (!cmd.CanRun(player))
|
||||
{
|
||||
TShock.Utils.SendLogs(string.Format("{0} tried to execute /{1}.", player.Name, cmdText), Color.Red);
|
||||
TShock.Utils.SendLogs(string.Format("{0} tried to execute /{1}.", player.Name, cmdText), Color.PaleVioletRed, player);
|
||||
player.SendErrorMessage("You do not have access to that command.");
|
||||
}
|
||||
else if (!cmd.AllowServer && !player.RealPlayer)
|
||||
|
|
@ -292,7 +293,7 @@ namespace TShockAPI
|
|||
else
|
||||
{
|
||||
if (cmd.DoLog)
|
||||
TShock.Utils.SendLogs(string.Format("{0} executed: /{1}.", player.Name, cmdText), Color.Red);
|
||||
TShock.Utils.SendLogs(string.Format("{0} executed: /{1}.", player.Name, cmdText), Color.PaleVioletRed, player);
|
||||
cmd.Run(cmdText, player, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -1288,8 +1289,9 @@ namespace TShockAPI
|
|||
{
|
||||
message += " " + args.Parameters[i];
|
||||
}
|
||||
|
||||
TShock.Utils.Broadcast("(Server Broadcast)" + message, Color.Red);
|
||||
|
||||
Color color = new Color(TShock.Config.BroadcastRGB[0], TShock.Config.BroadcastRGB[1], TShock.Config.BroadcastRGB[2]);
|
||||
TShock.Utils.Broadcast("(Server Broadcast)" + message, color);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2879,7 +2881,7 @@ namespace TShockAPI
|
|||
args.Player, pageNumber, lines, new PaginationTools.Settings
|
||||
{
|
||||
HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name),
|
||||
FooterFormat = "Type /region info {0} for more information."
|
||||
FooterFormat = string.Format("Type /region info {0} {{0}} for more information.", regionName)
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -3372,6 +3374,41 @@ namespace TShockAPI
|
|||
args.Player.SendSuccessMessage("Annoying " + ply.Name + " for " + annoy + " seconds.");
|
||||
(new Thread(ply.Whoopie)).Start(annoy);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Aliases(CommandArgs args)
|
||||
{
|
||||
if (args.Parameters.Count < 1)
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /aliases <command or alias>");
|
||||
return;
|
||||
}
|
||||
|
||||
string givenCommandName = string.Join(" ", args.Parameters);
|
||||
if (string.IsNullOrWhiteSpace(givenCommandName)) {
|
||||
args.Player.SendErrorMessage("Please enter a proper command name or alias.");
|
||||
return;
|
||||
}
|
||||
|
||||
string commandName;
|
||||
if (givenCommandName[0] == '/')
|
||||
commandName = givenCommandName.Substring(1);
|
||||
else
|
||||
commandName = givenCommandName;
|
||||
|
||||
bool didMatch = false;
|
||||
foreach (Command matchingCommand in ChatCommands.Where(cmd => cmd.Names.IndexOf(commandName) != -1)) {
|
||||
if (matchingCommand.Names.Count > 1)
|
||||
args.Player.SendInfoMessage(
|
||||
"Aliases of /{0}: /{1}", matchingCommand.Name, string.Join(", /", matchingCommand.Names.Skip(1)));
|
||||
else
|
||||
args.Player.SendInfoMessage("/{0} defines no aliases.", matchingCommand.Name);
|
||||
|
||||
didMatch = true;
|
||||
}
|
||||
|
||||
if (!didMatch)
|
||||
args.Player.SendErrorMessage("No command or command alias matching \"{0}\" found.", givenCommandName);
|
||||
}
|
||||
|
||||
#endregion General Commands
|
||||
|
|
|
|||
|
|
@ -251,7 +251,10 @@ namespace TShockAPI
|
|||
|
||||
[Description("The path of the directory where logs should be written into.")] public string LogPath = "tshock";
|
||||
|
||||
[Description("Prevents players from placing tiles with an invalid style.")] public bool PreventInvalidPlaceStyle = true;
|
||||
[Description("Prevents players from placing tiles with an invalid style.")] public bool PreventInvalidPlaceStyle = true;
|
||||
|
||||
[Description("#.#.#. = Red/Blue/Green - RGB Colors for broadcasts. Max value: 255.")] public float[] BroadcastRGB =
|
||||
{127,255,212};
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuration file from a given path
|
||||
|
|
|
|||
|
|
@ -2922,7 +2922,7 @@ namespace TShockAPI
|
|||
break;
|
||||
}
|
||||
|
||||
TShock.Utils.SendLogs(string.Format("{0} summoned {1}", args.Player.Name, boss), Color.Red);
|
||||
TShock.Utils.SendLogs(string.Format("{0} summoned {1}", args.Player.Name, boss), Color.PaleVioletRed, args.Player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,16 @@ namespace TShockAPI
|
|||
public static void Data(String message)
|
||||
{
|
||||
Write(message, LogLevel.Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes data to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void Data(String format, params String[] args)
|
||||
{
|
||||
Data(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -79,6 +89,16 @@ namespace TShockAPI
|
|||
public static void Error(String message)
|
||||
{
|
||||
Write(message, LogLevel.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an error to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void Error(String format, params String[] args)
|
||||
{
|
||||
Error(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -91,6 +111,16 @@ namespace TShockAPI
|
|||
Console.WriteLine(message);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Write(message, LogLevel.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an error to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void ConsoleError(String format, params String[] args)
|
||||
{
|
||||
ConsoleError(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -100,6 +130,16 @@ namespace TShockAPI
|
|||
public static void Warn(String message)
|
||||
{
|
||||
Write(message, LogLevel.Warning);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a warning to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void Warn(String format, params String[] args)
|
||||
{
|
||||
Warn(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -109,6 +149,16 @@ namespace TShockAPI
|
|||
public static void Info(String message)
|
||||
{
|
||||
Write(message, LogLevel.Info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an informative string to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void Info(String format, params String[] args)
|
||||
{
|
||||
Info(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -121,6 +171,16 @@ namespace TShockAPI
|
|||
Console.WriteLine(message);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Write(message, LogLevel.Info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes an informative string to the log file. Also outputs to the console.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void ConsoleInfo(String format, params String[] args)
|
||||
{
|
||||
ConsoleInfo(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -130,6 +190,16 @@ namespace TShockAPI
|
|||
public static void Debug(String message)
|
||||
{
|
||||
Write(message, LogLevel.Debug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public static void Debug(String format, params String[] args)
|
||||
{
|
||||
Debug(String.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -899,6 +899,10 @@ namespace TShockAPI
|
|||
|
||||
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
|
||||
{
|
||||
// Main.rand is thread static.
|
||||
if (Main.rand == null)
|
||||
Main.rand = new Random();
|
||||
|
||||
Main.npc[npcid].StrikeNPC(damage, knockBack, hitDirection);
|
||||
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,18 +218,19 @@ namespace TShockAPI
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends message to all users with 'logs' permission.
|
||||
/// Sends message to all players with 'logs' permission.
|
||||
/// </summary>
|
||||
/// <param name="log">Message to send</param>
|
||||
/// <param name="color">Color of the message</param>
|
||||
public void SendLogs(string log, Color color)
|
||||
/// <param name="color">Color of the message</param>
|
||||
/// <param name="excludedPlayer">The player to not send the message to.</param>
|
||||
public void SendLogs(string log, Color color, TSPlayer excludedPlayer = null)
|
||||
{
|
||||
Log.Info(log);
|
||||
TSPlayer.Server.SendMessage(log, color);
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
{
|
||||
if (player != null && player.Active && player.Group.HasPermission(Permissions.logs) && player.DisplayLogs &&
|
||||
TShock.Config.DisableSpewLogs == false)
|
||||
if (player != null && player != excludedPlayer && player.Active && player.Group.HasPermission(Permissions.logs) &&
|
||||
player.DisplayLogs && TShock.Config.DisableSpewLogs == false)
|
||||
player.SendMessage(log, color);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue