General stuff.
This commit is contained in:
parent
dfa89f28f1
commit
45c7e6e830
2 changed files with 52 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ using Terraria;
|
||||||
using TerrariaAPI;
|
using TerrariaAPI;
|
||||||
using TerrariaAPI.Hooks;
|
using TerrariaAPI.Hooks;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -60,8 +61,10 @@ namespace TShockAPI
|
||||||
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
GameHooks.OnUpdate += new Action<Microsoft.Xna.Framework.GameTime>(OnUpdate);
|
||||||
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
GameHooks.OnLoadContent += new Action<Microsoft.Xna.Framework.Content.ContentManager>(OnLoadContent);
|
||||||
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
ServerHooks.OnChat += new Action<int, string, HandledEventArgs>(OnChat);
|
||||||
|
ServerHooks.OnJoin += new Action<int, AllowEventArgs>(OnJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hooks:
|
* 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)
|
void OnLoadContent(Microsoft.Xna.Framework.Content.ContentManager obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -106,7 +119,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
void OnPostInit()
|
void OnPostInit()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnUpdate(GameTime time)
|
void OnUpdate(GameTime time)
|
||||||
|
|
@ -118,6 +131,43 @@ namespace TShockAPI
|
||||||
* Useful stuff:
|
* 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()
|
private static void KeepTilesUpToDate()
|
||||||
{
|
{
|
||||||
TextReader tr = new StreamReader(saveDir + "tiles.txt");
|
TextReader tr = new StreamReader(saveDir + "tiles.txt");
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
|
<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.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" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue