Added unban/unbanip

Fixed banning when a player picks up lava/water
Fixed name check for real this time.
Fixed banning multiple times.
This commit is contained in:
high 2011-06-07 04:56:01 -04:00
parent b7a87866fe
commit 6371a301da
4 changed files with 94 additions and 45 deletions

View file

@ -47,10 +47,17 @@ namespace TShockAPI
public void AddBan(string ip, string name = "", string reason = "")
{
if (GetBanByIp(ip) != null)
return;
Bans.Add(new Ban(ip, name, reason));
SaveBans();
}
public void RemoveBan(Ban ban)
{
Bans.Remove(ban);
}
/// <summary>
/// Reloads the file if it was changed
/// </summary>

View file

@ -78,6 +78,8 @@ namespace TShockAPI
{
commands.Add(new Command("kick", "kick", Kick));
commands.Add(new Command("ban", "ban", Ban));
commands.Add(new Command("unban", "unban", UnBan));
commands.Add(new Command("unbanip", "unbanip", UnBanIP));
commands.Add(new Command("off", "maintenance", Off));
commands.Add(new Command("reload", "cfg", Reload));
commands.Add(new Command("dropmeteor", "causeevents", DropMeteor));
@ -232,6 +234,38 @@ namespace TShockAPI
Tools.SendMessage(adminplr, "Invalid player!", new[] { 255f, 0f, 0f });
}
public static void UnBan(CommandArgs args)
{
string plStr = args.Message.Remove(0, 4);
int adminplr = args.PlayerID;
var ban = TShock.Bans.GetBanByName(plStr);
if (ban != null)
{
TShock.Bans.RemoveBan(ban);
Tools.SendMessage(adminplr, string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), new[] { 255f, 0f, 0f });
}
else
{
Tools.SendMessage(adminplr, "Invalid player!", new[] { 255f, 0f, 0f });
}
}
public static void UnBanIP(CommandArgs args)
{
string plStr = args.Message.Remove(0, 4);
int adminplr = args.PlayerID;
var ban = TShock.Bans.GetBanByIp(plStr);
if (ban != null)
{
TShock.Bans.RemoveBan(ban);
Tools.SendMessage(adminplr, string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP), new[] { 255f, 0f, 0f });
}
else
{
Tools.SendMessage(adminplr, "Invalid player!", new[] { 255f, 0f, 0f });
}
}
public static void Off(CommandArgs args)
{
for (int player = 0; player < Main.maxPlayers; player++)
@ -366,7 +400,6 @@ namespace TShockAPI
Tools.SendMessage(ply, "Teleported to your spawnpoint.");
}
public static void Spawn(CommandArgs args)
{
int ply = args.PlayerID;
@ -673,21 +706,24 @@ namespace TShockAPI
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to night.");
} else if (arg[1] == "dusk")
}
else if (arg[1] == "dusk")
{
Main.dayTime = false;
Main.time = 0.0;
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to dusk.");
} else if (arg[1] == "noon")
}
else if (arg[1] == "noon")
{
Main.dayTime = true;
Main.time = 27000.0;
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to noon.");
} else if (arg[1] == "midnight")
}
else if (arg[1] == "midnight")
{
Main.dayTime = false;
Main.time = 16200.0;

View file

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Terraria;
@ -206,7 +207,8 @@ namespace TShockAPI
{
Tools.Kick(e.Msg.whoAmI, "You are banned: " + ban.Reason);
}
if (Main.player[e.Msg.whoAmI].name.Length > 32)
string name = Encoding.ASCII.GetString(e.Msg.readBuffer, e.Index + 23, (e.Length - (e.Index + 23)) + e.Index - 1);
if (name.Length > 32)
{
Tools.Kick(e.Msg.whoAmI, "Name exceeded 32 characters.");
}
@ -467,6 +469,10 @@ namespace TShockAPI
byte liquid = br.ReadByte();
bool lava = br.ReadBoolean();
//The liquid was picked up.
if (liquid == 0)
return;
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16);
int plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16);
int tileX = Math.Abs(x);

View file

@ -17,5 +17,5 @@
default null
vip default reservedslot
newadmin default kick editspawn reservedslot
admin newadmin ban causeevents spawnboss spawnmob tp immunetokick kill
admin newadmin ban unban unbanip causeevents spawnboss spawnmob tp immunetokick kill
trustedadmin admin maintenance cfg cheat pvpfun ignorecheatdetection immunetoban ignoregriefdetection