Added ban for placing impossible to place tiles and liquids.
Added ban for attempting to place non-existent liquids.
This commit is contained in:
parent
46fcd29337
commit
43b968e37f
3 changed files with 60 additions and 10 deletions
|
|
@ -200,7 +200,18 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static void Ban(CommandArgs args)
|
public static void Ban(CommandArgs args)
|
||||||
{
|
{
|
||||||
string plStr = args.Message.Remove(0, 4).Trim().TrimEnd('"').TrimStart('"');
|
string plStr = args.Message.Remove(0, 4).Trim().TrimEnd('"').TrimStart('"').Split(' ')[0];
|
||||||
|
string[] reason = plStr.Split(' ');
|
||||||
|
string banReason = "";
|
||||||
|
for (int i = 0; i < reason.Length; i++)
|
||||||
|
{
|
||||||
|
if (reason[i].Contains("\""))
|
||||||
|
reason[i] = "";
|
||||||
|
}
|
||||||
|
for (int i = 0; i < reason.Length; i++)
|
||||||
|
{
|
||||||
|
banReason += reason[i];
|
||||||
|
}
|
||||||
int adminplr = args.PlayerID;
|
int adminplr = args.PlayerID;
|
||||||
int player = Tools.FindPlayer(plStr);
|
int player = Tools.FindPlayer(plStr);
|
||||||
if (!(player == -1 || player == -2 || plStr == ""))
|
if (!(player == -1 || player == -2 || plStr == ""))
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ namespace TShockAPI
|
||||||
public bool syncHP;
|
public bool syncHP;
|
||||||
public bool syncMP;
|
public bool syncMP;
|
||||||
public Group group;
|
public Group group;
|
||||||
|
public int lavaCount = 0;
|
||||||
|
public int waterCount = 0;
|
||||||
private int player;
|
private int player;
|
||||||
|
|
||||||
public TSPlayer(int ply)
|
public TSPlayer(int ply)
|
||||||
|
|
|
||||||
|
|
@ -199,10 +199,6 @@ namespace TShockAPI
|
||||||
|
|
||||||
private void GetData(GetDataEventArgs e)
|
private void GetData(GetDataEventArgs e)
|
||||||
{
|
{
|
||||||
if (Main.netMode != 2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.MsgID == 17)
|
if (e.MsgID == 17)
|
||||||
{
|
{
|
||||||
using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
|
using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
|
||||||
|
|
@ -211,7 +207,20 @@ namespace TShockAPI
|
||||||
int x = br.ReadInt32();
|
int x = br.ReadInt32();
|
||||||
int y = br.ReadInt32();
|
int y = br.ReadInt32();
|
||||||
byte typetile = br.ReadByte();
|
byte typetile = br.ReadByte();
|
||||||
|
if (type == 1 || type == 3)
|
||||||
|
{
|
||||||
|
int plyX = Math.Abs((int) Main.player[e.Msg.whoAmI].position.X);
|
||||||
|
int plyY = Math.Abs((int) Main.player[e.Msg.whoAmI].position.Y);
|
||||||
|
int realX = Math.Abs(x*16);
|
||||||
|
int realY = Math.Abs(y*16);
|
||||||
|
|
||||||
|
if ((plyX - realX > 6) || (plyY - realY > 6))
|
||||||
|
TShock.Ban(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)
|
||||||
|
|
||||||
if (ConfigurationManager.spawnProtect)
|
if (ConfigurationManager.spawnProtect)
|
||||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||||
{
|
{
|
||||||
|
|
@ -411,6 +420,34 @@ namespace TShockAPI
|
||||||
byte liquid = br.ReadByte();
|
byte liquid = br.ReadByte();
|
||||||
bool lava = br.ReadBoolean();
|
bool lava = br.ReadBoolean();
|
||||||
|
|
||||||
|
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X);
|
||||||
|
int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y);
|
||||||
|
int realX = Math.Abs(x * 16);
|
||||||
|
int realY = Math.Abs(y * 16);
|
||||||
|
|
||||||
|
for (int i = 0; i < 44; i++)
|
||||||
|
{
|
||||||
|
if (Main.player[e.Msg.whoAmI].inventory[i].name == "Lava Bucket")
|
||||||
|
TShock.players[e.Msg.whoAmI].lavaCount++;
|
||||||
|
else if (Main.player[e.Msg.whoAmI].inventory[i].name == "Water Bucket")
|
||||||
|
TShock.players[e.Msg.whoAmI].waterCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lava && TShock.players[e.Msg.whoAmI].lavaCount <= 0)
|
||||||
|
{
|
||||||
|
TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have.");
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
else if (!lava && TShock.players[e.Msg.whoAmI].waterCount <= 0)
|
||||||
|
{
|
||||||
|
TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have.");
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
if ((plyX - realX > 6) || (plyY - realY > 6))
|
||||||
|
TShock.Ban(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)
|
||||||
{
|
{
|
||||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||||
|
|
@ -423,12 +460,12 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x22) // Client only KillTile
|
|
||||||
{
|
|
||||||
e.Handled = true; // Client only uses it for chests, but sends regular 17 as well.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (e.MsgID == 0x22) // Client only KillTile
|
||||||
|
{
|
||||||
|
e.Handled = true; // Client only uses it for chests, but sends regular 17 as well.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGreetPlayer(int who, HandledEventArgs e)
|
private void OnGreetPlayer(int who, HandledEventArgs e)
|
||||||
|
|
@ -797,6 +834,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static void Ban(int plr, string reason = "")
|
public static void Ban(int plr, string reason = "")
|
||||||
{
|
{
|
||||||
|
Tools.Kick(plr, reason);
|
||||||
Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason);
|
Bans.AddBan(Tools.GetPlayerIP(plr), Main.player[plr].name, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue