Added silent commands & other stuff (see below)
1. Removed old code. 2. Added silent command prefix & supporting code 3. Region ban & spawnmob support silence
This commit is contained in:
parent
7649718530
commit
f2b2da90d7
3 changed files with 70 additions and 18 deletions
|
|
@ -37,6 +37,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
public string Message { get; private set; }
|
public string Message { get; private set; }
|
||||||
public TSPlayer Player { get; private set; }
|
public TSPlayer Player { get; private set; }
|
||||||
|
public bool Silent { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parameters passed to the arguement. Does not include the command name.
|
/// Parameters passed to the arguement. Does not include the command name.
|
||||||
|
|
@ -54,6 +55,15 @@ namespace TShockAPI
|
||||||
Message = message;
|
Message = message;
|
||||||
Player = ply;
|
Player = ply;
|
||||||
Parameters = args;
|
Parameters = args;
|
||||||
|
Silent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandArgs(string message, bool silent, TSPlayer ply, List<string> args)
|
||||||
|
{
|
||||||
|
Message = message;
|
||||||
|
Player = ply;
|
||||||
|
Parameters = args;
|
||||||
|
Silent = silent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,14 +139,14 @@ namespace TShockAPI
|
||||||
Permissions = new List<string>();
|
Permissions = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Run(string msg, TSPlayer ply, List<string> parms)
|
public bool Run(string msg, bool silent, TSPlayer ply, List<string> parms)
|
||||||
{
|
{
|
||||||
if (!CanRun(ply))
|
if (!CanRun(ply))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommandDelegate(new CommandArgs(msg, ply, parms));
|
CommandDelegate(new CommandArgs(msg, silent, ply, parms));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -147,6 +157,11 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Run(string msg, TSPlayer ply, List<string> parms)
|
||||||
|
{
|
||||||
|
return Run(msg, false, ply, parms);
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasAlias(string name)
|
public bool HasAlias(string name)
|
||||||
{
|
{
|
||||||
return Names.Contains(name);
|
return Names.Contains(name);
|
||||||
|
|
@ -583,6 +598,11 @@ namespace TShockAPI
|
||||||
public static bool HandleCommand(TSPlayer player, string text)
|
public static bool HandleCommand(TSPlayer player, string text)
|
||||||
{
|
{
|
||||||
string cmdText = text.Remove(0, 1);
|
string cmdText = text.Remove(0, 1);
|
||||||
|
string cmdPrefix = text[0].ToString();
|
||||||
|
bool silent = false;
|
||||||
|
|
||||||
|
if (cmdPrefix == TShock.Config.CommandSilentSpecifier)
|
||||||
|
silent = true;
|
||||||
|
|
||||||
var args = ParseParameters(cmdText);
|
var args = ParseParameters(cmdText);
|
||||||
if (args.Count < 1)
|
if (args.Count < 1)
|
||||||
|
|
@ -622,8 +642,8 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cmd.DoLog)
|
if (cmd.DoLog)
|
||||||
TShock.Utils.SendLogs(string.Format("{0} executed: {1}{2}.", player.Name, TShock.Config.CommandSpecifier, cmdText), Color.PaleVioletRed, player);
|
TShock.Utils.SendLogs(string.Format("{0} executed: {1}{2}.", player.Name, silent ? TShock.Config.CommandSilentSpecifier : TShock.Config.CommandSpecifier, cmdText), Color.PaleVioletRed, player);
|
||||||
cmd.Run(cmdText, player, args);
|
cmd.Run(cmdText, silent, player, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1152,9 +1172,27 @@ namespace TShockAPI
|
||||||
var knownIps = JsonConvert.DeserializeObject<List<string>>(user.KnownIps);
|
var knownIps = JsonConvert.DeserializeObject<List<string>>(user.KnownIps);
|
||||||
TShock.Bans.AddBan(knownIps.Last(), user.Name, user.UUID, reason, false, args.Player.UserAccountName);
|
TShock.Bans.AddBan(knownIps.Last(), user.Name, user.UUID, reason, false, args.Player.UserAccountName);
|
||||||
if (String.IsNullOrWhiteSpace(args.Player.UserAccountName))
|
if (String.IsNullOrWhiteSpace(args.Player.UserAccountName))
|
||||||
TSPlayer.All.SendInfoMessage("{0} was {1}banned for '{2}'.", user.Name, force ? "force " : "", reason);
|
{
|
||||||
|
if (args.Silent)
|
||||||
|
{
|
||||||
|
args.Player.SendInfoMessage("{0} was {1}banned for '{2}'.", user.Name, force ? "Force " : "", reason);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
TSPlayer.All.SendInfoMessage("{0} {1}banned {2} for '{3}'.", args.Player.Name, force ? "force " : "", user.Name, reason);
|
{
|
||||||
|
TSPlayer.All.SendInfoMessage("{0} was {1}banned for '{2}'.", user.Name, force ? "Force " : "", reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.Silent)
|
||||||
|
{
|
||||||
|
args.Player.SendInfoMessage("{0}banned {1} for '{2}'.", force ? "Force " : "", user.Name, reason);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TSPlayer.All.SendInfoMessage("{0} {1}banned {2} for '{3}'.", args.Player.Name, force ? "Force " : "", user.Name, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -1229,8 +1267,10 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
args.Player.SendErrorMessage("Invalid player or account!");
|
args.Player.SendErrorMessage("Invalid player or account!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (players.Count > 1)
|
else if (players.Count > 1)
|
||||||
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
TShock.Utils.SendMultipleMatchError(args.Player, players.Select(p => p.Name));
|
||||||
else
|
else
|
||||||
|
|
@ -1575,12 +1615,6 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdatePlugins(CommandArgs args)
|
|
||||||
{
|
|
||||||
args.Player.SendInfoMessage("Starting plugin update process:");
|
|
||||||
args.Player.SendInfoMessage("This may take a while, do not turn off the server!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ManageRest(CommandArgs args)
|
private static void ManageRest(CommandArgs args)
|
||||||
{
|
{
|
||||||
string subCommand = "help";
|
string subCommand = "help";
|
||||||
|
|
@ -1947,8 +1981,15 @@ namespace TShockAPI
|
||||||
if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113)
|
if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113)
|
||||||
{
|
{
|
||||||
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY, 50, 20);
|
TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, args.Player.TileX, args.Player.TileY, 50, 20);
|
||||||
|
if (args.Silent)
|
||||||
|
{
|
||||||
|
args.Player.SendSuccessMessage("Spawned {0} {1} time(s).", npc.name, amount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
TSPlayer.All.SendSuccessMessage("{0} has spawned {1} {2} time(s).", args.Player.Name, npc.name, amount);
|
TSPlayer.All.SendSuccessMessage("{0} has spawned {1} {2} time(s).", args.Player.Name, npc.name, amount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (npc.type == 113)
|
else if (npc.type == 113)
|
||||||
{
|
{
|
||||||
if (Main.wof >= 0 || (args.Player.Y / 16f < (Main.maxTilesY - 205)))
|
if (Main.wof >= 0 || (args.Player.Y / 16f < (Main.maxTilesY - 205)))
|
||||||
|
|
@ -1957,7 +1998,14 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NPC.SpawnWOF(new Vector2(args.Player.X, args.Player.Y));
|
NPC.SpawnWOF(new Vector2(args.Player.X, args.Player.Y));
|
||||||
TSPlayer.All.SendSuccessMessage("{0} has spawned Wall of Flesh!", args.Player.Name);
|
if (args.Silent)
|
||||||
|
{
|
||||||
|
args.Player.SendSuccessMessage("Spawned Wall of Flesh!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TSPlayer.All.SendSuccessMessage("{0} has spawned a Wall of Flesh!", args.Player.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -367,9 +367,12 @@ namespace TShockAPI
|
||||||
[Description("Allows anyone to break grass, pots, etc.")]
|
[Description("Allows anyone to break grass, pots, etc.")]
|
||||||
public bool AllowCutTilesAndBreakables = false;
|
public bool AllowCutTilesAndBreakables = false;
|
||||||
|
|
||||||
[Description("Specifies which string starts a command")]
|
[Description("Specifies which string starts a command.")]
|
||||||
public string CommandSpecifier = "/";
|
public string CommandSpecifier = "/";
|
||||||
|
|
||||||
|
[Description("Specifies which string starts a command silently.")]
|
||||||
|
public string CommandSilentSpecifier = ".";
|
||||||
|
|
||||||
[Description("Kicks a hardcore player on death.")]
|
[Description("Kicks a hardcore player on death.")]
|
||||||
public bool KickOnHardcoreDeath;
|
public bool KickOnHardcoreDeath;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1049,7 +1049,8 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (args.Text.StartsWith(Config.CommandSpecifier) && !string.IsNullOrWhiteSpace(args.Text.Substring(1)))
|
if ((args.Text.StartsWith(Config.CommandSpecifier) || args.Text.StartsWith(Config.CommandSilentSpecifier))
|
||||||
|
&& !string.IsNullOrWhiteSpace(args.Text.Substring(1)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue