Added HardcoreOnly
This commit is contained in:
parent
f839308883
commit
5dfc4f6e60
3 changed files with 16 additions and 1 deletions
|
|
@ -59,5 +59,7 @@ namespace TShockAPI
|
|||
public int Spawn_WorldID;
|
||||
|
||||
public bool RememberLeavePos = false;
|
||||
|
||||
public bool HardcoreOnly = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue