Replaced the 3 ban files with a simple ban manager which stores ip, name and reason.

This commit is contained in:
high 2011-06-05 19:05:38 -04:00
parent 6c9d9873f0
commit 1caf69998d
5 changed files with 262 additions and 265 deletions

View file

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using System.Collections.Generic;
namespace TShockAPI
{
@ -19,6 +19,16 @@ namespace TShockAPI
return mess.Split(':')[0];
}
/// <summary>
/// Gets the IP from a player index
/// </summary>
/// <param name="plr">Player Index</param>
/// <returns>IP</returns>
public static string GetPlayerIP(int plr)
{
return GetRealIP(Netplay.serverSock[plr].tcpClient.Client.RemoteEndPoint.ToString());
}
/// <summary>
/// Used for some places where a list of players might be used.
/// </summary>
@ -201,46 +211,6 @@ namespace TShockAPI
Log.Info("Kicked " + Tools.FindPlayer(ply) + " for : " + reason);
}
/// <summary>
/// Adds someone to cheaters.txt
/// </summary>
/// <param name="ply">int player</param>
public static void HandleCheater(int ply)
{
if (!TShock.players[ply].group.HasPermission("ignorecheatdetection"))
{
string cheater = Tools.FindPlayer(ply);
string ip = Tools.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
FileTools.WriteCheater(ply);
if (!ConfigurationManager.kickCheater) { return; }
Netplay.serverSock[ply].kill = true;
Netplay.serverSock[ply].Reset();
NetMessage.syncPlayers();
Tools.Broadcast(cheater + " was " + (ConfigurationManager.banCheater ? "banned " : "kicked ") + "for cheating.");
}
}
/// <summary>
/// Adds someone to griefers.txt
/// </summary>
/// <param name="ply">int player</param>
public static void HandleGriefer(int ply)
{
if (!TShock.players[ply].group.HasPermission("ignoregriefdetection"))
{
string cheater = Tools.FindPlayer(ply);
string ip = Tools.GetRealIP(Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint));
FileTools.WriteGrief(ply);
if (!ConfigurationManager.kickGriefer) { return; }
Netplay.serverSock[ply].kill = true;
Netplay.serverSock[ply].Reset();
NetMessage.syncPlayers();
Tools.Broadcast(cheater + " was " + (ConfigurationManager.banGriefer ? "banned " : "kicked ") + "for griefing.");
}
}
/// <summary>
/// Shows a MOTD to the player
/// </summary>