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
|
||||||
|
|
@ -245,6 +245,7 @@ namespace TShockAPI
|
||||||
add(Permissions.savessi, OverrideSSI, "overridessi", "ossi");
|
add(Permissions.savessi, OverrideSSI, "overridessi", "ossi");
|
||||||
add(Permissions.xmas, ForceXmas, "forcexmas");
|
add(Permissions.xmas, ForceXmas, "forcexmas");
|
||||||
add(Permissions.settempgroup, TempGroup, "tempgroup");
|
add(Permissions.settempgroup, TempGroup, "tempgroup");
|
||||||
|
add(null, Aliases, "aliases");
|
||||||
//add(null, TestCallbackCommand, "test");
|
//add(null, TestCallbackCommand, "test");
|
||||||
|
|
||||||
TShockCommands = new ReadOnlyCollection<Command>(tshockCommands);
|
TShockCommands = new ReadOnlyCollection<Command>(tshockCommands);
|
||||||
|
|
@ -282,7 +283,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (!cmd.CanRun(player))
|
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.");
|
player.SendErrorMessage("You do not have access to that command.");
|
||||||
}
|
}
|
||||||
else if (!cmd.AllowServer && !player.RealPlayer)
|
else if (!cmd.AllowServer && !player.RealPlayer)
|
||||||
|
|
@ -292,7 +293,7 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cmd.DoLog)
|
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);
|
cmd.Run(cmdText, player, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1289,7 +1290,8 @@ namespace TShockAPI
|
||||||
message += " " + args.Parameters[i];
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2879,7 +2881,7 @@ namespace TShockAPI
|
||||||
args.Player, pageNumber, lines, new PaginationTools.Settings
|
args.Player, pageNumber, lines, new PaginationTools.Settings
|
||||||
{
|
{
|
||||||
HeaderFormat = string.Format("Information About Region \"{0}\" ({{0}}/{{1}}):", region.Name),
|
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)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -3374,6 +3376,41 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
#endregion General Commands
|
||||||
|
|
||||||
#region Cheat Commands
|
#region Cheat Commands
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,9 @@ namespace TShockAPI
|
||||||
|
|
||||||
[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>
|
/// <summary>
|
||||||
/// Reads a configuration file from a given path
|
/// Reads a configuration file from a given path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -2922,7 +2922,7 @@ namespace TShockAPI
|
||||||
break;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Data);
|
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>
|
/// <summary>
|
||||||
/// Writes an error to the log file.
|
/// Writes an error to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -81,6 +91,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Error);
|
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>
|
/// <summary>
|
||||||
/// Writes an error to the log file.
|
/// Writes an error to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -93,6 +113,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Error);
|
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>
|
/// <summary>
|
||||||
/// Writes a warning to the log file.
|
/// Writes a warning to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -102,6 +132,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Warning);
|
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>
|
/// <summary>
|
||||||
/// Writes an informative string to the log file.
|
/// Writes an informative string to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -111,6 +151,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Info);
|
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>
|
/// <summary>
|
||||||
/// Writes an informative string to the log file. Also outputs to the console.
|
/// Writes an informative string to the log file. Also outputs to the console.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -123,6 +173,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Info);
|
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>
|
/// <summary>
|
||||||
/// Writes a debug string to the log file.
|
/// Writes a debug string to the log file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -132,6 +192,16 @@ namespace TShockAPI
|
||||||
Write(message, LogLevel.Debug);
|
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>
|
/// <summary>
|
||||||
/// Disposes objects that are being used.
|
/// Disposes objects that are being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -899,6 +899,10 @@ namespace TShockAPI
|
||||||
|
|
||||||
public void StrikeNPC(int npcid, int damage, float knockBack, int hitDirection)
|
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);
|
Main.npc[npcid].StrikeNPC(damage, knockBack, hitDirection);
|
||||||
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
NetMessage.SendData((int) PacketTypes.NpcStrike, -1, -1, "", npcid, damage, knockBack, hitDirection);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,18 +218,19 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends message to all users with 'logs' permission.
|
/// Sends message to all players with 'logs' permission.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="log">Message to send</param>
|
/// <param name="log">Message to send</param>
|
||||||
/// <param name="color">Color of the message</param>
|
/// <param name="color">Color of the message</param>
|
||||||
public void SendLogs(string log, Color color)
|
/// <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);
|
Log.Info(log);
|
||||||
TSPlayer.Server.SendMessage(log, color);
|
TSPlayer.Server.SendMessage(log, color);
|
||||||
foreach (TSPlayer player in TShock.Players)
|
foreach (TSPlayer player in TShock.Players)
|
||||||
{
|
{
|
||||||
if (player != null && player.Active && player.Group.HasPermission(Permissions.logs) && player.DisplayLogs &&
|
if (player != null && player != excludedPlayer && player.Active && player.Group.HasPermission(Permissions.logs) &&
|
||||||
TShock.Config.DisableSpewLogs == false)
|
player.DisplayLogs && TShock.Config.DisableSpewLogs == false)
|
||||||
player.SendMessage(log, color);
|
player.SendMessage(log, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue