General stuff.

This commit is contained in:
Shank 2011-05-30 01:49:44 -06:00
parent dfa89f28f1
commit 45c7e6e830
2 changed files with 52 additions and 1 deletions

View file

@ -7,6 +7,7 @@ using Terraria;
using TerrariaAPI;
using TerrariaAPI.Hooks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace TShockAPI
{
@ -60,8 +61,10 @@ namespace TShockAPI
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
}
/*
* Hooks:
* */
@ -94,6 +97,16 @@ namespace TShockAPI
}
}
void OnJoin(int ply, AllowEventArgs handler)
{
string ip = GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)));
if (CheckBanned(ip) || CheckCheat(ip) || CheckGreif(ip))
{
Kick(ply, "Your account has been disabled.");
}
}
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
{
@ -106,7 +119,7 @@ namespace TShockAPI
void OnPostInit()
{
}
void OnUpdate(GameTime time)
@ -118,6 +131,43 @@ namespace TShockAPI
* Useful stuff:
* */
public static bool CheckGreif(String ip)
{
ip = GetRealIP(ip);
if (!banTnt) { return false; }
TextReader tr = new StreamReader(saveDir + "grief.txt");
string list = tr.ReadToEnd();
tr.Close();
return list.Contains(ip);
}
public static bool CheckCheat(String ip)
{
ip = GetRealIP(ip);
if (!banCheater) { return false; }
TextReader tr = new StreamReader(saveDir + "cheaters.txt");
string trr = tr.ReadToEnd();
tr.Close();
if (trr.Contains(ip))
{
return true;
}
return false;
}
public static bool CheckBanned(String p)
{
String ip = p.Split(':')[0];
TextReader tr = new StreamReader(saveDir + "bans.txt");
string banlist = tr.ReadToEnd();
tr.Close();
banlist = banlist.Trim();
if (banlist.Contains(ip))
return true;
return false;
}
private static void KeepTilesUpToDate()
{
TextReader tr = new StreamReader(saveDir + "tiles.txt");

View file

@ -33,6 +33,7 @@
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />