diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 6e6de82b..b8c9f33a 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -59,5 +59,7 @@ namespace TShockAPI public int Spawn_WorldID; public bool RememberLeavePos = false; + + public bool HardcoreOnly = false; } } \ No newline at end of file diff --git a/TShockAPI/ConfigurationManager.cs b/TShockAPI/ConfigurationManager.cs index 0dd04bbc..b3f2fba8 100644 --- a/TShockAPI/ConfigurationManager.cs +++ b/TShockAPI/ConfigurationManager.cs @@ -81,6 +81,8 @@ namespace TShockAPI public static int originalSpawnX; public static int originalSpawnY; + public static bool hardcoreOnly = false; + public static void ReadJsonConfiguration() { TextReader tr = new StreamReader(FileTools.ConfigPath); @@ -125,6 +127,7 @@ namespace TShockAPI Main.spawnTileY = cfg.spawnTileY; Spawn_WorldID = cfg.Spawn_WorldID; RememberLeavePos = cfg.RememberLeavePos; + hardcoreOnly = cfg.HardcoreOnly; } public static void WriteJsonConfiguration() @@ -163,6 +166,7 @@ namespace TShockAPI cfg.spawnTileY = Main.spawnTileY; cfg.RememberLeavePos = RememberLeavePos; cfg.Spawn_WorldID = Spawn_WorldID; + cfg.HardcoreOnly = hardcoreOnly; string json = JsonConvert.SerializeObject(cfg, Formatting.Indented); TextWriter tr = new StreamWriter(FileTools.ConfigPath); tr.Write(json); diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index b23b5732..ecd1cb20 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -132,7 +132,10 @@ namespace TShockAPI { byte playerid = args.Data.ReadInt8(); byte hair = args.Data.ReadInt8(); - args.Data.Position += 22; + //Various colours here + + args.Data.Position += 21; + bool hardcore = args.Data.ReadBoolean(); string name = Encoding.ASCII.GetString(args.Data.ReadBytes((int)(args.Data.Length - args.Data.Position - 1))); if (hair >= Main.maxHair) @@ -160,6 +163,12 @@ namespace TShockAPI { return Tools.HandleGriefer(args.Player, "Sent client info more than once"); } + if (ConfigurationManager.hardcoreOnly) + if (!hardcore) + { + Tools.ForceKick(args.Player, "Server is set to hardcore characters only!"); + return true; + } args.Player.ReceivedInfo = true; return false;