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

View file

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

View file

@ -137,7 +137,7 @@ namespace TShockAPI.DB
var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name);
if (exceptions)
throw new GroupManagerException(error);
Log.ConsoleError(error);
TShock.Log.ConsoleError(error);
return error;
}
group.Parent = parent;
@ -298,7 +298,7 @@ namespace TShockAPI.DB
string groupName = reader.Get<string>("GroupName");
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;
}
@ -314,7 +314,7 @@ namespace TShockAPI.DB
catch (ArgumentException)
{
// 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;
}
}
@ -349,14 +349,14 @@ namespace TShockAPI.DB
group.Parent = groups.FirstOrDefault(g => g.Name == parentGroupName);
if (group.Parent == null)
{
Log.ConsoleError(
TShock.Log.ConsoleError(
"ERROR: Group \"{0}\" is referencing non existent parent group \"{1}\", parent reference was removed.",
group.Name, parentGroupName);
}
else
{
if (group.Parent == group)
Log.ConsoleInfo(
TShock.Log.ConsoleInfo(
"WARNING: Group \"{0}\" is referencing itself as parent group, parent reference was removed.", group.Name);
List<Group> groupChain = new List<Group> { group };
@ -365,7 +365,7 @@ namespace TShockAPI.DB
{
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.",
checkingGroup.Name, checkingGroup.Parent.Name);
@ -386,7 +386,7 @@ namespace TShockAPI.DB
}
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)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
}
@ -87,7 +87,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
}
@ -131,7 +131,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
}
@ -155,7 +155,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
}
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
r.AllowedIDs.Add(id);
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)
{
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.");
Log.Error(e.ToString());
Log.Error(e.StackTrace);
TShock.Log.Error("Your database contains invalid UserIDs (they should be ints).");
TShock.Log.Error("A lot of things will fail because of this. You must manually delete and re-create the allowed field.");
TShock.Log.Error(e.ToString());
TShock.Log.Error(e.StackTrace);
}
Regions.Add(r);
@ -111,7 +111,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
}
@ -131,7 +131,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return false;
}
@ -147,7 +147,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return false;
}
@ -165,7 +165,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
return false;
}
}
@ -182,7 +182,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
return false;
}
}
@ -308,7 +308,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return false;
}
@ -363,7 +363,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return false;
}
@ -390,7 +390,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return false;
}
@ -413,7 +413,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
}
return regions;
}
@ -518,7 +518,7 @@ namespace TShockAPI.DB
}
catch (Exception ex)
{
Log.Error(ex.ToString());
TShock.Log.Error(ex.ToString());
return false;
}
}
@ -584,7 +584,7 @@ namespace TShockAPI.DB
{
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;
}
return false;

View file

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

View file

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

View file

@ -213,7 +213,7 @@ namespace Rests
object result = cmd.Execute(verbs, parms, request);
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;

View file

@ -179,7 +179,7 @@ namespace TShockAPI
var msg = args.Parameters["msg"];
if (string.IsNullOrWhiteSpace(msg))
return RestMissingParam("msg");
TShock.Utils.Broadcast(msg);
TSPlayer.All.SendInfoMessage(msg);
return RestResponse("The message was broadcasted successfully");
}
@ -660,7 +660,7 @@ namespace TShockAPI
TSPlayer player = (TSPlayer)ret;
player.DamagePlayer(999999);
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");
}
@ -916,7 +916,7 @@ namespace TShockAPI
TSPlayer player = (TSPlayer)ret;
player.mute = mute;
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);
}

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, ",
"change the config setting \"RestUseNewPermissionModel\" to true."
);
Log.Warn(warningMessage);
TShock.Log.Warn(warningMessage);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(warningMessage);
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 ",
"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
WorldFile.saveWorld(task.resetTime);
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)
{

View file

@ -30,29 +30,29 @@ namespace TShockAPI
{
public class TSPlayer
{
/// <summary>
/// This represents the server as a player.
/// </summary>
/// <summary>
/// This represents the server as a player.
/// </summary>
public static readonly TSServerPlayer Server = new TSServerPlayer();
/// <summary>
/// This player represents all the players.
/// </summary>
/// <summary>
/// This player represents all the players.
/// </summary>
public static readonly TSPlayer All = new TSPlayer("All");
/// <summary>
/// The amount of tiles that the player has killed in the last second.
/// </summary>
/// <summary>
/// The amount of tiles that the player has killed in the last second.
/// </summary>
public int TileKillThreshold { get; set; }
/// <summary>
/// The amount of tiles the player has placed in the last second.
/// </summary>
public int TilePlaceThreshold { get; set; }
/// <summary>
/// The amount of tiles the player has placed in the last second.
/// </summary>
public int TilePlaceThreshold { get; set; }
/// <summary>
/// The amount of liquid (in tiles) that the player has placed in the last second.
/// </summary>
/// <summary>
/// The amount of liquid (in tiles) that the player has placed in the last second.
/// </summary>
public int TileLiquidThreshold { get; set; }
/// <summary>
@ -60,9 +60,9 @@ namespace TShockAPI
/// </summary>
public int PaintThreshold { get; set; }
/// <summary>
/// The number of projectiles created by the player in the last second.
/// </summary>
/// <summary>
/// The number of projectiles created by the player in the last second.
/// </summary>
public int ProjectileThreshold { get; set; }
/// <summary>
@ -83,130 +83,130 @@ namespace TShockAPI
public int sX = -1;
public int sY = -1;
/// <summary>
/// A queue of tiles destroyed by the player for reverting.
/// </summary>
/// <summary>
/// A queue of tiles destroyed by the player for reverting.
/// </summary>
public Dictionary<Vector2, Tile> TilesDestroyed { get; protected set; }
/// <summary>
/// A queue of tiles placed by the player for reverting.
/// </summary>
/// <summary>
/// A queue of tiles placed by the player for reverting.
/// </summary>
public Dictionary<Vector2, Tile> TilesCreated { get; protected set; }
/// <summary>
/// The player's group.
/// </summary>
public Group Group
{
get
{
if (tempGroup != null)
return tempGroup;
return group;
}
set { group = value; }
}
/// <summary>
/// The player's group.
/// </summary>
public Group Group
{
get
{
if (tempGroup != null)
return tempGroup;
return group;
}
set { group = value; }
}
/// <summary>
/// The player's temporary group. This overrides the user's actual group.
/// </summary>
public Group tempGroup = null;
/// <summary>
/// The player's temporary group. This overrides the user's actual group.
/// </summary>
public Group tempGroup = null;
private Group group = null;
private Group group = null;
public bool ReceivedInfo { get; set; }
/// <summary>
/// The players index in the player array( Main.players[] ).
/// </summary>
/// <summary>
/// The players index in the player array( Main.players[] ).
/// </summary>
public int Index { get; protected set; }
/// <summary>
/// The last time the player changed their team or pvp status.
/// </summary>
/// <summary>
/// The last time the player changed their team or pvp status.
/// </summary>
public DateTime LastPvPTeamChange;
/// <summary>
/// Temp points for use in regions and other plugins.
/// </summary>
/// <summary>
/// Temp points for use in regions and other plugins.
/// </summary>
public Point[] TempPoints = new Point[2];
/// <summary>
/// Whether the player is waiting to place/break a tile to set as a temp point.
/// </summary>
/// <summary>
/// Whether the player is waiting to place/break a tile to set as a temp point.
/// </summary>
public int AwaitingTempPoint { get; set; }
/// <summary>
/// A list of command callbacks indexed by the command they need to do.
/// </summary>
public Dictionary<string, Action<object>> AwaitingResponse;
/// <summary>
/// A list of command callbacks indexed by the command they need to do.
/// </summary>
public Dictionary<string, Action<object>> AwaitingResponse;
public bool AwaitingName { get; set; }
public string[] AwaitingNameParameters { get; set; }
/// <summary>
/// The last time a player broke a grief check.
/// </summary>
/// <summary>
/// The last time a player broke a grief check.
/// </summary>
public DateTime LastThreat { get; set; }
public bool InitSpawn;
/// <summary>
/// Whether the player should see logs.
/// </summary>
/// <summary>
/// Whether the player should see logs.
/// </summary>
public bool DisplayLogs = true;
/// <summary>
/// The last player that the player whispered with (to or from).
/// </summary>
/// <summary>
/// The last player that the player whispered with (to or from).
/// </summary>
public TSPlayer LastWhisper;
/// <summary>
/// The number of unsuccessful login attempts.
/// </summary>
/// <summary>
/// The number of unsuccessful login attempts.
/// </summary>
public int LoginAttempts { get; set; }
public Vector2 TeleportCoords = new Vector2(-1, -1);
public Vector2 LastNetPosition = Vector2.Zero;
/// <summary>
/// The player's login name.
/// </summary>
/// <summary>
/// The player's login name.
/// </summary>
public string UserAccountName { get; set; }
/// <summary>
/// Whether the player performed a valid login attempt (i.e. entered valid user name and password) but is still blocked
/// from logging in because of SSI.
/// </summary>
/// <summary>
/// Whether the player performed a valid login attempt (i.e. entered valid user name and password) but is still blocked
/// from logging in because of SSI.
/// </summary>
public bool LoginFailsBySsi { get; set; }
/// <summary>
/// Whether the player is logged in or not.
/// </summary>
/// <summary>
/// Whether the player is logged in or not.
/// </summary>
public bool IsLoggedIn;
/// <summary>
/// Whether the player has sent their whole inventory to the server while connecting.
/// </summary>
/// <summary>
/// Whether the player has sent their whole inventory to the server while connecting.
/// </summary>
public bool HasSentInventory { get; set; }
/// <summary>
/// The player's user id( from the db ).
/// </summary>
/// <summary>
/// The player's user id( from the db ).
/// </summary>
public int UserID = -1;
/// <summary>
/// Whether the player has been nagged about logging in.
/// </summary>
/// <summary>
/// Whether the player has been nagged about logging in.
/// </summary>
public bool HasBeenNaggedAboutLoggingIn;
public bool TPAllow = true;
public bool TPAllow = true;
/// <summary>
/// Whether the player is muted or not.
/// </summary>
/// <summary>
/// Whether the player is muted or not.
/// </summary>
public bool mute;
private Player FakePlayer;
@ -218,16 +218,16 @@ namespace TShockAPI
/// </summary>
public int RespawnTimer;
/// <summary>
/// Whether the player is dead or not.
/// </summary>
/// <summary>
/// Whether the player is dead or not.
/// </summary>
public bool Dead;
public string Country = "??";
/// <summary>
/// The players difficulty( normal[softcore], mediumcore, hardcore ).
/// </summary>
/// <summary>
/// The players difficulty( normal[softcore], mediumcore, hardcore ).
/// </summary>
public int Difficulty;
private string CacheIP;
@ -240,53 +240,53 @@ namespace TShockAPI
public bool IgnoreActionsForClearingTrashCan;
/// <summary>
/// The player's server side inventory data.
/// </summary>
/// <summary>
/// The player's server side inventory data.
/// </summary>
public PlayerData PlayerData;
/// <summary>
/// Whether the player needs to specify a password upon connection( either server or user account ).
/// </summary>
/// <summary>
/// Whether the player needs to specify a password upon connection( either server or user account ).
/// </summary>
public bool RequiresPassword;
public bool SilentKickInProgress;
public bool SilentJoinInProgress;
/// <summary>
/// A list of points where ice tiles have been placed.
/// </summary>
/// <summary>
/// A list of points where ice tiles have been placed.
/// </summary>
public List<Point> IceTiles;
/// <summary>
/// Unused, can be removed.
/// </summary>
public long RPm = 1;
/// <summary>
/// Unused, can be removed.
/// </summary>
public long RPm = 1;
/// <summary>
/// World protection message cool down.
/// </summary>
public long WPm = 1;
/// <summary>
/// World protection message cool down.
/// </summary>
public long WPm = 1;
/// <summary>
/// Spawn protection message cool down.
/// </summary>
public long SPm = 1;
/// <summary>
/// Permission to build message cool down.
/// </summary>
public long BPm = 1;
/// <summary>
/// Spawn protection message cool down.
/// </summary>
public long SPm = 1;
/// <summary>
/// Permission to build message cool down.
/// </summary>
public long BPm = 1;
/// <summary>
/// The time in ms when the player has logged in.
/// </summary>
/// <summary>
/// The time in ms when the player has logged in.
/// </summary>
public long LoginMS;
/// <summary>
/// Whether the player has been harrassed about logging in due to server side inventory or forced login.
/// </summary>
/// <summary>
/// Whether the player has been harrassed about logging in due to server side inventory or forced login.
/// </summary>
public bool LoginHarassed = false;
/// <summary>
@ -304,9 +304,9 @@ namespace TShockAPI
/// </summary>
public int LastKilledProjectile = 0;
/// <summary>
/// Whether the player is a real, human, player on the server.
/// </summary>
/// <summary>
/// Whether the player is a real, human, player on the server.
/// </summary>
public bool RealPlayer
{
get { return Index >= 0 && Index < Main.maxNetPlayers && Main.player[Index] != null; }
@ -317,7 +317,7 @@ namespace TShockAPI
get
{
return RealPlayer &&
(Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill);
(Netplay.serverSock[Index] != null && Netplay.serverSock[Index].active && !Netplay.serverSock[Index].kill);
}
}
@ -488,9 +488,9 @@ namespace TShockAPI
TilesDestroyed = new Dictionary<Vector2, Tile>();
TilesCreated = new Dictionary<Vector2, Tile>();
Index = index;
Group = Group.DefaultGroup;
Group = Group.DefaultGroup;
IceTiles = new List<Point>();
AwaitingResponse = new Dictionary<string, Action<object>>();
AwaitingResponse = new Dictionary<string, Action<object>>();
}
protected TSPlayer(String playerName)
@ -499,8 +499,8 @@ namespace TShockAPI
TilesCreated = new Dictionary<Vector2, Tile>();
Index = -1;
FakePlayer = new Player {name = playerName, whoAmi = -1};
Group = Group.DefaultGroup;
AwaitingResponse = new Dictionary<string, Action<object>>();
Group = Group.DefaultGroup;
AwaitingResponse = new Dictionary<string, Action<object>>();
}
public virtual void Disconnect(string reason)
@ -622,7 +622,6 @@ namespace TShockAPI
public void Spawn()
{
// TPlayer.FindSpawn();
if (this.sX > 0 && this.sY > 0)
{
Spawn(this.sX, this.sY);
@ -662,8 +661,8 @@ namespace TShockAPI
}
}
public virtual bool SendTileSquare(int x, int y, int size = 10)
{
public virtual bool SendTileSquare(int x, int y, int size = 10)
{
try
{
int num = (size - 1)/2;
@ -710,19 +709,19 @@ namespace TShockAPI
TShock.Log.Error(ex.ToString());
}
return false;
}
}
public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0)
{
if ((TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) &&
(TShock.Itembans.ItemIsBanned(name, this) || !TShock.Config.AllowAllowedGroupsToSpawnBannedItems))
return false;
public bool GiveItemCheck(int type, string name, int width, int height, int stack, int prefix = 0)
{
if ((TShock.Itembans.ItemIsBanned(name) && TShock.Config.PreventBannedItemSpawn) &&
(TShock.Itembans.ItemIsBanned(name, this) || !TShock.Config.AllowAllowedGroupsToSpawnBannedItems))
return false;
GiveItem(type,name,width,height,stack,prefix);
return true;
}
GiveItem(type,name,width,height,stack,prefix);
return true;
}
public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0)
public virtual void GiveItem(int type, string name, int width, int height, int stack, int prefix = 0)
{
int itemid = Item.NewItem((int) X, (int) Y, width, height, type, stack, true, prefix, true);
@ -730,7 +729,7 @@ namespace TShockAPI
Main.item[itemid].SetDefaults(name);
// The set default overrides the wet and stack set by NewItem
Main.item[itemid].wet = Collision.WetCollision(Main.item[itemid].position, Main.item[itemid].width,
Main.item[itemid].height);
Main.item[itemid].height);
Main.item[itemid].stack = stack;
Main.item[itemid].owner = Index;
Main.item[itemid].prefix = (byte) prefix;
@ -740,47 +739,47 @@ namespace TShockAPI
NetMessage.SendData((int)PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
}
public virtual void SendInfoMessage(string msg)
{
SendMessage(msg, Color.Yellow);
}
public virtual void SendInfoMessage(string msg)
{
SendMessage(msg, Color.Yellow);
}
public void SendInfoMessage(string format, params object[] args)
{
SendInfoMessage(string.Format(format, args));
}
public void SendInfoMessage(string format, params object[] args)
{
SendInfoMessage(string.Format(format, args));
}
public virtual void SendSuccessMessage(string msg)
{
SendMessage(msg, Color.Green);
}
public virtual void SendSuccessMessage(string msg)
{
SendMessage(msg, Color.Green);
}
public void SendSuccessMessage(string format, params object[] args)
{
SendSuccessMessage(string.Format(format, args));
}
public void SendSuccessMessage(string format, params object[] args)
{
SendSuccessMessage(string.Format(format, args));
}
public virtual void SendWarningMessage(string msg)
{
SendMessage(msg, Color.OrangeRed);
}
public virtual void SendWarningMessage(string msg)
{
SendMessage(msg, Color.OrangeRed);
}
public void SendWarningMessage(string format, params object[] args)
{
SendWarningMessage(string.Format(format, args));
}
public void SendWarningMessage(string format, params object[] args)
{
SendWarningMessage(string.Format(format, args));
}
public virtual void SendErrorMessage(string msg)
{
SendMessage(msg, Color.Red);
}
public virtual void SendErrorMessage(string msg)
{
SendMessage(msg, Color.Red);
}
public void SendErrorMessage(string format, params object[] args)
{
SendErrorMessage(string.Format(format, args));
}
public void SendErrorMessage(string format, params object[] args)
{
SendErrorMessage(string.Format(format, args));
}
[Obsolete("Use SendErrorMessage, SendInfoMessage, or SendWarningMessage, or a custom color instead.")]
[Obsolete("Use SendErrorMessage, SendInfoMessage, or SendWarningMessage, or a custom color instead.")]
public virtual void SendMessage(string msg)
{
SendMessage(msg, 0, 255, 0);
@ -796,10 +795,10 @@ namespace TShockAPI
SendData(PacketTypes.ChatText, msg, 255, red, green, blue);
}
public virtual void SendMessageFromPlayer(string msg, byte red, byte green, byte blue, int ply)
{
SendDataFromPlayer(PacketTypes.ChatText, ply, msg, red, green, blue, 0);
}
public virtual void SendMessageFromPlayer(string msg, byte red, byte green, byte blue, int ply)
{
SendDataFromPlayer(PacketTypes.ChatText, ply, msg, red, green, blue, 0);
}
public virtual void DamagePlayer(int damage)
{
@ -849,7 +848,7 @@ namespace TShockAPI
StackFrame frame = null;
frame = trace.GetFrame(1);
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)
@ -883,13 +882,13 @@ namespace TShockAPI
NetMessage.SendData((int) msgType, Index, -1, text, number, number2, number3, number4, number5);
}
public virtual void SendDataFromPlayer(PacketTypes msgType, int ply, string text = "", float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
{
if (RealPlayer && !ConnectionAlive)
return;
public virtual void SendDataFromPlayer(PacketTypes msgType, int ply, string text = "", float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
{
if (RealPlayer && !ConnectionAlive)
return;
NetMessage.SendData((int) msgType, Index, -1, text, ply, number2, number3, number4, number5);
}
NetMessage.SendData((int) msgType, Index, -1, text, ply, number2, number3, number4, number5);
}
public virtual void SendRawData(byte[] data)
{
@ -898,20 +897,20 @@ namespace TShockAPI
NetMessage.SendBytes(Netplay.serverSock[Index], data, 0, data.Length, Netplay.serverSock[Index].ServerWriteCallBack, Netplay.serverSock[Index].networkStream);
}
/// <summary>
/// Adds a command callback to a specified command string.
/// </summary>
/// <param name="name">The string representing the command i.e "yes" == /yes</param>
/// <param name="callback">The method that will be executed on confirmation ie user accepts</param>
public void AddResponse( string name, Action<object> callback)
{
if( AwaitingResponse.ContainsKey(name))
{
AwaitingResponse.Remove(name);
}
/// <summary>
/// Adds a command callback to a specified command string.
/// </summary>
/// <param name="name">The string representing the command i.e "yes" == /yes</param>
/// <param name="callback">The method that will be executed on confirmation ie user accepts</param>
public void AddResponse( string name, Action<object> callback)
{
if( AwaitingResponse.ContainsKey(name))
{
AwaitingResponse.Remove(name);
}
AwaitingResponse.Add(name, callback);
}
AwaitingResponse.Add(name, callback);
}
}
public class TSRestPlayer : TSPlayer
@ -924,14 +923,9 @@ namespace TShockAPI
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)
{
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)
@ -967,45 +961,40 @@ namespace TShockAPI
public class TSServerPlayer : TSPlayer
{
public static string AccountName = "ServerConsole";
public static string AccountName = "ServerConsole";
public TSServerPlayer()
: base("Server")
{
Group = new SuperAdminGroup();
UserAccountName = AccountName;
UserAccountName = AccountName;
}
public override void SendErrorMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendInfoMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendSuccessMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendWarningMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendMessage(string msg)
public override void SendErrorMessage(string msg)
{
SendMessage(msg, 0, 255, 0);
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendInfoMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendSuccessMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendWarningMessage(string msg)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(msg);
Console.ResetColor();
}
public override void SendMessage(string msg, Color color)
@ -1016,7 +1005,6 @@ namespace TShockAPI
public override void SendMessage(string msg, byte red, byte green, byte blue)
{
Console.WriteLine(msg);
//RconHandler.Response += msg + "\n";
}
public void SetFullMoon()
@ -1093,7 +1081,7 @@ namespace TShockAPI
int spawnTileX;
int spawnTileY;
TShock.Utils.GetRandomClearTileWithInRange(startTileX, startTileY, tileXRange, tileYRange, out spawnTileX,
out spawnTileY);
out spawnTileY);
int npcid = NPC.NewNPC(spawnTileX*16, spawnTileY*16, type, 0);
// This is for special slimes
Main.npc[npcid].SetDefaults(name);
@ -1407,19 +1395,19 @@ namespace TShockAPI
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[8].name, player.Index, 67f, (float)Main.player[player.Index].armor[8].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[9].name, player.Index, 68f, (float)Main.player[player.Index].armor[9].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[10].name, player.Index, 69f, (float)Main.player[player.Index].armor[10].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[11].name, player.Index, 70f, (float)Main.player[player.Index].armor[11].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[12].name, player.Index, 71f, (float)Main.player[player.Index].armor[12].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[13].name, player.Index, 72f, (float)Main.player[player.Index].armor[13].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[14].name, player.Index, 73f, (float)Main.player[player.Index].armor[14].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[15].name, player.Index, 74f, (float)Main.player[player.Index].armor[15].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[11].name, player.Index, 70f, (float)Main.player[player.Index].armor[11].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[12].name, player.Index, 71f, (float)Main.player[player.Index].armor[12].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[13].name, player.Index, 72f, (float)Main.player[player.Index].armor[13].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[14].name, player.Index, 73f, (float)Main.player[player.Index].armor[14].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].armor[15].name, player.Index, 74f, (float)Main.player[player.Index].armor[15].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[0].name, player.Index, 75f, (float)Main.player[player.Index].dye[0].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[1].name, player.Index, 76f, (float)Main.player[player.Index].dye[1].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[2].name, player.Index, 77f, (float)Main.player[player.Index].dye[2].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[3].name, player.Index, 78f, (float)Main.player[player.Index].dye[3].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[4].name, player.Index, 79f, (float)Main.player[player.Index].dye[4].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[5].name, player.Index, 80f, (float)Main.player[player.Index].dye[5].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[6].name, player.Index, 81f, (float)Main.player[player.Index].dye[6].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[7].name, player.Index, 82f, (float)Main.player[player.Index].dye[7].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[3].name, player.Index, 78f, (float)Main.player[player.Index].dye[3].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[4].name, player.Index, 79f, (float)Main.player[player.Index].dye[4].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[5].name, player.Index, 80f, (float)Main.player[player.Index].dye[5].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[6].name, player.Index, 81f, (float)Main.player[player.Index].dye[6].prefix, 0f, 0);
NetMessage.SendData(5, -1, -1, Main.player[player.Index].dye[7].name, player.Index, 82f, (float)Main.player[player.Index].dye[7].prefix, 0f, 0);
NetMessage.SendData(4, -1, -1, player.Name, player.Index, 0f, 0f, 0f, 0);
NetMessage.SendData(42, -1, -1, "", player.Index, 0f, 0f, 0f, 0);
NetMessage.SendData(16, -1, -1, "", player.Index, 0f, 0f, 0f, 0);
@ -1428,30 +1416,31 @@ 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].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[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[3].name, player.Index, 62f, (float)Main.player[player.Index].armor[3].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[4].name, player.Index, 63f, (float)Main.player[player.Index].armor[4].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[5].name, player.Index, 64f, (float)Main.player[player.Index].armor[5].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[6].name, player.Index, 65f, (float)Main.player[player.Index].armor[6].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[7].name, player.Index, 66f, (float)Main.player[player.Index].armor[7].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[8].name, player.Index, 67f, (float)Main.player[player.Index].armor[8].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[9].name, player.Index, 68f, (float)Main.player[player.Index].armor[9].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[10].name, player.Index, 69f, (float)Main.player[player.Index].armor[10].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[11].name, player.Index, 70f, (float)Main.player[player.Index].armor[11].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[12].name, player.Index, 71f, (float)Main.player[player.Index].armor[12].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[13].name, player.Index, 72f, (float)Main.player[player.Index].armor[13].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[14].name, player.Index, 73f, (float)Main.player[player.Index].armor[14].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[15].name, player.Index, 74f, (float)Main.player[player.Index].armor[15].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[0].name, player.Index, 75f, (float)Main.player[player.Index].dye[0].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[1].name, player.Index, 76f, (float)Main.player[player.Index].dye[1].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[2].name, player.Index, 77f, (float)Main.player[player.Index].dye[2].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[3].name, player.Index, 78f, (float)Main.player[player.Index].dye[3].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[4].name, player.Index, 79f, (float)Main.player[player.Index].dye[4].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[5].name, player.Index, 80f, (float)Main.player[player.Index].dye[5].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[6].name, player.Index, 81f, (float)Main.player[player.Index].dye[6].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[7].name, player.Index, 82f, (float)Main.player[player.Index].dye[7].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[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[3].name, player.Index, 62f, (float)Main.player[player.Index].armor[3].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[4].name, player.Index, 63f, (float)Main.player[player.Index].armor[4].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[5].name, player.Index, 64f, (float)Main.player[player.Index].armor[5].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[6].name, player.Index, 65f, (float)Main.player[player.Index].armor[6].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[7].name, player.Index, 66f, (float)Main.player[player.Index].armor[7].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[8].name, player.Index, 67f, (float)Main.player[player.Index].armor[8].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[9].name, player.Index, 68f, (float)Main.player[player.Index].armor[9].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[10].name, player.Index, 69f, (float)Main.player[player.Index].armor[10].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[11].name, player.Index, 70f, (float)Main.player[player.Index].armor[11].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[12].name, player.Index, 71f, (float)Main.player[player.Index].armor[12].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[13].name, player.Index, 72f, (float)Main.player[player.Index].armor[13].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[14].name, player.Index, 73f, (float)Main.player[player.Index].armor[14].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].armor[15].name, player.Index, 74f, (float)Main.player[player.Index].armor[15].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[0].name, player.Index, 75f, (float)Main.player[player.Index].dye[0].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[1].name, player.Index, 76f, (float)Main.player[player.Index].dye[1].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[2].name, player.Index, 77f, (float)Main.player[player.Index].dye[2].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[3].name, player.Index, 78f, (float)Main.player[player.Index].dye[3].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[4].name, player.Index, 79f, (float)Main.player[player.Index].dye[4].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[5].name, player.Index, 80f, (float)Main.player[player.Index].dye[5].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[6].name, player.Index, 81f, (float)Main.player[player.Index].dye[6].prefix, 0f, 0);
NetMessage.SendData(5, player.Index, -1, Main.player[player.Index].dye[7].name, player.Index, 82f, (float)Main.player[player.Index].dye[7].prefix, 0f, 0);
NetMessage.SendData(4, player.Index, -1, player.Name, player.Index, 0f, 0f, 0f, 0);
NetMessage.SendData(42, player.Index, -1, "", player.Index, 0f, 0f, 0f, 0);
NetMessage.SendData(16, player.Index, -1, "", player.Index, 0f, 0f, 0f, 0);

View file

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