All greif related checks now respect ignoregreifdetection and ban/kick greif flags.
Refactored common ban/kick logic into helper method in tools. Added ForceKick for when wanting to disallow players to join when sever is full or name is too long or not on whitelist etc. Updated OnJoin to set e.Handled when players are force kicked during join. Logging all players that successfully join the server.
This commit is contained in:
parent
bdce73f0dc
commit
1ad261a562
3 changed files with 127 additions and 133 deletions
|
|
@ -184,13 +184,10 @@ namespace TShockAPI
|
||||||
int player = Tools.FindPlayer(plStr);
|
int player = Tools.FindPlayer(plStr);
|
||||||
if (!(player == -1 || player == -2 || plStr == ""))
|
if (!(player == -1 || player == -2 || plStr == ""))
|
||||||
{
|
{
|
||||||
if (!TShock.players[Tools.FindPlayer(plStr)].group.HasPermission("immunetokick"))
|
if (!Tools.Kick(player, "Misbehaviour."))
|
||||||
{
|
{
|
||||||
Tools.Kick(player, "You were kicked.");
|
|
||||||
Tools.Broadcast(Tools.FindPlayer(player) + " was kicked by " + Tools.FindPlayer(ply));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Tools.SendMessage(ply, "You can't kick another admin!", new[] {255f, 0f, 0f});
|
Tools.SendMessage(ply, "You can't kick another admin!", new[] {255f, 0f, 0f});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Tools.FindPlayer(plStr) == -2)
|
else if (Tools.FindPlayer(plStr) == -2)
|
||||||
Tools.SendMessage(ply, "More than one player matched!", new[] {255f, 0f, 0f});
|
Tools.SendMessage(ply, "More than one player matched!", new[] {255f, 0f, 0f});
|
||||||
|
|
@ -216,14 +213,10 @@ namespace TShockAPI
|
||||||
int player = Tools.FindPlayer(plStr);
|
int player = Tools.FindPlayer(plStr);
|
||||||
if (!(player == -1 || player == -2 || plStr == ""))
|
if (!(player == -1 || player == -2 || plStr == ""))
|
||||||
{
|
{
|
||||||
if (!TShock.players[Tools.FindPlayer(plStr)].group.HasPermission("immunetoban"))
|
if (!Tools.Ban(player, banReason.Equals("") ? "Misbehaviour." : banReason, Tools.FindPlayer(adminplr)))
|
||||||
{
|
{
|
||||||
TShock.Bans.AddBan(Tools.GetPlayerIP(player), Main.player[player].name);
|
|
||||||
Tools.Kick(player, "You were banned.");
|
|
||||||
Tools.Broadcast(Tools.FindPlayer(adminplr) + " banned " + Tools.FindPlayer(player) + "!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Tools.SendMessage(adminplr, "You can't ban another admin!", new[] {255f, 0f, 0f});
|
Tools.SendMessage(adminplr, "You can't ban another admin!", new[] {255f, 0f, 0f});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Tools.FindPlayer(plStr) == -2)
|
else if (Tools.FindPlayer(plStr) == -2)
|
||||||
Tools.SendMessage(adminplr, "More than one player matched!", new[] {255f, 0f, 0f});
|
Tools.SendMessage(adminplr, "More than one player matched!", new[] {255f, 0f, 0f});
|
||||||
|
|
@ -237,7 +230,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (Main.player[player].active)
|
if (Main.player[player].active)
|
||||||
{
|
{
|
||||||
Tools.Kick(player, "Server shutting down!");
|
Tools.ForceKick(player, "Server shutting down!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WorldGen.saveWorld();
|
WorldGen.saveWorld();
|
||||||
|
|
|
||||||
|
|
@ -203,13 +203,12 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (players[e.Msg.whoAmI] == null)
|
if (players[e.Msg.whoAmI] == null)
|
||||||
{
|
{
|
||||||
Tools.Kick(e.Msg.whoAmI, "Player doesn't exist");
|
Tools.ForceKick(e.Msg.whoAmI, "Player doesn't exist");
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
else if (players[e.Msg.whoAmI].receivedInfo)
|
else if (players[e.Msg.whoAmI].receivedInfo)
|
||||||
{
|
{
|
||||||
Tools.Kick(e.Msg.whoAmI, "Sent client info more than once");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Sent client info more than once");
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -229,8 +228,7 @@ namespace TShockAPI
|
||||||
int tileY = Math.Abs(y);
|
int tileY = Math.Abs(y);
|
||||||
if (size > 5 || Math.Abs(plyX - tileX) > 10 || Math.Abs(plyY - tileY) > 10)
|
if (size > 5 || Math.Abs(plyX - tileX) > 10 || Math.Abs(plyY - tileY) > 10)
|
||||||
{
|
{
|
||||||
Ban(e.Msg.whoAmI, "Send Tile Square Abuse");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Send Tile Square Abuse");
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -251,10 +249,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
||||||
Tools.Broadcast(Main.player[e.Msg.whoAmI].name +
|
|
||||||
" was banned for placing impossible to place blocks.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == 0 || type == 1)
|
if (type == 0 || type == 1)
|
||||||
|
|
@ -298,25 +293,18 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x0A) //SendSection
|
else if (e.MsgID == 0x0A) //SendSection
|
||||||
{
|
{
|
||||||
Tools.Broadcast(string.Format("{0}({1}) attempted sending a section", Main.player[e.Msg.whoAmI].name,
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "SendSection abuse.");
|
||||||
e.Msg.whoAmI));
|
|
||||||
Tools.Kick(e.Msg.whoAmI, "SendSection abuse.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x17) //Npc Data
|
else if (e.MsgID == 0x17) //Npc Data
|
||||||
{
|
{
|
||||||
Tools.Broadcast(string.Format("{0}({1}) attempted spawning an NPC", Main.player[e.Msg.whoAmI].name,
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Spawn NPC abuse");
|
||||||
e.Msg.whoAmI));
|
|
||||||
Tools.Kick(e.Msg.whoAmI, "Spawn NPC abuse");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x0D) //Update Player
|
else if (e.MsgID == 0x0D) //Update Player
|
||||||
{
|
{
|
||||||
byte plr = e.Msg.readBuffer[e.Index];
|
byte plr = e.Msg.readBuffer[e.Index];
|
||||||
if (plr != e.Msg.whoAmI)
|
if (plr != e.Msg.whoAmI)
|
||||||
{
|
{
|
||||||
Tools.Kick(e.Msg.whoAmI, "Update Player abuse");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Update Player abuse");
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x10)
|
else if (e.MsgID == 0x10)
|
||||||
|
|
@ -331,19 +319,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (players[ply].syncHP)
|
if (players[ply].syncHP)
|
||||||
{
|
{
|
||||||
if (!players[ply].group.HasPermission("ignorecheatdetection"))
|
e.Handled = Tools.HandleCheater(ply, "Abnormal life increase");
|
||||||
{
|
|
||||||
if (ConfigurationManager.banCheater || ConfigurationManager.kickCheater)
|
|
||||||
{
|
|
||||||
string playerName = Tools.FindPlayer(ply);
|
|
||||||
if (ConfigurationManager.banCheater)
|
|
||||||
Ban(ply, "Abnormal life increase");
|
|
||||||
Tools.Kick(ply, "Abnormal life increase");
|
|
||||||
Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") +
|
|
||||||
" because they gained an abnormal amount of health.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -364,19 +340,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (players[ply].syncMP)
|
if (players[ply].syncMP)
|
||||||
{
|
{
|
||||||
if (!players[ply].group.HasPermission("ignorecheatdetection"))
|
e.Handled = Tools.HandleCheater(ply, "Abnormal mana increase");
|
||||||
{
|
|
||||||
if (ConfigurationManager.banCheater || ConfigurationManager.kickCheater)
|
|
||||||
{
|
|
||||||
string playerName = Tools.FindPlayer(ply);
|
|
||||||
if (ConfigurationManager.banCheater)
|
|
||||||
Ban(ply, "Abnormal mana increase");
|
|
||||||
Tools.Kick(ply, "Abnormal mana increase");
|
|
||||||
Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") +
|
|
||||||
" because they gained an abnormal amount of mana.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -401,20 +365,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (type == 29 || type == 28 || type == 30)
|
if (type == 29 || type == 28 || type == 30)
|
||||||
{
|
{
|
||||||
if (!players[e.Msg.whoAmI].group.HasPermission("ignoregriefdetection"))
|
e.Handled = Tools.HandleExplosivesUser(e.Msg.whoAmI, "Throwing an explosive device.");
|
||||||
{
|
|
||||||
if (ConfigurationManager.kickBoom || ConfigurationManager.banBoom)
|
|
||||||
{
|
|
||||||
int i = e.Msg.whoAmI;
|
|
||||||
if (ConfigurationManager.banBoom)
|
|
||||||
Ban(i, "Explosives");
|
|
||||||
Tools.Kick(i, "Explosives were thrown.");
|
|
||||||
Tools.Broadcast(Main.player[i].name + " was " +
|
|
||||||
(ConfigurationManager.banBoom ? "banned" : "kicked") +
|
|
||||||
" for throwing an explosive device.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -429,10 +380,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (id != e.Msg.whoAmI)
|
if (id != e.Msg.whoAmI)
|
||||||
{
|
{
|
||||||
Ban(e.Msg.whoAmI, "Griefer");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Trying to execute KillMe on someone else.");
|
||||||
Log.Info(Tools.FindPlayer(e.Msg.whoAmI) +
|
|
||||||
" was kicked for trying to execute KillMe on someone else.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -476,20 +424,15 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (lava && lavacount <= 0)
|
if (lava && lavacount <= 0)
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have.");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Placing lava they didn't have."); ;
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
else if (!lava && watercount <= 0)
|
else if (!lava && watercount <= 0)
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have.");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Placing water they didn't have.");
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
|
||||||
{
|
{
|
||||||
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid.");
|
e.Handled = Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place liquid."); ;
|
||||||
Tools.Broadcast(Main.player[e.Msg.whoAmI].name +
|
|
||||||
" was banned for placing impossible to place liquid.");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigurationManager.spawnProtect)
|
if (ConfigurationManager.spawnProtect)
|
||||||
|
|
@ -519,17 +462,11 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int plr = who; //legacy support
|
int plr = who; //legacy support
|
||||||
|
Log.Info(Tools.FindPlayer(who) + " (" + Tools.GetPlayerIP(who) + ") from '" + players[who].group.GetName() + "' group joined.");
|
||||||
Tools.ShowMOTD(who);
|
Tools.ShowMOTD(who);
|
||||||
if (!players[who].group.HasPermission("ignorecheatdetection") && HackedHealth(who))
|
if (HackedHealth(who))
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.banCheater || ConfigurationManager.kickCheater)
|
Tools.HandleCheater(who, "Hacked health.");
|
||||||
{
|
|
||||||
string playerName = Tools.FindPlayer(who);
|
|
||||||
if (ConfigurationManager.banCheater)
|
|
||||||
Ban(who, "Hacked health.");
|
|
||||||
Tools.Kick(who, "Hacked health.");
|
|
||||||
Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") + " for hacked health.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ConfigurationManager.permaPvp)
|
if (ConfigurationManager.permaPvp)
|
||||||
{
|
{
|
||||||
|
|
@ -551,9 +488,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
if (msg.whoAmI != ply)
|
if (msg.whoAmI != ply)
|
||||||
{
|
{
|
||||||
Log.Info(Tools.FindPlayer(msg.whoAmI) + " was kicked for trying to fake chat as someone else.");
|
e.Handled = Tools.HandleGriefer(ply, "Faking Chat"); ;
|
||||||
Ban(ply, "Faking Chat");
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = (int)Main.player[ply].position.X;
|
int x = (int)Main.player[ply].position.X;
|
||||||
|
|
@ -596,30 +531,34 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
string ip = Tools.GetPlayerIP(ply);
|
string ip = Tools.GetPlayerIP(ply);
|
||||||
;
|
|
||||||
players[ply] = new TSPlayer(ply);
|
players[ply] = new TSPlayer(ply);
|
||||||
players[ply].group = Tools.GetGroupForIP(ip);
|
players[ply].group = Tools.GetGroupForIP(ip);
|
||||||
|
|
||||||
if (Tools.activePlayers() + 1 > ConfigurationManager.maxSlots &&
|
if (Tools.activePlayers() + 1 > ConfigurationManager.maxSlots &&
|
||||||
!players[ply].group.HasPermission("reservedslot"))
|
!players[ply].group.HasPermission("reservedslot"))
|
||||||
{
|
{
|
||||||
Tools.Kick(ply, "Server is full");
|
Tools.ForceKick(ply, "Server is full");
|
||||||
return;
|
handler.Handled = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
var ban = Bans.GetBanByIp(ip);
|
|
||||||
if (ban != null)
|
|
||||||
{
|
{
|
||||||
Tools.Kick(ply, "You are banned: " + ban.Reason);
|
var ban = Bans.GetBanByIp(ip);
|
||||||
}
|
if (ban != null)
|
||||||
else if (Tools.FindPlayer(ply).Length > 32)
|
{
|
||||||
{
|
Tools.ForceKick(ply, "You are banned: " + ban.Reason);
|
||||||
Tools.Kick(ply, "Your name was too long.");
|
handler.Handled = true;
|
||||||
Tools.Broadcast(ip + " was kicked because their name exceeded 32 characters.");
|
}
|
||||||
}
|
else if (Tools.FindPlayer(ply).Length > 32)
|
||||||
if (!FileTools.OnWhitelist(ip))
|
{
|
||||||
{
|
Tools.ForceKick(ply, "Your name was too long.");
|
||||||
Tools.Kick(ply, "Not on whitelist.");
|
handler.Handled = true;
|
||||||
|
}
|
||||||
|
else if (!FileTools.OnWhitelist(ip))
|
||||||
|
{
|
||||||
|
Tools.ForceKick(ply, "Not on whitelist.");
|
||||||
|
handler.Handled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -643,7 +582,7 @@ namespace TShockAPI
|
||||||
FileTools.CreateFile(FileTools.SaveDir + "auth.lck");
|
FileTools.CreateFile(FileTools.SaveDir + "auth.lck");
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationManager.maxSlots = Main.maxPlayers - 1;
|
//ConfigurationManager.maxSlots = Main.maxPlayers - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdate(GameTime time)
|
private void OnUpdate(GameTime time)
|
||||||
|
|
@ -662,14 +601,8 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (Main.player[i] != null)
|
if (Main.player[i] != null)
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt)
|
if (Tools.HandleTntUser((int)i, "Kill tile abuse detected."))
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.banTnt)
|
|
||||||
Ban((int)i, "Explosives");
|
|
||||||
Tools.Kick((int)i, "Kill tile abuse detected.");
|
|
||||||
Tools.Broadcast(Main.player[i].name + " was " +
|
|
||||||
(ConfigurationManager.banTnt ? "banned" : "kicked") +
|
|
||||||
" for kill tile abuse.");
|
|
||||||
RevertKillTile((int)i);
|
RevertKillTile((int)i);
|
||||||
}
|
}
|
||||||
else if (players[i].tileThreshold > 0)
|
else if (players[i].tileThreshold > 0)
|
||||||
|
|
@ -873,15 +806,6 @@ namespace TShockAPI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Ban(int plr, string reason = "")
|
|
||||||
{
|
|
||||||
if (!players[plr].group.HasPermission("immunetoban"))
|
|
||||||
{
|
|
||||||
Tools.Kick(plr, "Banned: " + reason);
|
|
||||||
Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Position
|
public class Position
|
||||||
{
|
{
|
||||||
public float X;
|
public float X;
|
||||||
|
|
|
||||||
|
|
@ -208,19 +208,96 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Kicks a player from the server without checking for immunetokick permission.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ply">int player</param>
|
||||||
|
/// <param name="reason">string reason</param>
|
||||||
|
public static void ForceKick(int ply, string reason)
|
||||||
|
{
|
||||||
|
string ip = GetPlayerIP(ply);
|
||||||
|
NetMessage.SendData(0x2, ply, -1, reason, 0x0, 0f, 0f, 0f);
|
||||||
|
Log.Info(ip + " was force kicked for : " + reason);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kicks a player from the server.
|
/// Kicks a player from the server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ply">int player</param>
|
/// <param name="ply">int player</param>
|
||||||
/// <param name="reason">string reason</param>
|
/// <param name="reason">string reason</param>
|
||||||
public static void Kick(int ply, string reason)
|
public static bool Kick(int ply, string reason, string adminUserName = "")
|
||||||
{
|
{
|
||||||
if (!TShock.players[ply].group.HasPermission("immunetokick") || reason.Contains("Banned: "))
|
if (!TShock.players[ply].group.HasPermission("immunetokick"))
|
||||||
{
|
{
|
||||||
string displayName = FindPlayer(ply).Equals("") ? GetPlayerIP(ply) : FindPlayer(ply);
|
string playerName = Main.player[ply].name;
|
||||||
NetMessage.SendData(0x2, ply, -1, reason, 0x0, 0f, 0f, 0f);
|
NetMessage.SendData(0x2, ply, -1, "Kicked: " + reason, 0x0, 0f, 0f, 0f);
|
||||||
Log.Info("Kicked " + displayName + " for : " + reason);
|
Log.Info("Kicked " + playerName + " for : " + reason);
|
||||||
|
if (adminUserName.Equals(""))
|
||||||
|
Broadcast(playerName + " was kicked for " + reason.ToLower());
|
||||||
|
else
|
||||||
|
Tools.Broadcast(adminUserName + " kicked " + playerName + " for " + reason.ToLower());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bans and kicks a player from the server.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ply">int player</param>
|
||||||
|
/// <param name="reason">string reason</param>
|
||||||
|
public static bool Ban(int plr, string reason, string adminUserName = "")
|
||||||
|
{
|
||||||
|
if (!TShock.players[plr].group.HasPermission("immunetoban"))
|
||||||
|
{
|
||||||
|
string ip = GetPlayerIP(plr);
|
||||||
|
string playerName = Main.player[plr].name;
|
||||||
|
TShock.Bans.AddBan(ip, playerName, reason);
|
||||||
|
NetMessage.SendData(0x2, plr, -1, "Banned: " + reason, 0x0, 0f, 0f, 0f);
|
||||||
|
Log.Info("Banned " + playerName + " for : " + reason);
|
||||||
|
if (adminUserName.Equals(""))
|
||||||
|
Broadcast(playerName + " was banned for " + reason.ToLower());
|
||||||
|
else
|
||||||
|
Tools.Broadcast(adminUserName + " banned " + playerName + " for " + reason.ToLower());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HandleCheater(int ply, string reason)
|
||||||
|
{
|
||||||
|
return HandleBadPlayer(ply, "ignorecheatdetection", ConfigurationManager.banCheater, ConfigurationManager.kickCheater, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HandleGriefer(int ply, string reason)
|
||||||
|
{
|
||||||
|
return HandleBadPlayer(ply, "ignoregriefdetection", ConfigurationManager.banGriefer, ConfigurationManager.kickGriefer, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HandleTntUser(int ply, string reason)
|
||||||
|
{
|
||||||
|
return HandleBadPlayer(ply, "ignoregriefdetection", ConfigurationManager.banTnt, ConfigurationManager.kickTnt, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HandleExplosivesUser(int ply, string reason)
|
||||||
|
{
|
||||||
|
return HandleBadPlayer(ply, "ignoregriefdetection", ConfigurationManager.banBoom, ConfigurationManager.kickBoom, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool HandleBadPlayer(int ply, string overridePermission, bool ban, bool kick, string reason)
|
||||||
|
{
|
||||||
|
if (!TShock.players[ply].group.HasPermission(overridePermission))
|
||||||
|
{
|
||||||
|
if (ban)
|
||||||
|
{
|
||||||
|
return Ban(ply, reason);
|
||||||
|
}
|
||||||
|
else if (kick)
|
||||||
|
{
|
||||||
|
return Kick(ply, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue