Fix player respawn again (#1830)

* fix respawn time unit, add spawn bouncer, add respawn time config warning

Co-authored-by: Lucas Nicodemus <shank@shanked.me>
This commit is contained in:
Axeel 2020-05-21 13:37:31 +08:00 committed by GitHub
parent 341424248c
commit 56a9e27365
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View file

@ -441,12 +441,12 @@ namespace TShockAPI
[Description("Whether or not to log REST API connections.")]
public bool LogRest = false;
/// <summary>The number of seconds a player must wait before being respawned.</summary>
[Description("The number of seconds a player must wait before being respawned.")]
/// <summary>The number of seconds a player must wait before being respawned. Cannot be longer than normal value now. Use at your own risk.</summary>
[Description("The number of seconds a player must wait before being respawned. Cannot be longer than normal value now. Use at your own risk.")]
public int RespawnSeconds = 5;
/// <summary>The number of seconds a player must wait before being respawned if there is a boss nearby.</summary>
[Description("The number of seconds a player must wait before being respawned if there is a boss nearby.")]
/// <summary>The number of seconds a player must wait before being respawned if there is a boss nearby. Cannot be longer than normal value now. Use at your own risk.</summary>
[Description("The number of seconds a player must wait before being respawned if there is a boss nearby. Cannot be longer than normal value now. Use at your own risk.")]
public int RespawnBossSeconds = 10;
/// <summary>Disables a player if this number of tiles is painted within 1 second.</summary>

View file

@ -2065,6 +2065,11 @@ namespace TShockAPI
private static bool HandleSpawn(GetDataHandlerArgs args)
{
if (args.Player.Dead && args.Player.RespawnTimer > 0)
{
return true;
}
byte player = args.Data.ReadInt8();
short spawnx = args.Data.ReadInt16();
short spawny = args.Data.ReadInt16();

View file

@ -299,9 +299,10 @@ namespace TShockAPI
/// </summary>
public int RespawnTimer
{
get => TPlayer.respawnTimer;
set => TPlayer.respawnTimer = value;
get => _respawnTimer;
set => TPlayer.respawnTimer = (_respawnTimer = value) * 60;
}
private int _respawnTimer;
/// <summary>
/// Whether the player is dead or not.
@ -1196,7 +1197,7 @@ namespace TShockAPI
PlayerIndex = (byte)Index,
TileX = (short)tilex,
TileY = (short)tiley,
RespawnTimer = respawnTimer ?? TShock.Players[Index].TPlayer.respawnTimer,
RespawnTimer = respawnTimer ?? TShock.Players[Index].RespawnTimer * 60,
PlayerSpawnContext = context,
};
msg.PackFull(ms);