diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 2c9d77b3..85340da0 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -2203,8 +2203,13 @@ namespace TShockAPI return true; } } - if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[Main.tile[tileX, tileY].type]) + if (TShock.Config.AllowCutTilesAndBreakables && Main.tileCut[tile.type]) { + if (action == EditAction.KillWall) + { + args.Player.SendTileSquare(tileX, tileY, 1); + return true; + } return false; } diff --git a/TShockAPI/Rest/RestManager.cs b/TShockAPI/Rest/RestManager.cs index b62fc9dd..20e0ddb2 100644 --- a/TShockAPI/Rest/RestManager.cs +++ b/TShockAPI/Rest/RestManager.cs @@ -23,7 +23,6 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Reflection; -using System.Reflection.Emit; using System.Text; using HttpServer; using Rests; @@ -102,12 +101,14 @@ namespace TShockAPI // Server Commands if (TShock.Config.EnableTokenEndpointAuthentication) { + Rest.Register(new SecureRestCommand("/status", ServerStatusRoot)); Rest.Register(new SecureRestCommand("/v2/server/status", ServerStatusV2)); Rest.Register(new SecureRestCommand("/v3/server/motd", ServerMotd)); Rest.Register(new SecureRestCommand("/v3/server/rules", ServerRules)); } else { + Rest.Register(new RestCommand("/status", (a) => this.ServerStatusRoot(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v2/server/status", (a) => this.ServerStatusV2(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v3/server/motd", (a) => this.ServerMotd(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); Rest.Register(new RestCommand("/v3/server/rules", (a) => this.ServerRules(new RestRequestArgs(a.Verbs, a.Parameters, a.Request, SecureRest.TokenData.None, a.Context)))); @@ -274,6 +275,16 @@ namespace TShockAPI }; } + [Description("Get a list of information about the current TShock server.")] + [Route("/status")] + [Token] + private object ServerStatusRoot(RestRequestArgs args) + { + RestObject status = (RestObject)ServerStatusV2(args); + status.Add("upgrade", "/v2/server/status"); + return status; + } + [Description("Get a list of information about the current TShock server.")] [Route("/v2/server/status")] [Token] @@ -761,10 +772,11 @@ namespace TShockAPI return new RestObject() { {"nickname", player.Name}, - {"username", null == player.User ? "" : player.User.Name}, + {"username", player.User?.Name}, {"ip", player.IP}, {"group", player.Group.Name}, - {"registered", null == player.User ? "" : player.User.Registered}, + {"registered", player.User?.Registered}, + {"muted", player.mute }, {"position", player.TileX + "," + player.TileY}, {"inventory", string.Join(", ", inventory.Select(p => (p.name + ":" + p.stack)))}, {"armor", string.Join(", ", equipment.Select(p => (p.netID + ":" + p.prefix)))}, diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index fcd30a65..1efab2a3 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -822,6 +822,7 @@ namespace TShockAPI /// AuthToken - The auth token used by the /auth system to grant temporary superadmin access to new admins. public static int AuthToken = -1; + private string _cliPassword = null; /// OnPostInit - Fired when the server loads a map, to perform world specific operations. /// args - The EventArgs object. @@ -829,6 +830,16 @@ namespace TShockAPI { SetConsoleTitle(false); + //This is to prevent a bug where a CLI-defined password causes packets to be + //sent in an unexpected order, resulting in clients being unable to connect + if (!string.IsNullOrEmpty(Netplay.ServerPassword)) + { + //CLI defined password overrides a config password + _cliPassword = Netplay.ServerPassword; + Netplay.ServerPassword = ""; + Config.ServerPassword = _cliPassword; + } + // Disable the auth system if "auth.lck" is present or a superadmin exists if (File.Exists(Path.Combine(SavePath, "auth.lck")) || Users.GetUsers().Exists(u => u.Group == new SuperAdminGroup().Name)) { @@ -2172,7 +2183,14 @@ namespace TShockAPI if (file.MaxSlots > 235) file.MaxSlots = 235; Main.maxNetPlayers = file.MaxSlots + 20; + Netplay.ServerPassword = ""; + if (!string.IsNullOrEmpty(_cliPassword)) + { + //This prevents a config reload from removing/updating a CLI-defined password + file.ServerPassword = _cliPassword; + } + Netplay.spamCheck = false; } } diff --git a/TerrariaServerAPI b/TerrariaServerAPI index 302124e1..ecb3b742 160000 --- a/TerrariaServerAPI +++ b/TerrariaServerAPI @@ -1 +1 @@ -Subproject commit 302124e1bcf6a6661d518b84f630384a90dbcbcb +Subproject commit ecb3b742b795fb489f9fb6f8ee1c17667f64f85a