Merge pull request #1620 from DankRank/mediumcorekick

Make Kick/BanOnMediumcoreDeath behave like their Hardcore equvivalents
This commit is contained in:
Chris 2018-04-27 16:07:59 +00:00 committed by GitHub
commit a1f7179b46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 31 deletions

View file

@ -81,6 +81,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* `Utils.GetIPv4Address()` is now `Utils.GetIPv4AddressFromHostname()`. (@hakusaro)
* Fixed the disappearing problem when placing tile entities. (@mistzzt)
* Removed the stat tracking system. (@hakusaro)
* Fixed erroneous kicks and bans when using `KickOnMediumcoreDeath` and `BanOnMediumcoreDeath` options. (@DankRank)
* Removed `TSPlayer.InitSpawn` field. (@DankRank)
## TShock 4.3.25
* Fixed a critical exploit in the Terraria protocol that could cause massive unpreventable world corruption as well as a number of other problems. Thanks to @bartico6 for reporting. Fixed by the efforts of @QuiCM, @hakusaro, and tips in the right directioon from @bartico6.

View file

@ -2380,16 +2380,21 @@ namespace TShockAPI
}
}
if (args.TPlayer.difficulty == 2 && (TShock.Config.KickOnHardcoreDeath || TShock.Config.BanOnHardcoreDeath))
// Handle kicks/bans on mediumcore/hardcore deaths.
if (args.TPlayer.difficulty != 0) // Player is not softcore
{
if (TShock.Config.BanOnHardcoreDeath)
{
if (!args.Player.Ban(TShock.Config.HardcoreBanReason, false, "hardcore-death"))
bool mediumcore = args.TPlayer.difficulty == 1;
bool shouldBan = mediumcore ? TShock.Config.BanOnMediumcoreDeath : TShock.Config.BanOnHardcoreDeath;
bool shouldKick = mediumcore ? TShock.Config.KickOnMediumcoreDeath : TShock.Config.KickOnHardcoreDeath;
string banReason = mediumcore ? TShock.Config.MediumcoreBanReason : TShock.Config.HardcoreBanReason;
string kickReason = mediumcore ? TShock.Config.MediumcoreKickReason : TShock.Config.HardcoreKickReason;
if(shouldBan) {
if (!args.Player.Ban(banReason, false, "TShock"))
args.Player.Kick("You died! Normally, you'd be banned.", true, true);
}
else
{
args.Player.Kick(TShock.Config.HardcoreKickReason, true, true, null, false);
else if(shouldKick) {
args.Player.Kick(kickReason, true, true, null, false);
}
}
@ -2440,28 +2445,6 @@ namespace TShockAPI
if (OnPlayerSpawn(args.Player, args.Data, player, spawnx, spawny))
return true;
if (args.Player.InitSpawn && args.TPlayer.inventory[args.TPlayer.selectedItem].type != 50)
{
if (args.TPlayer.difficulty == 1 && (TShock.Config.KickOnMediumcoreDeath || TShock.Config.BanOnMediumcoreDeath))
{
if (args.TPlayer.selectedItem != 50)
{
if (TShock.Config.BanOnMediumcoreDeath)
{
if (!args.Player.Ban(TShock.Config.MediumcoreBanReason, false, "mediumcore-death"))
args.Player.Kick("You died! Normally, you'd be banned.", true, true);
}
else
{
args.Player.Kick(TShock.Config.MediumcoreKickReason, true, true, null, false);
}
return true;
}
}
}
else
args.Player.InitSpawn = true;
if ((Main.ServerSideCharacter) && (args.Player.sX > 0) && (args.Player.sY > 0) && (args.TPlayer.SpawnX > 0) && ((args.TPlayer.SpawnX != args.Player.sX) && (args.TPlayer.SpawnY != args.Player.sY)))
{

View file

@ -228,8 +228,6 @@ namespace TShockAPI
/// </summary>
public DateTime LastThreat { get; set; }
public bool InitSpawn;
/// <summary>
/// Whether the player should see logs.
/// </summary>