Merge branch 'master' of github.com:TShock/TShock

Conflicts:
	TShockAPI/Commands.cs
This commit is contained in:
Shank 2011-06-07 11:13:47 -06:00
commit d5072af087
5 changed files with 144 additions and 74 deletions

View file

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

View file

@ -51,8 +51,8 @@ namespace TShockAPI
CommandArgs args = new CommandArgs(); CommandArgs args = new CommandArgs();
args.Message = msg; args.Message = msg;
args.PlayerX = (int) ply.GetPlayer().position.X; args.PlayerX = (int)ply.GetPlayer().position.X;
args.PlayerY = (int) ply.GetPlayer().position.Y; args.PlayerY = (int)ply.GetPlayer().position.Y;
args.PlayerID = ply.GetPlayerID(); args.PlayerID = ply.GetPlayerID();
command(args); command(args);
@ -79,6 +79,8 @@ namespace TShockAPI
commands.Add(new Command("kick", "kick", Kick)); commands.Add(new Command("kick", "kick", Kick));
commands.Add(new Command("ban", "ban", Ban)); commands.Add(new Command("ban", "ban", Ban));
commands.Add(new Command("banip", "ban", BanIP)); commands.Add(new Command("banip", "ban", BanIP));
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("off", "maintenance", Off));
commands.Add(new Command("reload", "cfg", Reload)); commands.Add(new Command("reload", "cfg", Reload));
commands.Add(new Command("dropmeteor", "causeevents", DropMeteor)); commands.Add(new Command("dropmeteor", "causeevents", DropMeteor));
@ -136,14 +138,14 @@ namespace TShockAPI
} }
else else
{ {
Tools.SendMessage(args.PlayerID, "You are not in a party!", new float[]{ 255f, 240f, 20f}); Tools.SendMessage(args.PlayerID, "You are not in a party!", new float[] { 255f, 240f, 20f });
} }
} }
public static void ThirdPerson(CommandArgs args) public static void ThirdPerson(CommandArgs args)
{ {
string msg = args.Message.Remove(0, 3); string msg = args.Message.Remove(0, 3);
Tools.Broadcast("*" + Tools.FindPlayer(args.PlayerID) + " " + msg, new float[] {205, 133, 63}); Tools.Broadcast("*" + Tools.FindPlayer(args.PlayerID) + " " + msg, new float[] { 205, 133, 63 });
} }
public static void Playing(CommandArgs args) public static void Playing(CommandArgs args)
@ -160,7 +162,7 @@ namespace TShockAPI
lineOne += "BanCheater : " + ConfigurationManager.banCheater + ", "; lineOne += "BanCheater : " + ConfigurationManager.banCheater + ", ";
lineOne += "KickGriefer : " + ConfigurationManager.kickGriefer + ", "; lineOne += "KickGriefer : " + ConfigurationManager.kickGriefer + ", ";
lineOne += "BanGriefer : " + ConfigurationManager.banGriefer; lineOne += "BanGriefer : " + ConfigurationManager.banGriefer;
Tools.SendMessage(ply, lineOne, new[] {255f, 255f, 0f}); Tools.SendMessage(ply, lineOne, new[] { 255f, 255f, 0f });
string lineTwo = ""; string lineTwo = "";
lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", "; lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", ";
lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", "; lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", ";
@ -192,12 +194,12 @@ namespace TShockAPI
Tools.Broadcast(Tools.FindPlayer(player) + " was kicked by " + Tools.FindPlayer(ply)); Tools.Broadcast(Tools.FindPlayer(player) + " was kicked by " + Tools.FindPlayer(ply));
} }
else else
Tools.SendMessage(ply, "You can't kick another admin!", new[] {255f, 0f, 0f}); Tools.SendMessage(ply, "You can't kick another admin!", new[] { 255f, 0f, 0f });
} }
else if (Tools.FindPlayer(plStr) == -2) else if (Tools.FindPlayer(plStr) == -2)
Tools.SendMessage(ply, "More than one player matched!", new[] {255f, 0f, 0f}); Tools.SendMessage(ply, "More than one player matched!", new[] { 255f, 0f, 0f });
else else
Tools.SendMessage(ply, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(ply, "Invalid player!", new[] { 255f, 0f, 0f });
} }
public static void BanIP(CommandArgs args) public static void BanIP(CommandArgs args)
@ -247,12 +249,44 @@ namespace TShockAPI
Tools.Broadcast(Tools.FindPlayer(adminplr) + " banned " + Tools.FindPlayer(player) + " with reason " + reason + "!"); Tools.Broadcast(Tools.FindPlayer(adminplr) + " banned " + Tools.FindPlayer(player) + " with reason " + reason + "!");
} }
else else
Tools.SendMessage(adminplr, "You can't ban another admin!", new[] {255f, 0f, 0f}); Tools.SendMessage(adminplr, "You can't ban another admin!", new[] { 255f, 0f, 0f });
} }
else if (Tools.FindPlayer(plStr) == -2) else if (Tools.FindPlayer(plStr) == -2)
Tools.SendMessage(adminplr, "More than one player matched!", new[] {255f, 0f, 0f}); Tools.SendMessage(adminplr, "More than one player matched!", new[] { 255f, 0f, 0f });
else else
Tools.SendMessage(adminplr, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(adminplr, "Invalid player!", new[] { 255f, 0f, 0f });
}
public static void UnBan(CommandArgs args)
{
string plStr = args.Message.Remove(0, 6);
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, 8);
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) public static void Off(CommandArgs args)
@ -290,12 +324,12 @@ namespace TShockAPI
int penis56 = 12; int penis56 = 12;
int penis57 = Main.rand.Next(Main.maxTilesX - 50) + 100; int penis57 = Main.rand.Next(Main.maxTilesX - 50) + 100;
penis57 *= 0x10; penis57 *= 0x10;
int penis58 = Main.rand.Next((int) (Main.maxTilesY*0.05))*0x10; int penis58 = Main.rand.Next((int)(Main.maxTilesY * 0.05)) * 0x10;
Vector2 vector = new Vector2(penis57, penis58); Vector2 vector = new Vector2(penis57, penis58);
float speedX = Main.rand.Next(-100, 0x65); float speedX = Main.rand.Next(-100, 0x65);
float speedY = Main.rand.Next(200) + 100; float speedY = Main.rand.Next(200) + 100;
float penis61 = (float) Math.Sqrt(((speedX*speedX) + (speedY*speedY))); float penis61 = (float)Math.Sqrt(((speedX * speedX) + (speedY * speedY)));
penis61 = (penis56)/penis61; penis61 = (penis56) / penis61;
speedX *= penis61; speedX *= penis61;
speedY *= penis61; speedY *= penis61;
Projectile.NewProjectile(vector.X, vector.Y, speedX, speedY, 12, 0x3e8, 10f, Main.myPlayer); Projectile.NewProjectile(vector.X, vector.Y, speedX, speedY, 12, 0x3e8, 10f, Main.myPlayer);
@ -317,7 +351,7 @@ namespace TShockAPI
int x = args.PlayerX; int x = args.PlayerX;
int y = args.PlayerY; int y = args.PlayerY;
int ply = args.PlayerID; int ply = args.PlayerID;
Tools.NewNPC((int) ConfigurationManager.NPCList.WORLD_EATER, x, y, ply); Tools.NewNPC((int)ConfigurationManager.NPCList.WORLD_EATER, x, y, ply);
Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned an eater of worlds!"); Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned an eater of worlds!");
} }
@ -326,7 +360,7 @@ namespace TShockAPI
int x = args.PlayerX; int x = args.PlayerX;
int y = args.PlayerY; int y = args.PlayerY;
int ply = args.PlayerID; int ply = args.PlayerID;
Tools.NewNPC((int) ConfigurationManager.NPCList.EYE, x, y, ply); Tools.NewNPC((int)ConfigurationManager.NPCList.EYE, x, y, ply);
Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned an eye!"); Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned an eye!");
} }
@ -335,7 +369,7 @@ namespace TShockAPI
int x = args.PlayerX; int x = args.PlayerX;
int y = args.PlayerY; int y = args.PlayerY;
int ply = args.PlayerID; int ply = args.PlayerID;
Tools.NewNPC((int) ConfigurationManager.NPCList.SKELETRON, x, y, ply); Tools.NewNPC((int)ConfigurationManager.NPCList.SKELETRON, x, y, ply);
Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned skeletron!"); Tools.Broadcast(Tools.FindPlayer(ply) + " has spawned skeletron!");
} }
@ -389,12 +423,11 @@ namespace TShockAPI
Tools.SendMessage(ply, "Teleported to your spawnpoint."); Tools.SendMessage(ply, "Teleported to your spawnpoint.");
} }
public static void Spawn(CommandArgs args) public static void Spawn(CommandArgs args)
{ {
int ply = args.PlayerID; int ply = args.PlayerID;
TShock.Teleport(ply, Main.spawnTileX*16 + 8 - Main.player[ply].width/2, TShock.Teleport(ply, Main.spawnTileX * 16 + 8 - Main.player[ply].width / 2,
Main.spawnTileY*16 - Main.player[ply].height); Main.spawnTileY * 16 - Main.player[ply].height);
Tools.SendMessage(ply, "Teleported to the map's spawnpoint."); Tools.SendMessage(ply, "Teleported to the map's spawnpoint.");
} }
@ -429,7 +462,7 @@ namespace TShockAPI
Tools.SendMessage(ply, "Teleported to " + player); Tools.SendMessage(ply, "Teleported to " + player);
} }
else else
Tools.SendMessage(ply, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(ply, "Invalid player!", new[] { 255f, 0f, 0f });
} }
public static void TPHere(CommandArgs args) public static void TPHere(CommandArgs args)
@ -443,7 +476,7 @@ namespace TShockAPI
Tools.SendMessage(ply, "You brought " + player + " here."); Tools.SendMessage(ply, "You brought " + player + " here.");
} }
else else
Tools.SendMessage(ply, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(ply, "Invalid player!", new[] { 255f, 0f, 0f });
} }
public static void SpawnMob(CommandArgs args) public static void SpawnMob(CommandArgs args)
@ -475,7 +508,7 @@ namespace TShockAPI
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /spawnmob <mob name/id> [amount]", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /spawnmob <mob name/id> [amount]",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
public static void Item(CommandArgs args) public static void Item(CommandArgs args)
@ -511,14 +544,14 @@ namespace TShockAPI
} }
} }
if (!flag) if (!flag)
Tools.SendMessage(args.PlayerID, "You don't have free slots!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "You don't have free slots!", new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid item type!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Invalid item type!", new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /item <item name/id>", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /item <item name/id>",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
public static void Give(CommandArgs args) public static void Give(CommandArgs args)
@ -562,17 +595,17 @@ namespace TShockAPI
} }
} }
if (!flag) if (!flag)
Tools.SendMessage(args.PlayerID, "Player does not have free slots!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Player does not have free slots!", new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Invalid player!", new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid item type!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Invalid item type!", new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /give <item type/id> <player>", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /give <item type/id> <player>",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
public static void Heal(CommandArgs args) public static void Heal(CommandArgs args)
@ -588,8 +621,8 @@ namespace TShockAPI
{ {
Tools.SendMessage(ply, string.Format("You just healed {0}", (msgargs[1].TrimEnd('"')).TrimStart('"'))); Tools.SendMessage(ply, string.Format("You just healed {0}", (msgargs[1].TrimEnd('"')).TrimStart('"')));
Tools.SendMessage(player, string.Format("{0} just healed you!", Tools.FindPlayer(ply))); Tools.SendMessage(player, string.Format("{0} just healed you!", Tools.FindPlayer(ply)));
x = (int) Main.player[player].position.X; x = (int)Main.player[player].position.X;
y = (int) Main.player[player].position.Y; y = (int)Main.player[player].position.Y;
} }
else else
Tools.SendMessage(ply, "You just got healed!"); Tools.SendMessage(ply, "You just got healed!");
@ -696,21 +729,24 @@ namespace TShockAPI
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers(); NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to night."); Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to night.");
} else if (arg[1] == "dusk") }
else if (arg[1] == "dusk")
{ {
Main.dayTime = false; Main.dayTime = false;
Main.time = 0.0; Main.time = 0.0;
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers(); NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to dusk."); Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to dusk.");
} else if (arg[1] == "noon") }
else if (arg[1] == "noon")
{ {
Main.dayTime = true; Main.dayTime = true;
Main.time = 27000.0; Main.time = 27000.0;
NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY); NetMessage.SendData(18, -1, -1, "", 0, 0, Main.sunModY, Main.moonModY);
NetMessage.syncPlayers(); NetMessage.syncPlayers();
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to noon."); Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " set time to noon.");
} else if (arg[1] == "midnight") }
else if (arg[1] == "midnight")
{ {
Main.dayTime = false; Main.dayTime = false;
Main.time = 16200.0; Main.time = 16200.0;
@ -720,11 +756,11 @@ namespace TShockAPI
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night/dusk/noon/midnight>", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night/dusk/noon/midnight>",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night/dusk/noon/midnight>", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /time <day/night/dusk/noon/midnight>",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
public static void Kill(CommandArgs args) public static void Kill(CommandArgs args)
@ -747,15 +783,15 @@ namespace TShockAPI
msgargs[i] = (msgargs[i].TrimStart('"')).TrimEnd('"'); msgargs[i] = (msgargs[i].TrimStart('"')).TrimEnd('"');
if (msgargs.Length == 1) if (msgargs.Length == 1)
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
else if (msgargs.Length == 2) else if (msgargs.Length == 2)
{ {
int player = Tools.FindPlayer(msgargs[1]); int player = Tools.FindPlayer(msgargs[1]);
if (player == -1) if (player == -1)
Tools.SendMessage(args.PlayerID, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Invalid player!", new[] { 255f, 0f, 0f });
else else
{ {
NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(1, 20)), 5, (float) 0); NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(1, 20)), 5, (float)0);
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) +
" for 5 damage."); " for 5 damage.");
} }
@ -766,17 +802,17 @@ namespace TShockAPI
int damage = 5; int damage = 5;
int.TryParse(msgargs[2], out damage); int.TryParse(msgargs[2], out damage);
if (player == -1) if (player == -1)
Tools.SendMessage(args.PlayerID, "Invalid player!", new[] {255f, 0f, 0f}); Tools.SendMessage(args.PlayerID, "Invalid player!", new[] { 255f, 0f, 0f });
else else
{ {
NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(-1, 1)), damage, (float) 0); NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(-1, 1)), damage, (float)0);
Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for " + Tools.Broadcast(Tools.FindPlayer(args.PlayerID) + " slapped " + Tools.FindPlayer(player) + " for " +
damage + " damage."); damage + " damage.");
} }
} }
else else
Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]", Tools.SendMessage(args.PlayerID, "Invalid syntax! Proper syntax: /slap <player> [dmg]",
new[] {255f, 0f, 0f}); new[] { 255f, 0f, 0f });
} }
public static void ProtectSpawn(CommandArgs args) public static void ProtectSpawn(CommandArgs args)

View file

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Text;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using Terraria; using Terraria;
@ -199,26 +200,37 @@ namespace TShockAPI
private void GetData(GetDataEventArgs e) private void GetData(GetDataEventArgs e)
{ {
e.Handled = HandleGetData(e);
}
private bool HandleGetData(GetDataEventArgs e)
{
if (!Netplay.serverSock[e.Msg.whoAmI].active || Netplay.serverSock[e.Msg.whoAmI].kill)
return true;
if (e.MsgID == 4) if (e.MsgID == 4)
{ {
var ban = Bans.GetBanByName(Main.player[e.Msg.whoAmI].name); var ban = Bans.GetBanByName(Main.player[e.Msg.whoAmI].name);
if (ban != null) if (ban != null)
{ {
Tools.Kick(e.Msg.whoAmI, "You are banned: " + ban.Reason); Tools.Kick(e.Msg.whoAmI, "You are banned: " + ban.Reason);
return true;
} }
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."); Tools.Kick(e.Msg.whoAmI, "Name exceeded 32 characters.");
return true;
} }
if (players[e.Msg.whoAmI] == null) if (players[e.Msg.whoAmI] == null)
{ {
Tools.Kick(e.Msg.whoAmI, "Player doesn't exist"); Tools.Kick(e.Msg.whoAmI, "Player doesn't exist");
e.Handled = true; return true;
} }
else if (players[e.Msg.whoAmI].receivedInfo) else if (players[e.Msg.whoAmI].receivedInfo)
{ {
Tools.Kick(e.Msg.whoAmI, "Sent client info more than once"); Tools.Kick(e.Msg.whoAmI, "Sent client info more than once");
e.Handled = true; return true;
} }
else else
{ {
@ -239,7 +251,7 @@ namespace TShockAPI
if (size > 5 || Math.Abs(plyX - tileX) > 10 || Math.Abs(plyY - tileY) > 10) if (size > 5 || Math.Abs(plyX - tileX) > 10 || Math.Abs(plyY - tileY) > 10)
{ {
Ban(e.Msg.whoAmI, "Send Tile Square Abuse"); Ban(e.Msg.whoAmI, "Send Tile Square Abuse");
e.Handled = true; return true;
} }
} }
} }
@ -263,12 +275,13 @@ namespace TShockAPI
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks."); TShock.Ban(e.Msg.whoAmI, "Placing impossible to place blocks.");
Tools.Broadcast(Main.player[e.Msg.whoAmI].name + Tools.Broadcast(Main.player[e.Msg.whoAmI].name +
" was banned for placing impossible to place blocks."); " was banned for placing impossible to place blocks.");
e.Handled = true; return 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"))
{ {
var flag = CheckSpawn(x, y); var flag = CheckSpawn(x, y);
@ -276,7 +289,9 @@ namespace TShockAPI
{ {
Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.",
new[] { 255f, 0f, 0f }); new[] { 255f, 0f, 0f });
e.Handled = true; return true;
}
}
} }
} }
@ -285,7 +300,6 @@ namespace TShockAPI
players[e.Msg.whoAmI].tileThreshold++; players[e.Msg.whoAmI].tileThreshold++;
players[e.Msg.whoAmI].tilesDestroyed.Add(new Position(x, y), Main.tile[x, y]); players[e.Msg.whoAmI].tilesDestroyed.Add(new Position(x, y), Main.tile[x, y]);
} }
return;
} }
} }
else if (e.MsgID == 0x1e) else if (e.MsgID == 0x1e)
@ -301,8 +315,7 @@ namespace TShockAPI
if (ConfigurationManager.permaPvp) if (ConfigurationManager.permaPvp)
Main.player[e.Msg.whoAmI].hostile = true; Main.player[e.Msg.whoAmI].hostile = true;
NetMessage.SendData(30, -1, -1, "", e.Msg.whoAmI); NetMessage.SendData(30, -1, -1, "", e.Msg.whoAmI);
e.Handled = true; return true;
return;
} }
} }
else if (e.MsgID == 0x0A) //SendSection else if (e.MsgID == 0x0A) //SendSection
@ -310,14 +323,14 @@ namespace TShockAPI
Tools.Broadcast(string.Format("{0}({1}) attempted sending a section", Main.player[e.Msg.whoAmI].name, Tools.Broadcast(string.Format("{0}({1}) attempted sending a section", Main.player[e.Msg.whoAmI].name,
e.Msg.whoAmI)); e.Msg.whoAmI));
Tools.Kick(e.Msg.whoAmI, "SendSection abuse."); Tools.Kick(e.Msg.whoAmI, "SendSection abuse.");
e.Handled = true; return true;
} }
else if (e.MsgID == 0x17) //Npc Data else if (e.MsgID == 0x17) //Npc Data
{ {
Tools.Broadcast(string.Format("{0}({1}) attempted spawning an NPC", Main.player[e.Msg.whoAmI].name, Tools.Broadcast(string.Format("{0}({1}) attempted spawning an NPC", Main.player[e.Msg.whoAmI].name,
e.Msg.whoAmI)); e.Msg.whoAmI));
Tools.Kick(e.Msg.whoAmI, "Spawn NPC abuse"); Tools.Kick(e.Msg.whoAmI, "Spawn NPC abuse");
e.Handled = true; return true;
} }
else if (e.MsgID == 0x0D) //Update Player else if (e.MsgID == 0x0D) //Update Player
{ {
@ -325,7 +338,7 @@ namespace TShockAPI
if (plr != e.Msg.whoAmI) if (plr != e.Msg.whoAmI)
{ {
Tools.Kick(e.Msg.whoAmI, "Update Player abuse"); Tools.Kick(e.Msg.whoAmI, "Update Player abuse");
e.Handled = true; return true;
} }
} }
else if (e.MsgID == 0x10) else if (e.MsgID == 0x10)
@ -350,7 +363,7 @@ namespace TShockAPI
Tools.Kick(ply, "Abnormal life increase"); Tools.Kick(ply, "Abnormal life increase");
Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") + Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") +
" because they gained an abnormal amount of health."); " because they gained an abnormal amount of health.");
e.Handled = true; return true;
} }
} }
} }
@ -383,7 +396,7 @@ namespace TShockAPI
Tools.Kick(ply, "Abnormal mana increase"); Tools.Kick(ply, "Abnormal mana increase");
Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") + Tools.Broadcast(playerName + " was " + (ConfigurationManager.banCheater ? "banned" : "kicked") +
" because they gained an abnormal amount of mana."); " because they gained an abnormal amount of mana.");
e.Handled = true; return true;
} }
} }
} }
@ -421,7 +434,7 @@ namespace TShockAPI
Tools.Broadcast(Main.player[i].name + " was " + Tools.Broadcast(Main.player[i].name + " was " +
(ConfigurationManager.banBoom ? "banned" : "kicked") + (ConfigurationManager.banBoom ? "banned" : "kicked") +
" for throwing an explosive device."); " for throwing an explosive device.");
e.Handled = true; return true;
} }
} }
} }
@ -441,7 +454,7 @@ namespace TShockAPI
Ban(e.Msg.whoAmI, "Griefer"); Ban(e.Msg.whoAmI, "Griefer");
Log.Info(Tools.FindPlayer(e.Msg.whoAmI) + Log.Info(Tools.FindPlayer(e.Msg.whoAmI) +
" was kicked for trying to execute KillMe on someone else."); " was kicked for trying to execute KillMe on someone else.");
e.Handled = true; return true;
} }
} }
} }
@ -455,7 +468,7 @@ namespace TShockAPI
byte pvp = br.ReadByte(); byte pvp = br.ReadByte();
if (!Main.player[playerid].hostile) if (!Main.player[playerid].hostile)
e.Handled = true; return true;
} }
} }
else if (e.MsgID == 0x30) else if (e.MsgID == 0x30)
@ -467,6 +480,10 @@ namespace TShockAPI
byte liquid = br.ReadByte(); byte liquid = br.ReadByte();
bool lava = br.ReadBoolean(); bool lava = br.ReadBoolean();
//The liquid was picked up.
if (liquid == 0)
return false;
int plyX = Math.Abs((int)Main.player[e.Msg.whoAmI].position.X / 16); 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 plyY = Math.Abs((int)Main.player[e.Msg.whoAmI].position.Y / 16);
int tileX = Math.Abs(x); int tileX = Math.Abs(x);
@ -486,19 +503,19 @@ namespace TShockAPI
if (lava && lavacount <= 0) if (lava && lavacount <= 0)
{ {
TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have."); TShock.Ban(e.Msg.whoAmI, "Placing lava they didn't have.");
e.Handled = true; return true;
} }
else if (!lava && watercount <= 0) else if (!lava && watercount <= 0)
{ {
TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have."); TShock.Ban(e.Msg.whoAmI, "Placing water they didn't have.");
e.Handled = true; return true;
} }
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
{ {
TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid."); TShock.Ban(e.Msg.whoAmI, "Placing impossible to place liquid.");
Tools.Broadcast(Main.player[e.Msg.whoAmI].name + Tools.Broadcast(Main.player[e.Msg.whoAmI].name +
" was banned for placing impossible to place liquid."); " was banned for placing impossible to place liquid.");
e.Handled = true; return true;
} }
if (ConfigurationManager.spawnProtect) if (ConfigurationManager.spawnProtect)
@ -509,7 +526,7 @@ namespace TShockAPI
if (flag) if (flag)
{ {
Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new[] { 255f, 0f, 0f }); Tools.SendMessage(e.Msg.whoAmI, "The spawn is protected!", new[] { 255f, 0f, 0f });
e.Handled = true; return true;
} }
} }
} }
@ -517,8 +534,10 @@ namespace TShockAPI
} }
else if (e.MsgID == 0x22) // Client only KillTile else if (e.MsgID == 0x22) // Client only KillTile
{ {
e.Handled = true; // Client only uses it for chests, but sends regular 17 as well. return true; // Client only uses it for chests, but sends regular 17 as well.
} }
return false;
} }
private void OnGreetPlayer(int who, HandledEventArgs e) private void OnGreetPlayer(int who, HandledEventArgs e)
@ -605,7 +624,6 @@ namespace TShockAPI
} }
string ip = Tools.GetPlayerIP(ply); string ip = Tools.GetPlayerIP(ply);
;
players[ply] = new TSPlayer(ply); players[ply] = new TSPlayer(ply);
players[ply].group = Tools.GetGroupForIP(ip); players[ply].group = Tools.GetGroupForIP(ip);
@ -613,6 +631,7 @@ namespace TShockAPI
!players[ply].group.HasPermission("reservedslot")) !players[ply].group.HasPermission("reservedslot"))
{ {
Tools.Kick(ply, "Server is full"); Tools.Kick(ply, "Server is full");
handler.Handled = true;
return; return;
} }
@ -620,10 +639,14 @@ namespace TShockAPI
if (ban != null) if (ban != null)
{ {
Tools.Kick(ply, "You are banned: " + ban.Reason); Tools.Kick(ply, "You are banned: " + ban.Reason);
handler.Handled = true;
return;
} }
if (!FileTools.OnWhitelist(ip)) if (!FileTools.OnWhitelist(ip))
{ {
Tools.Kick(ply, "Not on whitelist."); Tools.Kick(ply, "Not on whitelist.");
handler.Handled = true;
return;
} }
} }
@ -656,7 +679,7 @@ namespace TShockAPI
{ {
return; return;
} }
for (uint i = 0; i < Main.maxPlayers; i++) for (int i = 0; i < Main.maxPlayers; i++)
{ {
if (Main.player[i].active == false) if (Main.player[i].active == false)
{ {
@ -669,12 +692,15 @@ namespace TShockAPI
if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt) if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt)
{ {
if (ConfigurationManager.banTnt) if (ConfigurationManager.banTnt)
Ban((int)i, "Explosives"); Ban(i, "Kill Tile Abuse");
Tools.Kick((int)i, "Kill tile abuse detected."); else
Tools.Kick(i, "Kill tile abuse detected.");
Tools.Broadcast(Main.player[i].name + " was " + Tools.Broadcast(Main.player[i].name + " was " +
(ConfigurationManager.banTnt ? "banned" : "kicked") + (ConfigurationManager.banTnt ? "banned" : "kicked") +
" for kill tile abuse."); " for kill tile abuse.");
RevertKillTile((int)i); RevertKillTile(i);
players[i].tileThreshold = 0;
players[i].tilesDestroyed.Clear();
} }
else if (players[i].tileThreshold > 0) else if (players[i].tileThreshold > 0)
{ {

View file

@ -85,7 +85,6 @@ namespace TShockAPI
Log.Info("Broadcast: " + msg); Log.Info("Broadcast: " + msg);
} }
public static void Broadcast(string msg, float[] color) public static void Broadcast(string msg, float[] color)
{ {
for (int i = 0; i < Main.player.Length; i++) for (int i = 0; i < Main.player.Length; i++)
@ -215,6 +214,8 @@ namespace TShockAPI
/// <param name="reason">string reason</param> /// <param name="reason">string reason</param>
public static void Kick(int ply, string reason) public static void Kick(int ply, string reason)
{ {
if (!Netplay.serverSock[ply].active || Netplay.serverSock[ply].kill)
return;
if (!TShock.players[ply].group.HasPermission("immunetokick") || reason.Contains("Banned: ")) if (!TShock.players[ply].group.HasPermission("immunetokick") || reason.Contains("Banned: "))
{ {
string displayName = FindPlayer(ply).Equals("") ? GetPlayerIP(ply) : FindPlayer(ply); string displayName = FindPlayer(ply).Equals("") ? GetPlayerIP(ply) : FindPlayer(ply);
@ -239,7 +240,7 @@ namespace TShockAPI
{ {
string possibleColor = foo.Substring(0, 13); string possibleColor = foo.Substring(0, 13);
foo = foo.Remove(0, 13); foo = foo.Remove(0, 13);
float[] pC = {0, 0, 0}; float[] pC = { 0, 0, 0 };
possibleColor = possibleColor.Replace("%", ""); possibleColor = possibleColor.Replace("%", "");
string[] pCc = possibleColor.Split(','); string[] pCc = possibleColor.Split(',');
if (pCc.Length == 3) if (pCc.Length == 3)

View file

@ -17,5 +17,5 @@
default null default null
vip default reservedslot vip default reservedslot
newadmin default kick editspawn 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 trustedadmin admin maintenance cfg cheat pvpfun ignorecheatdetection immunetoban ignoregriefdetection