From de2a07db6bc88aa8fa4d87042168d8ab7232afaa Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 9 Mar 2015 07:56:27 -0600 Subject: [PATCH 01/11] Advertise https websites (this is 2015) --- TShockAPI/Commands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index c04f2b00..f48c23c2 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -4449,7 +4449,7 @@ namespace TShockAPI args.Player.SendSuccessMessage("Your new account has been verified, and the /auth system has been turned off."); args.Player.SendSuccessMessage("You can always use the /user command to manage players. Don't just delete the auth.lck."); - args.Player.SendSuccessMessage("Thank you for using TShock! http://tshock.co/ & http://github.com/TShock/TShock"); + args.Player.SendSuccessMessage("Thank you for using TShock! https://tshock.co/ & https://github.com/TShock/TShock"); FileTools.CreateFile(Path.Combine(TShock.SavePath, "auth.lck")); File.Delete(Path.Combine(TShock.SavePath, "authcode.txt")); TShock.AuthToken = 0; From bca48fb2eb5095850bbde5d70b2a85be78f5773f Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Mon, 9 Mar 2015 23:34:07 -0600 Subject: [PATCH 02/11] Attempt to fix tempbans not working --- TShockAPI/Commands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index f48c23c2..8835ee64 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -1285,11 +1285,11 @@ namespace TShockAPI { if (args.Silent) { - args.Player.SendInfoMessage("[broken name] was {1}banned for '{2}'.", force ? "force " : "", reason); + args.Player.SendInfoMessage("[broken name] was {0}banned for '{1}'.", force ? "force " : "", reason); } else { - TSPlayer.All.SendInfoMessage("{0} {1}banned [broken name] for '{3}'.", args.Player.Name, force ? "force " : "", reason); + TSPlayer.All.SendInfoMessage("{0} {1}banned [broken name] for '{2}'.", args.Player.Name, force ? "force " : "", reason); } } } From 27553ce892be927633672dcb949cfcd5152a9081 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 10 Mar 2015 01:21:23 -0600 Subject: [PATCH 03/11] Update .travis.yml to support slack notifications --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 622133dc..e7357131 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,5 @@ solution: ./TShockAPI/TShockAPI.csproj notifications: hipchat: secure: hpRLWiHF2j6O2qJOVs++aqAmryN6G5kY0SF26/rKCpQ7klhMlDZIgI1V1dbkKqlculFtW1neS0EBJyV9lmcV5b26H+KhlZYGN0j7q1VcOTM3rvtU6wW0Ap22uRLl2RrnA4kEsgDAsNouPOkyLZ19hlHAISlsId6G4+Rfqg6k+zQ= + slack: + secure: O4Nibe2fdaUa2ZxuETUg6WEoQKvNM2CotnfaIVgm3fjfe61dfE1P+EgTpbwDG8646jSmpTqMDw8Z6I/WJwGTlXV/ZQsbwu63Cps4MgOTvPHZ0Lsye5azySlJZs1iI4ItYSj2czXfcnJ+qAl1SOOkXJrjB5uyTMWtDpCrSCFB3MA= From 7187245879bc9c33eb4b31b724f0f0fe895f945d Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 10 Mar 2015 11:14:21 -0600 Subject: [PATCH 04/11] Fix deprecation message fixes #880 --- TShockAPI/DB/SqlTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/DB/SqlTable.cs b/TShockAPI/DB/SqlTable.cs index 5245e04c..fefd8d22 100755 --- a/TShockAPI/DB/SqlTable.cs +++ b/TShockAPI/DB/SqlTable.cs @@ -76,7 +76,7 @@ namespace TShockAPI.DB /// Ensures a table exists and that its structure is correct /// /// The table name - [Obsolete("This method will be replaced by EnsureTableExists.")] + [Obsolete("This method will be replaced by EnsureTableStructure.")] public void EnsureExists(SqlTable table) { EnsureTableStructure(table); From caf3c662ebab44aa3093ea664e003a5e50bbc390 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Tue, 10 Mar 2015 11:15:52 -0600 Subject: [PATCH 05/11] Fix more random tab/spaces in SqlTable.cs --- TShockAPI/DB/SqlTable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/DB/SqlTable.cs b/TShockAPI/DB/SqlTable.cs index fefd8d22..8a9a9c2d 100755 --- a/TShockAPI/DB/SqlTable.cs +++ b/TShockAPI/DB/SqlTable.cs @@ -73,10 +73,10 @@ namespace TShockAPI.DB } /// - /// Ensures a table exists and that its structure is correct + /// Ensures a table exists and that its structure is correct /// /// The table name - [Obsolete("This method will be replaced by EnsureTableStructure.")] + [Obsolete("This method will be replaced by EnsureTableStructure.")] public void EnsureExists(SqlTable table) { EnsureTableStructure(table); From 03d817e0a28bdd0c472bef5ae493ffdfbc556f4e Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 11 Mar 2015 09:00:14 -0600 Subject: [PATCH 06/11] Return more modern error in AddGroup --- TShockAPI/DB/GroupManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index b8d0c4a2..1772dc9c 100755 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -124,7 +124,7 @@ namespace TShockAPI.DB { if (exceptions) throw new GroupExistsException(name); - return "Error: Group already exists. Use /modgroup to change permissions."; + return "Error: Group already exists; unable to add group."; } var group = new Group(name, null, chatcolor); From da8ce502bca0c0abac5c8270c2bacdb0ce8b7824 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Wed, 11 Mar 2015 09:10:40 -0600 Subject: [PATCH 07/11] Add replacement for string AddGroup Add deprecation warnings to previous methods --- TShockAPI/DB/GroupManager.cs | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/TShockAPI/DB/GroupManager.cs b/TShockAPI/DB/GroupManager.cs index 1772dc9c..c817705d 100755 --- a/TShockAPI/DB/GroupManager.cs +++ b/TShockAPI/DB/GroupManager.cs @@ -110,6 +110,45 @@ namespace TShockAPI.DB return 1 == ret.Count() ? ret.ElementAt(0) : null; } + /// + /// Adds group with name and permissions if it does not exist. + /// + /// name of group + /// parent of group + /// permissions + /// chatcolor + public void AddGroup(String name, string parentname, String permissions, String chatcolor) + { + if (GroupExists(name)) + { + throw new GroupExistsException(name); + } + + var group = new Group(name, null, chatcolor); + group.Permissions = permissions; + if (!string.IsNullOrWhiteSpace(parentname)) + { + var parent = groups.FirstOrDefault(gp => gp.Name == parentname); + if (parent == null || name == parentname) + { + var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name); + TShock.Log.ConsoleError(error); + throw new GroupManagerException(error); + } + group.Parent = parent; + } + + string query = (TShock.Config.StorageType.ToLower() == "sqlite") + ? "INSERT OR IGNORE INTO GroupList (GroupName, Parent, Commands, ChatColor) VALUES (@0, @1, @2, @3);" + : "INSERT IGNORE INTO GroupList SET GroupName=@0, Parent=@1, Commands=@2, ChatColor=@3"; + if (database.Query(query, name, parentname, permissions, chatcolor) == 1) + { + groups.Add(group); + } + else + throw new GroupManagerException("Failed to add group '" + name + ".'"); + } + /// /// Adds group with name and permissions if it does not exist. /// @@ -118,6 +157,7 @@ namespace TShockAPI.DB /// permissions /// chatcolor /// exceptions true indicates use exceptions for errors false otherwise + [Obsolete("Use AddGroup(name, parentname, permissions, chatcolor) instead.")] public String AddGroup(String name, string parentname, String permissions, String chatcolor = Group.defaultChatColor, bool exceptions = false) { if (GroupExists(name)) From 27de182ef9b9985e98e46c0db7af7175cabd37dc Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Fri, 13 Mar 2015 12:52:48 -0400 Subject: [PATCH 08/11] Log is not initialized when using command lines early enough, so dump to serverapi.logger. --- TShockAPI/TShock.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 4374c295..ebaf7a0a 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -483,7 +483,7 @@ namespace TShockAPI if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) { SavePath = path; - Log.ConsoleInfo("Config path has been set to " + path); + ServerApi.LogWriter.PluginWriteLine(this, "Config path has been set to " + path, TraceLevel.Info); } break; @@ -492,7 +492,7 @@ namespace TShockAPI if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) { Main.WorldPath = path; - Log.ConsoleInfo("World path has been set to " + path); + ServerApi.LogWriter.PluginWriteLine(this, "World path has been set to " + path, TraceLevel.Info); } break; @@ -501,7 +501,7 @@ namespace TShockAPI if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) { LogPath = path; - Log.ConsoleInfo("Log path has been set to " + path); + ServerApi.LogWriter.PluginWriteLine(this, "Log path has been set to " + path, TraceLevel.Info); } break; From eda5ba312edb78d60e932e5b217699213b4c10b4 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 14 Mar 2015 13:38:22 -0600 Subject: [PATCH 09/11] Remove deprecated GetUsers() and IDs method Thanks @Enerdy --- TShockAPI/Utils.cs | 48 +--------------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index a4884856..873b2ee7 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -63,28 +63,6 @@ namespace TShockAPI return mess.Split(':')[0]; } - /// - /// Used for some places where a list of players might be used. - /// - /// String of players seperated by commas. - [Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")] - public string GetPlayers() - { - var sb = new StringBuilder(); - foreach (TSPlayer player in TShock.Players) - { - if (player != null && player.Active) - { - if (sb.Length != 0) - { - sb.Append(", "); - } - sb.Append(player.Name); - } - } - return sb.ToString(); - } - /// /// Returns a list of current players on the server /// @@ -112,30 +90,6 @@ namespace TShockAPI return players; } - /// - /// Used for some places where a list of players might be used. - /// - /// String of players and their id seperated by commas. - [Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")] - public string GetPlayersWithIds() - { - var sb = new StringBuilder(); - foreach (TSPlayer player in TShock.Players) - { - if (player != null && player.Active) - { - if (sb.Length != 0) - { - sb.Append(", "); - } - sb.Append(player.Name); - string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")"; - sb.Append(id); - } - } - return sb.ToString(); - } - /// /// Finds a player and gets IP as string /// @@ -697,7 +651,7 @@ namespace TShockAPI } foo = foo.Replace("%map%", Main.worldName); - foo = foo.Replace("%players%", GetPlayers()); + foo = foo.Replace("%players%", String.Join(",", GetPlayers(false))); Regex reg = new Regex("%\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*,\\s*(?\\d{1,3})\\s*%"); var matches = reg.Matches(foo); Color c = Color.White; From 0b55e59ed47fc90c1480890c1f1da3041baf412e Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Sun, 15 Mar 2015 12:29:41 -0400 Subject: [PATCH 10/11] Fixes SSC error message not being formatted --- TShockAPI/TShock.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index ebaf7a0a..e7c605fe 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1229,7 +1229,7 @@ namespace TShockAPI if (Main.ServerSideCharacter) { player.SendErrorMessage( - player.IgnoreActionsForInventory = "Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier); + player.IgnoreActionsForInventory = String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier)); player.LoginHarassed = true; } else if (Config.RequireLogin) From 372a344b5a1da7cd083629d430ed494caa356aab Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 15 Mar 2015 15:02:06 -0600 Subject: [PATCH 11/11] Version tick: 4.2.8 --- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index 32afbe74..9e1ba90f 100755 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -53,5 +53,5 @@ using System.Runtime.InteropServices; // Also, be sure to release on github with the exact assembly version tag as below // so that the update manager works correctly (via the Github releases api and mimic) -[assembly: AssemblyVersion("4.2.7")] -[assembly: AssemblyFileVersion("4.2.7")] +[assembly: AssemblyVersion("4.2.8")] +[assembly: AssemblyFileVersion("4.2.8")]