diff --git a/TShockAPI/DB/BanManager.cs b/TShockAPI/DB/BanManager.cs index 3fa732dd..7a1015cd 100755 --- a/TShockAPI/DB/BanManager.cs +++ b/TShockAPI/DB/BanManager.cs @@ -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; } diff --git a/TShockAPI/DB/CharacterManager.cs b/TShockAPI/DB/CharacterManager.cs index df9f75a1..1c4f855b 100755 --- a/TShockAPI/DB/CharacterManager.cs +++ b/TShockAPI/DB/CharacterManager.cs @@ -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; diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index 2021ff25..2d7861ed 100755 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -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("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 groupChain = new List { 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); } } } diff --git a/TShockAPI/DB/ProjectileManager.cs b/TShockAPI/DB/ProjectileManager.cs index f2ceed1c..ee955a2f 100755 --- a/TShockAPI/DB/ProjectileManager.cs +++ b/TShockAPI/DB/ProjectileManager.cs @@ -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; diff --git a/TShockAPI/DB/RegionManager.cs b/TShockAPI/DB/RegionManager.cs index 1128a3ae..fc281b21 100755 --- a/TShockAPI/DB/RegionManager.cs +++ b/TShockAPI/DB/RegionManager.cs @@ -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; diff --git a/TShockAPI/DB/TileManager.cs b/TShockAPI/DB/TileManager.cs index 9144d34d..bf7f28dc 100755 --- a/TShockAPI/DB/TileManager.cs +++ b/TShockAPI/DB/TileManager.cs @@ -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; diff --git a/TShockAPI/DB/WarpsManager.cs b/TShockAPI/DB/WarpsManager.cs index 88c97e9b..a4c380aa 100755 --- a/TShockAPI/DB/WarpsManager.cs +++ b/TShockAPI/DB/WarpsManager.cs @@ -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; } diff --git a/TShockAPI/Rest/Rest.cs b/TShockAPI/Rest/Rest.cs index 17c032cd..a5e77115 100644 --- a/TShockAPI/Rest/Rest.cs +++ b/TShockAPI/Rest/Rest.cs @@ -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; diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index 93d81eee..5acf24e8 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -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); } diff --git a/TShockAPI/Rest/SecureRest.cs b/TShockAPI/Rest/SecureRest.cs index ee9eac2f..0913a87d 100644 --- a/TShockAPI/Rest/SecureRest.cs +++ b/TShockAPI/Rest/SecureRest.cs @@ -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); } } diff --git a/TShockAPI/SaveManager.cs b/TShockAPI/SaveManager.cs index 22d65873..08ee376a 100644 --- a/TShockAPI/SaveManager.cs +++ b/TShockAPI/SaveManager.cs @@ -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) { diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index af134d5b..9ce38fef 100755 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -30,29 +30,29 @@ namespace TShockAPI { public class TSPlayer { - /// - /// This represents the server as a player. - /// + /// + /// This represents the server as a player. + /// public static readonly TSServerPlayer Server = new TSServerPlayer(); - /// - /// This player represents all the players. - /// + /// + /// This player represents all the players. + /// public static readonly TSPlayer All = new TSPlayer("All"); - /// - /// The amount of tiles that the player has killed in the last second. - /// + /// + /// The amount of tiles that the player has killed in the last second. + /// public int TileKillThreshold { get; set; } - /// - /// The amount of tiles the player has placed in the last second. - /// - public int TilePlaceThreshold { get; set; } + /// + /// The amount of tiles the player has placed in the last second. + /// + public int TilePlaceThreshold { get; set; } - /// - /// The amount of liquid (in tiles) that the player has placed in the last second. - /// + /// + /// The amount of liquid (in tiles) that the player has placed in the last second. + /// public int TileLiquidThreshold { get; set; } /// @@ -60,9 +60,9 @@ namespace TShockAPI /// public int PaintThreshold { get; set; } - /// - /// The number of projectiles created by the player in the last second. - /// + /// + /// The number of projectiles created by the player in the last second. + /// public int ProjectileThreshold { get; set; } /// @@ -83,130 +83,130 @@ namespace TShockAPI public int sX = -1; public int sY = -1; - /// - /// A queue of tiles destroyed by the player for reverting. - /// + /// + /// A queue of tiles destroyed by the player for reverting. + /// public Dictionary TilesDestroyed { get; protected set; } - /// - /// A queue of tiles placed by the player for reverting. - /// + /// + /// A queue of tiles placed by the player for reverting. + /// public Dictionary TilesCreated { get; protected set; } - /// - /// The player's group. - /// - public Group Group - { - get - { - if (tempGroup != null) - return tempGroup; - return group; - } - set { group = value; } - } + /// + /// The player's group. + /// + public Group Group + { + get + { + if (tempGroup != null) + return tempGroup; + return group; + } + set { group = value; } + } - /// - /// The player's temporary group. This overrides the user's actual group. - /// - public Group tempGroup = null; + /// + /// The player's temporary group. This overrides the user's actual group. + /// + public Group tempGroup = null; - private Group group = null; + private Group group = null; public bool ReceivedInfo { get; set; } - /// - /// The players index in the player array( Main.players[] ). - /// + /// + /// The players index in the player array( Main.players[] ). + /// public int Index { get; protected set; } - /// - /// The last time the player changed their team or pvp status. - /// + /// + /// The last time the player changed their team or pvp status. + /// public DateTime LastPvPTeamChange; - /// - /// Temp points for use in regions and other plugins. - /// + /// + /// Temp points for use in regions and other plugins. + /// public Point[] TempPoints = new Point[2]; - /// - /// Whether the player is waiting to place/break a tile to set as a temp point. - /// + /// + /// Whether the player is waiting to place/break a tile to set as a temp point. + /// public int AwaitingTempPoint { get; set; } - /// - /// A list of command callbacks indexed by the command they need to do. - /// - public Dictionary> AwaitingResponse; + /// + /// A list of command callbacks indexed by the command they need to do. + /// + public Dictionary> AwaitingResponse; public bool AwaitingName { get; set; } public string[] AwaitingNameParameters { get; set; } - /// - /// The last time a player broke a grief check. - /// + /// + /// The last time a player broke a grief check. + /// public DateTime LastThreat { get; set; } public bool InitSpawn; - /// - /// Whether the player should see logs. - /// + /// + /// Whether the player should see logs. + /// public bool DisplayLogs = true; - /// - /// The last player that the player whispered with (to or from). - /// + /// + /// The last player that the player whispered with (to or from). + /// public TSPlayer LastWhisper; - /// - /// The number of unsuccessful login attempts. - /// + /// + /// The number of unsuccessful login attempts. + /// public int LoginAttempts { get; set; } public Vector2 TeleportCoords = new Vector2(-1, -1); public Vector2 LastNetPosition = Vector2.Zero; - /// - /// The player's login name. - /// + /// + /// The player's login name. + /// public string UserAccountName { get; set; } - /// - /// 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. - /// + /// + /// 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. + /// public bool LoginFailsBySsi { get; set; } - /// - /// Whether the player is logged in or not. - /// + /// + /// Whether the player is logged in or not. + /// public bool IsLoggedIn; - /// - /// Whether the player has sent their whole inventory to the server while connecting. - /// + /// + /// Whether the player has sent their whole inventory to the server while connecting. + /// public bool HasSentInventory { get; set; } - /// - /// The player's user id( from the db ). - /// + /// + /// The player's user id( from the db ). + /// public int UserID = -1; - /// - /// Whether the player has been nagged about logging in. - /// + /// + /// Whether the player has been nagged about logging in. + /// public bool HasBeenNaggedAboutLoggingIn; - public bool TPAllow = true; + public bool TPAllow = true; - /// - /// Whether the player is muted or not. - /// + /// + /// Whether the player is muted or not. + /// public bool mute; private Player FakePlayer; @@ -218,16 +218,16 @@ namespace TShockAPI /// public int RespawnTimer; - /// - /// Whether the player is dead or not. - /// + /// + /// Whether the player is dead or not. + /// public bool Dead; public string Country = "??"; - /// - /// The players difficulty( normal[softcore], mediumcore, hardcore ). - /// + /// + /// The players difficulty( normal[softcore], mediumcore, hardcore ). + /// public int Difficulty; private string CacheIP; @@ -240,53 +240,53 @@ namespace TShockAPI public bool IgnoreActionsForClearingTrashCan; - /// - /// The player's server side inventory data. - /// + /// + /// The player's server side inventory data. + /// public PlayerData PlayerData; - /// - /// Whether the player needs to specify a password upon connection( either server or user account ). - /// + /// + /// Whether the player needs to specify a password upon connection( either server or user account ). + /// public bool RequiresPassword; public bool SilentKickInProgress; public bool SilentJoinInProgress; - /// - /// A list of points where ice tiles have been placed. - /// + /// + /// A list of points where ice tiles have been placed. + /// public List IceTiles; - /// - /// Unused, can be removed. - /// - public long RPm = 1; + /// + /// Unused, can be removed. + /// + public long RPm = 1; - /// - /// World protection message cool down. - /// - public long WPm = 1; + /// + /// World protection message cool down. + /// + public long WPm = 1; - /// - /// Spawn protection message cool down. - /// - public long SPm = 1; - - /// - /// Permission to build message cool down. - /// - public long BPm = 1; + /// + /// Spawn protection message cool down. + /// + public long SPm = 1; + + /// + /// Permission to build message cool down. + /// + public long BPm = 1; - /// - /// The time in ms when the player has logged in. - /// + /// + /// The time in ms when the player has logged in. + /// public long LoginMS; - /// - /// Whether the player has been harrassed about logging in due to server side inventory or forced login. - /// + /// + /// Whether the player has been harrassed about logging in due to server side inventory or forced login. + /// public bool LoginHarassed = false; /// @@ -304,9 +304,9 @@ namespace TShockAPI /// public int LastKilledProjectile = 0; - /// - /// Whether the player is a real, human, player on the server. - /// + /// + /// Whether the player is a real, human, player on the server. + /// 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(); TilesCreated = new Dictionary(); Index = index; - Group = Group.DefaultGroup; + Group = Group.DefaultGroup; IceTiles = new List(); - AwaitingResponse = new Dictionary>(); + AwaitingResponse = new Dictionary>(); } protected TSPlayer(String playerName) @@ -499,8 +499,8 @@ namespace TShockAPI TilesCreated = new Dictionary(); Index = -1; FakePlayer = new Player {name = playerName, whoAmi = -1}; - Group = Group.DefaultGroup; - AwaitingResponse = new Dictionary>(); + Group = Group.DefaultGroup; + AwaitingResponse = new Dictionary>(); } 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); } - /// - /// Adds a command callback to a specified command string. - /// - /// The string representing the command i.e "yes" == /yes - /// The method that will be executed on confirmation ie user accepts - public void AddResponse( string name, Action callback) - { - if( AwaitingResponse.ContainsKey(name)) - { - AwaitingResponse.Remove(name); - } + /// + /// Adds a command callback to a specified command string. + /// + /// The string representing the command i.e "yes" == /yes + /// The method that will be executed on confirmation ie user accepts + public void AddResponse( string name, Action 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>(); } - 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); diff --git a/TShockAPI/UpdateManager.cs b/TShockAPI/UpdateManager.cs index 5448fb35..5ccc1c85 100755 --- a/TShockAPI/UpdateManager.cs +++ b/TShockAPI/UpdateManager.cs @@ -94,7 +94,7 @@ namespace TShockAPI } catch (Exception e) { - Log.ConsoleError("UpdateManager Exception: {0}", e); + TShock.Log.ConsoleError("UpdateManager Exception: {0}", e); throw e; }