Remove Utils.ForceKick; use TSPlayer.Kick.

Some anti-cheat calls were changed to "You have been Bounced." I don't
think we need to tell clients why they were disconnected so they can
tune their hacks better.
This commit is contained in:
Lucas Nicodemus 2017-12-27 18:01:53 -07:00
parent 9e91db9ea4
commit 1ea04ffd4f
6 changed files with 28 additions and 38 deletions

View file

@ -77,7 +77,7 @@ namespace TShockAPI
if (String.IsNullOrEmpty(args.Player.Name))
{
TShock.Utils.ForceKick(args.Player, "Blank name.", true);
args.Player.Kick("Your client sent a blank character name.", true, true);
args.Handled = true;
return;
}
@ -941,7 +941,7 @@ namespace TShockAPI
if (damage > 20000) //Abnormal values have the potential to cause infinite loops in the server.
{
TShock.Utils.ForceKick(args.Player, "Crash Exploit Attempt", true);
args.Player.Kick("Failed to shade polygon normals.", true, true);
TShock.Log.ConsoleError("Death Exploit Attempt: Damage {0}", damage);
args.Handled = true;
return;

View file

@ -349,7 +349,7 @@ namespace TShockAPI
}
/// <summary>
/// PlayerInfo - called at a PlayerInfo event
/// If this is cancelled, the server will ForceKick the player. If this should be changed in the future, let someone know.
/// If this is cancelled, the server will kick the player. If this should be changed in the future, let someone know.
/// </summary>
public static HandlerList<PlayerInfoEventArgs> PlayerInfo = new HandlerList<PlayerInfoEventArgs>();
@ -1715,13 +1715,13 @@ namespace TShockAPI
if (OnPlayerInfo(args.Player, args.Data, playerid, hair, skinVariant, difficulty, name))
{
TShock.Utils.ForceKick(args.Player, "A plugin cancelled the event.", true);
args.Player.Kick("A plugin on this server stopped your login.", true, true);
return true;
}
if (name.Trim().Length == 0)
{
TShock.Utils.ForceKick(args.Player, "Empty Name.", true);
args.Player.Kick("You have been Bounced.", true, true);
return true;
}
if (args.Player.ReceivedInfo)
@ -1749,12 +1749,12 @@ namespace TShockAPI
}
if (TShock.Config.MediumcoreOnly && difficulty < 1)
{
TShock.Utils.ForceKick(args.Player, "Server is set to mediumcore and above characters only!", true);
args.Player.Kick("You need to join with a mediumcore player or higher.", true, true);
return true;
}
if (TShock.Config.HardcoreOnly && difficulty < 2)
{
TShock.Utils.ForceKick(args.Player, "Server is set to hardcore characters only!", true);
args.Player.Kick("You need to join with a hardcore player.", true, true);
return true;
}
args.Player.Difficulty = difficulty;
@ -1884,9 +1884,10 @@ namespace TShockAPI
Hooks.PlayerHooks.OnPlayerPostLogin(args.Player);
return true;
}
TShock.Utils.ForceKick(args.Player, "Invalid user account password.", true);
args.Player.Kick("Your password did not match this character's password.", true, true);
return true;
}
if (!string.IsNullOrEmpty(TShock.Config.ServerPassword))
{
if (TShock.Config.ServerPassword == password)
@ -1897,11 +1898,11 @@ namespace TShockAPI
NetMessage.SendData((int)PacketTypes.WorldInfo, args.Player.Index);
return true;
}
TShock.Utils.ForceKick(args.Player, "Incorrect server password", true);
args.Player.Kick("Invalid server password.", true, true);
return true;
}
TShock.Utils.ForceKick(args.Player, "Bad password attempt", true);
args.Player.Kick("You have been Bounced.", true, true);
return true;
}
@ -1949,7 +1950,7 @@ namespace TShockAPI
if (TShock.Players.Length + 1 > TShock.Config.MaxSlots &&
!args.Player.HasPermission(Permissions.reservedslot))
{
TShock.Utils.ForceKick(args.Player, TShock.Config.ServerFullReason, true);
args.Player.Kick(TShock.Config.ServerFullReason, true, true);
return true;
}
@ -2439,11 +2440,11 @@ namespace TShockAPI
if (TShock.Config.BanOnHardcoreDeath)
{
if (!TShock.Utils.Ban(args.Player, TShock.Config.HardcoreBanReason, false, "hardcore-death"))
TShock.Utils.ForceKick(args.Player, "Death results in a ban, but you are immune to bans.", true);
args.Player.Kick("You died! Normally, you'd be banned.", true, true);
}
else
{
TShock.Utils.ForceKick(args.Player, TShock.Config.HardcoreKickReason, true, false);
args.Player.Kick(TShock.Config.HardcoreKickReason, true, true, null, false);
}
}
@ -2503,11 +2504,11 @@ namespace TShockAPI
if (TShock.Config.BanOnMediumcoreDeath)
{
if (!TShock.Utils.Ban(args.Player, TShock.Config.MediumcoreBanReason, false, "mediumcore-death"))
TShock.Utils.ForceKick(args.Player, "Death results in a ban, but you are immune to bans.", true);
args.Player.Kick("You died! Normally, you'd be banned.", true, true);
}
else
{
TShock.Utils.ForceKick(args.Player, TShock.Config.MediumcoreKickReason, true, false);
args.Player.Kick(TShock.Config.MediumcoreKickReason, true, true, null, false);
}
return true;
}

View file

@ -982,7 +982,7 @@ namespace TShockAPI
return ret;
TSPlayer player = (TSPlayer)ret;
TShock.Utils.ForceKick(player, null == args.Parameters["reason"] ? "Kicked via web" : args.Parameters["reason"], false, true);
player.Kick(null == args.Parameters["reason"] ? "Kicked via web" : args.Parameters["reason"], false, true, null, true);
return RestResponse("Player " + player.Name + " was kicked");
}
@ -1002,7 +1002,7 @@ namespace TShockAPI
TSPlayer player = (TSPlayer)ret;
var reason = null == args.Parameters["reason"] ? "Banned via web" : args.Parameters["reason"];
TShock.Bans.AddBan2(player.IP, player.Name, "", "", reason);
TShock.Utils.ForceKick(player, reason, false, true);
player.Kick(reason, true, false, null, true);
return RestResponse("Player " + player.Name + " was banned");
}

View file

@ -481,13 +481,13 @@ namespace TShockAPI
// And then get rid of them.
if (potentialBan.Expiration == "")
{
Utils.ForceKick(args.Player, String.Format("Permanently banned by {0} for {1}", potentialBan.BanningUser
,potentialBan.Reason), false, false);
args.Player.Kick(String.Format("Permanently banned by {0} for {1}", potentialBan.BanningUser
,potentialBan.Reason), true, true);
}
else
{
Utils.ForceKick(args.Player, String.Format("Still banned by {0} for {1}", potentialBan.BanningUser,
potentialBan.Reason), false, false);
args.Player.Kick(String.Format("Still banned by {0} for {1}", potentialBan.BanningUser,
potentialBan.Reason), true, true);
}
}
}
@ -1245,14 +1245,14 @@ namespace TShockAPI
if (TShock.Players.Length + 1 > Config.MaxSlots + Config.ReservedSlots)
{
Utils.ForceKick(player, Config.ServerFullNoReservedReason, true, false);
player.Kick(Config.ServerFullNoReservedReason, true, true, null, false);
args.Handled = true;
return;
}
if (!FileTools.OnWhitelist(player.IP))
{
Utils.ForceKick(player, Config.WhitelistKickReason, true, false);
player.Kick(Config.WhitelistKickReason, true, true, null, false);
args.Handled = true;
return;
}
@ -1265,7 +1265,7 @@ namespace TShockAPI
{
if (Config.KickProxyUsers)
{
Utils.ForceKick(player, "Proxies are not allowed.", true, false);
player.Kick("Connecting via a proxy is not allowed.", true, true, null, false);
args.Handled = true;
return;
}
@ -1287,7 +1287,7 @@ namespace TShockAPI
if (Config.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID))
{
Utils.ForceKick(player, "Your client did not send a UUID, this server is not configured to accept such a client.", true);
player.Kick("Your client sent a blank UUID. Configure it to send one or use a different client.", true, true, null, false);
args.Handled = true;
return;
}

View file

@ -506,7 +506,7 @@ namespace TShockAPI
{
if (player != null && player.Active)
{
ForceKick(player, reason, false, true);
player.Kick(reason, true, true, null, true);
}
}
}
@ -549,18 +549,6 @@ namespace TShockAPI
Hooks.GeneralHooks.OnReloadEvent(player);
}
/// <summary>
/// Kicks a player from the server without checking for immunetokick permission.
/// </summary>
/// <param name="player">TSPlayer player</param>
/// <param name="reason">string reason</param>
/// <param name="silent">bool silent (default: false)</param>
/// <param name="saveSSI">bool saveSSI (default: false)</param>
public void ForceKick(TSPlayer player, string reason, bool silent = false, bool saveSSI = false)
{
player.Kick(reason, true, silent, null, saveSSI);
}
/// <summary>
/// Bans and kicks a player from the server.
/// </summary>