Merge branch 'master' of github.com:TShock/TShock
This commit is contained in:
commit
e1776f8d01
4 changed files with 64 additions and 15 deletions
|
|
@ -82,6 +82,20 @@ namespace TShockAPI
|
|||
public string MySqlUsername = "";
|
||||
public string MySqlPassword = "";
|
||||
|
||||
public string RangeCheckBanReason = "Placing impossible to place blocks.";
|
||||
public string SendSectionAbuseReason = "SendSection abuse.";
|
||||
public string NPCSpawnAbuseReason = "Spawn NPC abuse";
|
||||
public string UpdatePlayerAbuseReason = "Update Player abuse";
|
||||
public string ExplosiveAbuseReason = "Throwing an explosive device.";
|
||||
public string KillMeAbuseReason = "Trying to execute KillMe on someone else.";
|
||||
public string IllogicalLiquidUseReason = "Manipulating liquid without bucket.";
|
||||
public string LiquidAbuseReason = "Placing impossible to place liquid.";
|
||||
public string TileKillAbuseReason = "Tile Kill abuse ({0})";
|
||||
public string HardcoreBanReason = "Death results in a ban";
|
||||
public string HardcoreKickReason = "Death results in a kick";
|
||||
|
||||
public bool EnableDNSHostResolution = false;
|
||||
|
||||
public static ConfigFile Read(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
|
|
|
|||
|
|
@ -222,6 +222,36 @@ namespace TShockAPI.DB
|
|||
}
|
||||
return Tools.GetGroup("default");
|
||||
}
|
||||
|
||||
public Group GetGroupForIPExpensive(string ip)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var com = database.CreateCommand())
|
||||
{
|
||||
com.CommandText = "SELECT * FROM Users";
|
||||
|
||||
using (var reader = com.ExecuteReader())
|
||||
{
|
||||
while(reader.Read())
|
||||
{
|
||||
if (Tools.GetIPv4Address(reader.Get<string>("IP")) == ip)
|
||||
{
|
||||
string group = reader.Get<string>("UserGroup");
|
||||
return Tools.GetGroup(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ConsoleError("GetGroupForIP SQL returned an error: " + ex.ToString());
|
||||
}
|
||||
return Tools.GetGroup("default");
|
||||
}
|
||||
|
||||
|
||||
public User GetUserByName(string name)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ namespace TShockAPI
|
|||
{
|
||||
Log.Debug(string.Format("TilePlaced(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Type:{6})",
|
||||
plyX, plyY, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), tiletype));
|
||||
return Tools.HandleGriefer(args.Player, "Placing impossible to place blocks.");
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.RangeCheckBanReason);
|
||||
}
|
||||
}
|
||||
if (tiletype == 48 && !args.Player.Group.HasPermission("canspike"))
|
||||
|
|
@ -355,12 +355,12 @@ namespace TShockAPI
|
|||
|
||||
private static bool HandleSendSection(GetDataHandlerArgs args)
|
||||
{
|
||||
return Tools.HandleGriefer(args.Player, "SendSection abuse.");
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.SendSectionAbuseReason);
|
||||
}
|
||||
|
||||
private static bool HandleNpcUpdate(GetDataHandlerArgs args)
|
||||
{
|
||||
return Tools.HandleGriefer(args.Player, "Spawn NPC abuse");
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.NPCSpawnAbuseReason);
|
||||
}
|
||||
|
||||
private static bool HandlePlayerUpdate(GetDataHandlerArgs args)
|
||||
|
|
@ -378,12 +378,12 @@ namespace TShockAPI
|
|||
|
||||
if (plr != args.Player.Index)
|
||||
{
|
||||
return Tools.HandleGriefer(args.Player, "Update Player abuse");
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.UpdatePlayerAbuseReason);
|
||||
}
|
||||
|
||||
if (item < 0 || item >= args.TPlayer.inventory.Length)
|
||||
{
|
||||
Tools.HandleGriefer(args.Player, "Update Player abuse");
|
||||
Tools.HandleGriefer(args.Player, TShock.Config.UpdatePlayerAbuseReason);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -414,7 +414,7 @@ namespace TShockAPI
|
|||
//return true;
|
||||
}
|
||||
else
|
||||
return Tools.HandleExplosivesUser(args.Player, "Throwing an explosive device.");
|
||||
return Tools.HandleExplosivesUser(args.Player, TShock.Config.ExplosiveAbuseReason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ namespace TShockAPI
|
|||
byte id = args.Data.ReadInt8();
|
||||
if (id != args.Player.Index)
|
||||
{
|
||||
return Tools.HandleGriefer(args.Player, "Trying to execute KillMe on someone else.");
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.KillMeAbuseReason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -491,13 +491,13 @@ namespace TShockAPI
|
|||
Log.Debug(string.Format("{0}(PlyXY:{1}_{2}, TileXY:{3}_{4}, Result:{5}_{6}, Amount:{7})",
|
||||
lava ? "Lava" : "Water", plyX, plyY, tileX, tileY,
|
||||
Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), liquid));
|
||||
return Tools.HandleGriefer(args.Player, "Manipulating liquid without bucket."); ;
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.IllogicalLiquidUseReason); ;
|
||||
}
|
||||
if (TShock.Config.RangeChecks && ((Math.Abs(plyX - tileX) > 32) || (Math.Abs(plyY - tileY) > 32)))
|
||||
{
|
||||
Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Amount:{6})",
|
||||
plyX, plyY, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), liquid));
|
||||
return Tools.HandleGriefer(args.Player, "Placing impossible to place liquid."); ;
|
||||
return Tools.HandleGriefer(args.Player, TShock.Config.LiquidAbuseReason); ;
|
||||
}
|
||||
|
||||
if (TShock.Config.SpawnProtection)
|
||||
|
|
@ -527,7 +527,7 @@ namespace TShockAPI
|
|||
{
|
||||
Log.Debug(string.Format("TileKill(TileXY:{0}_{1}, Type:{2})",
|
||||
tilex, tiley, Main.tile[tilex, tiley].type));
|
||||
Tools.ForceKick(args.Player, string.Format("Tile Kill abuse ({0})", Main.tile[tilex, tiley].type));
|
||||
Tools.ForceKick(args.Player, string.Format(TShock.Config.TileKillAbuseReason, Main.tile[tilex, tiley].type));
|
||||
return true;
|
||||
}
|
||||
if (!args.Player.Group.HasPermission("canbuild"))
|
||||
|
|
@ -580,12 +580,12 @@ namespace TShockAPI
|
|||
{
|
||||
if (TShock.Config.BanOnHardcoreDeath)
|
||||
{
|
||||
if (!Tools.Ban(args.Player, "Death results in a ban"))
|
||||
if (!Tools.Ban(args.Player, TShock.Config.HardcoreBanReason))
|
||||
Tools.ForceKick(args.Player, "Death results in a ban, but can't ban you");
|
||||
}
|
||||
else
|
||||
{
|
||||
Tools.ForceKick(args.Player, "Death results in a kick");
|
||||
Tools.ForceKick(args.Player, TShock.Config.HardcoreKickReason);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace TShockAPI
|
|||
public class TShock : TerrariaPlugin
|
||||
{
|
||||
public static readonly Version VersionNum = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
public static readonly string VersionCodename = "The Deathly Database Part 2";
|
||||
public static readonly string VersionCodename = "Codename: Re";
|
||||
|
||||
public static string SavePath = "tshock";
|
||||
|
||||
|
|
@ -376,8 +376,13 @@ namespace TShockAPI
|
|||
private void OnJoin(int ply, HandledEventArgs handler)
|
||||
{
|
||||
var player = new TSPlayer(ply);
|
||||
|
||||
if (Config.EnableDNSHostResolution)
|
||||
{
|
||||
player.Group = TShock.Users.GetGroupForIPExpensive(player.IP);
|
||||
} else
|
||||
{
|
||||
player.Group = TShock.Users.GetGroupForIP(player.IP);
|
||||
}
|
||||
|
||||
if (Tools.ActivePlayers() + 1 > TShock.Config.MaxSlots && !player.Group.HasPermission("reservedslot"))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue