Remove more obsolete code; fix tab/space screwup in TSPlayer

This commit is contained in:
Lucas Nicodemus 2015-02-28 19:37:06 -07:00
parent 78c6f4db84
commit cbce64f1eb
13 changed files with 329 additions and 340 deletions

View file

@ -72,7 +72,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return null; return null;
} }
@ -96,7 +96,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
} }
return null; return null;
@ -123,7 +123,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return null; return null;
} }
@ -145,7 +145,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return null; return null;
} }
@ -167,7 +167,7 @@ namespace TShockAPI.DB
{ {
if (exceptions) if (exceptions)
throw ex; throw ex;
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -193,7 +193,7 @@ namespace TShockAPI.DB
{ {
if (exceptions) if (exceptions)
throw ex; throw ex;
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -206,7 +206,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }

View file

@ -95,7 +95,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return playerData; return playerData;
@ -137,7 +137,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
@ -162,7 +162,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
else else
@ -176,7 +176,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
return false; return false;
@ -191,7 +191,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;

View file

@ -137,7 +137,7 @@ namespace TShockAPI.DB
var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name); var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name);
if (exceptions) if (exceptions)
throw new GroupManagerException(error); throw new GroupManagerException(error);
Log.ConsoleError(error); TShock.Log.ConsoleError(error);
return error; return error;
} }
group.Parent = parent; group.Parent = parent;
@ -298,7 +298,7 @@ namespace TShockAPI.DB
string groupName = reader.Get<string>("GroupName"); string groupName = reader.Get<string>("GroupName");
if (groupName == "superadmin") if (groupName == "superadmin")
{ {
Log.ConsoleInfo("WARNING: Group \"superadmin\" is defined in the database even though it's a reserved group name."); TShock.Log.ConsoleInfo("WARNING: Group \"superadmin\" is defined in the database even though it's a reserved group name.");
continue; continue;
} }
@ -314,7 +314,7 @@ namespace TShockAPI.DB
catch (ArgumentException) catch (ArgumentException)
{ {
// Just in case somebody messed with the unique primary key. // Just in case somebody messed with the unique primary key.
Log.ConsoleError("ERROR: Group name \"{0}\" occurs more than once. Keeping current group settings."); TShock.Log.ConsoleError("ERROR: Group name \"{0}\" occurs more than once. Keeping current group settings.");
return; return;
} }
} }
@ -349,14 +349,14 @@ namespace TShockAPI.DB
group.Parent = groups.FirstOrDefault(g => g.Name == parentGroupName); group.Parent = groups.FirstOrDefault(g => g.Name == parentGroupName);
if (group.Parent == null) if (group.Parent == null)
{ {
Log.ConsoleError( TShock.Log.ConsoleError(
"ERROR: Group \"{0}\" is referencing non existent parent group \"{1}\", parent reference was removed.", "ERROR: Group \"{0}\" is referencing non existent parent group \"{1}\", parent reference was removed.",
group.Name, parentGroupName); group.Name, parentGroupName);
} }
else else
{ {
if (group.Parent == group) if (group.Parent == group)
Log.ConsoleInfo( TShock.Log.ConsoleInfo(
"WARNING: Group \"{0}\" is referencing itself as parent group, parent reference was removed.", group.Name); "WARNING: Group \"{0}\" is referencing itself as parent group, parent reference was removed.", group.Name);
List<Group> groupChain = new List<Group> { group }; List<Group> groupChain = new List<Group> { group };
@ -365,7 +365,7 @@ namespace TShockAPI.DB
{ {
if (groupChain.Contains(checkingGroup.Parent)) if (groupChain.Contains(checkingGroup.Parent))
{ {
Log.ConsoleError( TShock.Log.ConsoleError(
"ERROR: Group \"{0}\" is referencing parent group \"{1}\" which is already part of the parent chain. Parent reference removed.", "ERROR: Group \"{0}\" is referencing parent group \"{1}\" which is already part of the parent chain. Parent reference removed.",
checkingGroup.Name, checkingGroup.Parent.Name); checkingGroup.Name, checkingGroup.Parent.Name);
@ -386,7 +386,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.ConsoleError("Error on reloading groups: " + ex); TShock.Log.ConsoleError("Error on reloading groups: " + ex);
} }
} }
} }

View file

@ -72,7 +72,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -87,7 +87,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -131,7 +131,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -155,7 +155,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
return false; return false;

View file

@ -94,15 +94,15 @@ namespace TShockAPI.DB
if (Int32.TryParse(splitids[i], out id)) // if unparsable, it's not an int, so silently skip if (Int32.TryParse(splitids[i], out id)) // if unparsable, it's not an int, so silently skip
r.AllowedIDs.Add(id); r.AllowedIDs.Add(id);
else else
Log.Warn("One of your UserIDs is not a usable integer: " + splitids[i]); TShock.Log.Warn("One of your UserIDs is not a usable integer: " + splitids[i]);
} }
} }
catch (Exception e) catch (Exception e)
{ {
Log.Error("Your database contains invalid UserIDs (they should be ints)."); TShock.Log.Error("Your database contains invalid UserIDs (they should be ints).");
Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field."); TShock.Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
Log.Error(e.ToString()); TShock.Log.Error(e.ToString());
Log.Error(e.StackTrace); TShock.Log.Error(e.StackTrace);
} }
Regions.Add(r); Regions.Add(r);
@ -111,7 +111,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -131,7 +131,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -147,7 +147,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -165,7 +165,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
return false; return false;
} }
} }
@ -182,7 +182,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
return false; return false;
} }
} }
@ -308,7 +308,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -363,7 +363,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -390,7 +390,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -413,7 +413,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return regions; return regions;
} }
@ -518,7 +518,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
return false; return false;
} }
} }
@ -584,7 +584,7 @@ namespace TShockAPI.DB
{ {
if (!ply.HasBeenNaggedAboutLoggingIn) if (!ply.HasBeenNaggedAboutLoggingIn)
{ {
ply.SendMessage("You must be logged in to take advantage of protected regions.", Color.Red); ply.SendMessage("You must be TShock.Logged in to take advantage of protected regions.", Color.Red);
ply.HasBeenNaggedAboutLoggingIn = true; ply.HasBeenNaggedAboutLoggingIn = true;
} }
return false; return false;

View file

@ -72,7 +72,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -87,7 +87,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -131,7 +131,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
@ -155,7 +155,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
} }
return false; return false;

View file

@ -74,7 +74,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -117,7 +117,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -162,7 +162,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }
@ -186,7 +186,7 @@ namespace TShockAPI.DB
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error(ex.ToString()); TShock.Log.Error(ex.ToString());
} }
return false; return false;
} }

View file

@ -213,7 +213,7 @@ namespace Rests
object result = cmd.Execute(verbs, parms, request); object result = cmd.Execute(verbs, parms, request);
if (cmd.DoLog && TShock.Config.LogRest) if (cmd.DoLog && TShock.Config.LogRest)
{ {
Log.ConsoleInfo("Anonymous requested REST endpoint: " + BuildRequestUri(cmd, verbs, parms, false)); TShock.Log.ConsoleInfo("Anonymous requested REST endpoint: " + BuildRequestUri(cmd, verbs, parms, false));
} }
return result; return result;

View file

@ -179,7 +179,7 @@ namespace TShockAPI
var msg = args.Parameters["msg"]; var msg = args.Parameters["msg"];
if (string.IsNullOrWhiteSpace(msg)) if (string.IsNullOrWhiteSpace(msg))
return RestMissingParam("msg"); return RestMissingParam("msg");
TShock.Utils.Broadcast(msg); TSPlayer.All.SendInfoMessage(msg);
return RestResponse("The message was broadcasted successfully"); return RestResponse("The message was broadcasted successfully");
} }
@ -660,7 +660,7 @@ namespace TShockAPI
TSPlayer player = (TSPlayer)ret; TSPlayer player = (TSPlayer)ret;
player.DamagePlayer(999999); player.DamagePlayer(999999);
var from = string.IsNullOrWhiteSpace(args.Parameters["from"]) ? "Server Admin" : args.Parameters["from"]; var from = string.IsNullOrWhiteSpace(args.Parameters["from"]) ? "Server Admin" : args.Parameters["from"];
player.SendMessage(string.Format("{0} just killed you!", from)); player.SendInfoMessage(string.Format("{0} just killed you!", from));
return RestResponse("Player " + player.Name + " was killed"); return RestResponse("Player " + player.Name + " was killed");
} }
@ -916,7 +916,7 @@ namespace TShockAPI
TSPlayer player = (TSPlayer)ret; TSPlayer player = (TSPlayer)ret;
player.mute = mute; player.mute = mute;
var verb = mute ? "muted" : "unmuted"; var verb = mute ? "muted" : "unmuted";
player.SendMessage("You have been remotely " + verb); player.SendInfoMessage("You have been remotely " + verb);
return RestResponse("Player " + player.Name + " was " + verb); return RestResponse("Player " + player.Name + " was " + verb);
} }

View file

@ -68,7 +68,7 @@ namespace Rests
"The old model will be removed with the next maintenance release of TShock. In order to switch to the new model, ", "The old model will be removed with the next maintenance release of TShock. In order to switch to the new model, ",
"change the config setting \"RestUseNewPermissionModel\" to true." "change the config setting \"RestUseNewPermissionModel\" to true."
); );
Log.Warn(warningMessage); TShock.Log.Warn(warningMessage);
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(warningMessage); Console.WriteLine(warningMessage);
Console.ForegroundColor = ConsoleColor.Gray; Console.ForegroundColor = ConsoleColor.Gray;
@ -80,7 +80,7 @@ namespace Rests
"with existing REST services. If compatibility problems occur, you can switch back to the unsecure permission ", "with existing REST services. If compatibility problems occur, you can switch back to the unsecure permission ",
"model by changing the config setting \"RestUseNewPermissionModel\" to false, which is not recommended." "model by changing the config setting \"RestUseNewPermissionModel\" to false, which is not recommended."
); );
Log.ConsoleInfo(warningMessage); TShock.Log.ConsoleInfo(warningMessage);
} }
} }

View file

@ -130,7 +130,7 @@ namespace TShockAPI
else else
WorldFile.saveWorld(task.resetTime); WorldFile.saveWorld(task.resetTime);
TShock.Utils.Broadcast("World saved.", Color.Yellow); TShock.Utils.Broadcast("World saved.", Color.Yellow);
Log.Info(string.Format("World saved at ({0})", Main.worldPathName)); TShock.Log.Info(string.Format("World saved at ({0})", Main.worldPathName));
} }
catch (Exception e) catch (Exception e)
{ {

View file

@ -622,7 +622,6 @@ namespace TShockAPI
public void Spawn() public void Spawn()
{ {
// TPlayer.FindSpawn();
if (this.sX > 0 && this.sY > 0) if (this.sX > 0 && this.sY > 0)
{ {
Spawn(this.sX, this.sY); Spawn(this.sX, this.sY);
@ -849,7 +848,7 @@ namespace TShockAPI
StackFrame frame = null; StackFrame frame = null;
frame = trace.GetFrame(1); frame = trace.GetFrame(1);
if (frame != null && frame.GetMethod().DeclaringType != null) if (frame != null && frame.GetMethod().DeclaringType != null)
Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable()."); TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable().");
} }
public virtual void Whoopie(object time) public virtual void Whoopie(object time)
@ -924,14 +923,9 @@ namespace TShockAPI
AwaitingResponse = new Dictionary<string, Action<object>>(); AwaitingResponse = new Dictionary<string, Action<object>>();
} }
public override void SendMessage(string msg)
{
SendMessage(msg, 0, 255, 0);
}
public override void SendMessage(string msg, Color color) public override void SendMessage(string msg, Color color)
{ {
SendMessage(msg, color.R, color.G, color.B); SendInfoMessage(msg, color.R, color.G, color.B);
} }
public override void SendMessage(string msg, byte red, byte green, byte blue) public override void SendMessage(string msg, byte red, byte green, byte blue)
@ -1003,11 +997,6 @@ namespace TShockAPI
Console.ResetColor(); Console.ResetColor();
} }
public override void SendMessage(string msg)
{
SendMessage(msg, 0, 255, 0);
}
public override void SendMessage(string msg, Color color) public override void SendMessage(string msg, Color color)
{ {
SendMessage(msg, color.R, color.G, color.B); SendMessage(msg, color.R, color.G, color.B);
@ -1016,7 +1005,6 @@ namespace TShockAPI
public override void SendMessage(string msg, byte red, byte green, byte blue) public override void SendMessage(string msg, byte red, byte green, byte blue)
{ {
Console.WriteLine(msg); Console.WriteLine(msg);
//RconHandler.Response += msg + "\n";
} }
public void SetFullMoon() public void SetFullMoon()
@ -1428,6 +1416,7 @@ namespace TShockAPI
{ {
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].inventory[k].name, player.Index, (float)k, (float)Main.player[player.Index].inventory[k].prefix, 0f, 0); NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].inventory[k].name, player.Index, (float)k, (float)Main.player[player.Index].inventory[k].prefix, 0f, 0);
} }
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[0].name, player.Index, 59f, (float)Main.player[player.Index].armor[0].prefix, 0f, 0); NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[0].name, player.Index, 59f, (float)Main.player[player.Index].armor[0].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[1].name, player.Index, 60f, (float)Main.player[player.Index].armor[1].prefix, 0f, 0); NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[1].name, player.Index, 60f, (float)Main.player[player.Index].armor[1].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[2].name, player.Index, 61f, (float)Main.player[player.Index].armor[2].prefix, 0f, 0); NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[2].name, player.Index, 61f, (float)Main.player[player.Index].armor[2].prefix, 0f, 0);

View file

@ -94,7 +94,7 @@ namespace TShockAPI
} }
catch (Exception e) catch (Exception e)
{ {
Log.ConsoleError("UpdateManager Exception: {0}", e); TShock.Log.ConsoleError("UpdateManager Exception: {0}", e);
throw e; throw e;
} }