Merge remote-tracking branch 'upstream/master'

Conflicts:
	TShockAPI/Commands.cs
	TShockAPI/TShock.cs
	TShockAPI/Tools.cs
This commit is contained in:
ricky 2011-06-07 20:28:11 +10:00
commit c368518caa
5 changed files with 96 additions and 41 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));
@ -244,12 +246,46 @@ namespace TShockAPI
Tools.SendMessage(ply, "You can't ban another admin!", new[] { 255f, 0f, 0f });
}
}
else
Tools.SendMessage(adminplr, "You can't ban another admin!", new[] { 255f, 0f, 0f });
}
else
Tools.SendMessage(ply, "Invalid syntax! Proper syntax: /ban <player> [reason]",
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++)
@ -384,7 +420,6 @@ namespace TShockAPI
Tools.SendMessage(ply, "Teleported to your spawnpoint.");
}
public static void Spawn(CommandArgs args)
{
int ply = args.PlayerID;
@ -691,21 +726,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,8 +207,10 @@ namespace TShockAPI
{
Tools.ForceKick(e.Msg.whoAmI, "You are banned: " + ban.Reason);
e.Handled = true;
return;
}
else 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.ForceKick(e.Msg.whoAmI, "Name exceeded 32 characters.");
e.Handled = true;
@ -417,6 +420,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);
@ -610,6 +617,8 @@ namespace TShockAPI
if (Tools.HandleTntUser((int)i, "Kill tile abuse detected."))
{
RevertKillTile((int)i);
players[i].tileThreshold = 0;
players[i].tilesDestroyed.Clear();
}
else if (players[i].tileThreshold > 0)
{

3
TShockAPI/Tools.cs Normal file → Executable file
View file

@ -85,7 +85,6 @@ namespace TShockAPI
Log.Info("Broadcast: " + msg);
}
public static void Broadcast(string msg, float[] color)
{
for (int i = 0; i < Main.player.Length; i++)
@ -227,6 +226,8 @@ namespace TShockAPI
/// <param name="reason">string reason</param>
public static bool Kick(int ply, string reason, string adminUserName = "")
{
if (!Main.player[ply].active)
return;
if (!TShock.players[ply].group.HasPermission("immunetokick"))
{
string playerName = Main.player[ply].name;

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