Fixed false bans when picking up liquid.

Added 3 permissions (canlava, canwater, logs)
'canlava' and 'canwater' are in the default group. Without them you cannot manipulate water/lava.
Users with the 'logs' permission get sent information. For example when someone uses a command they don't have access to.
This commit is contained in:
high 2011-06-08 10:36:56 -04:00
parent 55000158ee
commit 0dc39e15f5
5 changed files with 92 additions and 50 deletions

View file

@ -141,20 +141,20 @@ namespace TShockAPI
{ {
if (Main.player[i].team == Main.player[args.PlayerID].team) if (Main.player[i].team == Main.player[args.PlayerID].team)
{ {
Tools.SendMessage(i, msg, new float[] { (float)Main.teamColor[playerTeam].R, (float)Main.teamColor[playerTeam].G, (float)Main.teamColor[playerTeam].B }); Tools.SendMessage(i, msg, Main.teamColor[playerTeam].R, Main.teamColor[playerTeam].G, Main.teamColor[playerTeam].B);
} }
} }
} }
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!", 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, 205, 133, 63);
} }
public static void Playing(CommandArgs args) public static void Playing(CommandArgs args)
@ -171,23 +171,23 @@ 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, 255f, 255f, 0f);
string lineTwo = ""; string lineTwo = "";
lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", "; lineTwo += "BanTnt : " + ConfigurationManager.banTnt + ", ";
lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", "; lineTwo += "KickTnt : " + ConfigurationManager.kickTnt + ", ";
lineTwo += "BanBoom : " + ConfigurationManager.banBoom + ", "; lineTwo += "BanBoom : " + ConfigurationManager.banBoom + ", ";
lineTwo += "KickBoom : " + ConfigurationManager.kickBoom; lineTwo += "KickBoom : " + ConfigurationManager.kickBoom;
Tools.SendMessage(ply, lineTwo, new[] { 255f, 255f, 0f }); Tools.SendMessage(ply, lineTwo, 255f, 255f, 0f);
string lineThree = ""; string lineThree = "";
lineThree += "InvMultiplier : " + ConfigurationManager.invasionMultiplier + ", "; lineThree += "InvMultiplier : " + ConfigurationManager.invasionMultiplier + ", ";
lineThree += "ProtectS : " + ConfigurationManager.spawnProtect + ", "; lineThree += "ProtectS : " + ConfigurationManager.spawnProtect + ", ";
lineThree += "ProtectR : " + ConfigurationManager.spawnProtectRadius + ", "; lineThree += "ProtectR : " + ConfigurationManager.spawnProtectRadius + ", ";
lineThree += "DMS : " + ConfigurationManager.defaultMaxSpawns + ", "; lineThree += "DMS : " + ConfigurationManager.defaultMaxSpawns + ", ";
lineThree += "SpawnRate: " + ConfigurationManager.defaultSpawnRate; lineThree += "SpawnRate: " + ConfigurationManager.defaultSpawnRate;
Tools.SendMessage(ply, lineThree, new[] { 255f, 255f, 0f }); Tools.SendMessage(ply, lineThree, 255f, 255f, 0f);
string lineFour = ""; string lineFour = "";
lineFour += "MaxSlots : " + ConfigurationManager.maxSlots + ", "; lineFour += "MaxSlots : " + ConfigurationManager.maxSlots + ", ";
Tools.SendMessage(ply, lineFour, new[] { 255f, 255f, 0f }); Tools.SendMessage(ply, lineFour, 255f, 255f, 0f);
} }
public static void Kick(CommandArgs args) public static void Kick(CommandArgs args)
@ -210,20 +210,20 @@ namespace TShockAPI
{ {
int player = Tools.FindPlayer(plStr); int player = Tools.FindPlayer(plStr);
if (player == -1) if (player == -1)
Tools.SendMessage(ply, "Invalid player!", new[] { 255f, 0f, 0f }); Tools.SendMessage(ply, "Invalid player!", 255f, 0f, 0f);
else if (player == -2) else if (player == -2)
Tools.SendMessage(ply, "More than one player matched!", new[] { 255f, 0f, 0f }); Tools.SendMessage(ply, "More than one player matched!", 255f, 0f, 0f );
else else
{ {
if (!Tools.Kick(player, reason.Length != 0 ? reason : "Misbehaviour.")) if (!Tools.Kick(player, reason.Length != 0 ? reason : "Misbehaviour."))
{ {
Tools.SendMessage(ply, "You can't kick another admin!", new[] { 255f, 0f, 0f }); Tools.SendMessage(ply, "You can't kick another admin!", 255f, 0f, 0f );
} }
} }
} }
else else
Tools.SendMessage(ply, "Invalid syntax! Proper syntax: /kick <player> [reason]", Tools.SendMessage(ply, "Invalid syntax! Proper syntax: /kick <player> [reason]",
new[] { 255f, 0f, 0f }); 255f, 0f, 0f );
} }
public static void BanIP(CommandArgs args) public static void BanIP(CommandArgs args)

View file

@ -19,7 +19,7 @@ namespace TShockAPI
public static string saveDir = "./tshock/"; public static string saveDir = "./tshock/";
public static Version VersionNum = new Version(2, 0, 0, 2); public static Version VersionNum = new Version(2, 0, 0, 4);
public static string VersionCodename = "UnrealIRCd ftw (irc.shankshock.com #terraria)"; public static string VersionCodename = "UnrealIRCd ftw (irc.shankshock.com #terraria)";
@ -134,9 +134,10 @@ namespace TShockAPI
{ {
Console.WriteLine(ex.ToString()); Console.WriteLine(ex.ToString());
} }
Console.WriteLine("TShock Version " + Version.Major + "." + Version.Minor + "." + Version.Build + "." + string version = "TShock Version " + Version + " (" + VersionCodename + ") now running.";
Version.Revision + " (" + VersionCodename + ") now running."); Console.WriteLine(version);
Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, false); Log.Initialize(FileTools.SaveDir + "log.txt", LogLevel.All, false);
Log.Info(version);
Log.Info("Starting..."); Log.Info("Starting...");
GameHooks.Initialize += OnPreInit; GameHooks.Initialize += OnPreInit;
@ -445,41 +446,48 @@ namespace TShockAPI
int tileX = Math.Abs(x); int tileX = Math.Abs(x);
int tileY = Math.Abs(y); int tileY = Math.Abs(y);
int lavacount = 0; bool bucket = false;
int watercount = 0;
for (int i = 0; i < 44; i++) for (int i = 0; i < 44; i++)
{ {
if (Main.player[e.Msg.whoAmI].inventory[i].name == "Lava Bucket") if (Main.player[e.Msg.whoAmI].inventory[i].type >= 205 && Main.player[e.Msg.whoAmI].inventory[i].type <= 207)
lavacount++; {
else if (Main.player[e.Msg.whoAmI].inventory[i].name == "Water Bucket") bucket = true;
watercount++; break;
}
} }
if (lava && lavacount <= 0) if (lava && !players[e.Msg.whoAmI].group.HasPermission("canlava"))
{ {
Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5})", Tools.SendMessage(e.Msg.whoAmI, "You do not have permission to use lava", Color.Red);
Tools.SendLogs(Main.player[e.Msg.whoAmI].name + " tried using lava", Color.Red);
return true;
}
if (!lava && !players[e.Msg.whoAmI].group.HasPermission("canwater"))
{
Tools.SendMessage(e.Msg.whoAmI, "You do not have permission to use water", Color.Red);
Tools.SendLogs(Main.player[e.Msg.whoAmI].name + " tried using water", Color.Red);
return true;
}
if (!bucket)
{
Log.Debug(string.Format("{0}(PlyXY:{1}_{2}, TileXY:{3}_{4}, Result:{5}_{6}, Amount:{7})",
lava ? "Lava" : "Water",
plyX, plyY, plyX, plyY,
tileX, tileY, tileX, tileY,
Math.Abs(plyX - tileX), Math.Abs(plyY - tileY) Math.Abs(plyX - tileX), Math.Abs(plyY - tileY),
liquid
)); ));
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing lava they didn't have."); ; return Tools.HandleGriefer(e.Msg.whoAmI, "Manipulating liquid without bucket."); ;
}
if (!lava && watercount <= 0)
{
Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5})",
plyX, plyY,
tileX, tileY,
Math.Abs(plyX - tileX), Math.Abs(plyY - tileY)
));
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing water they didn't have.");
} }
if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6)) if ((Math.Abs(plyX - tileX) > 6) || (Math.Abs(plyY - tileY) > 6))
{ {
Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5})", Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Amount:{6})",
plyX, plyY, plyX, plyY,
tileX, tileY, tileX, tileY,
Math.Abs(plyX - tileX), Math.Abs(plyY - tileY) Math.Abs(plyX - tileX), Math.Abs(plyY - tileY),
liquid
)); ));
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place liquid."); ; return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place liquid."); ;
} }
@ -521,10 +529,8 @@ namespace TShockAPI
private void OnGreetPlayer(int who, HandledEventArgs e) private void OnGreetPlayer(int who, HandledEventArgs e)
{ {
if (Main.netMode != 2) if (Main.netMode != 2)
{
return; return;
}
int plr = who; //legacy support
Log.Info(Tools.FindPlayer(who) + " (" + Tools.GetPlayerIP(who) + ") from '" + players[who].group.GetName() + "' group joined."); Log.Info(Tools.FindPlayer(who) + " (" + Tools.GetPlayerIP(who) + ") from '" + players[who].group.GetName() + "' group joined.");
Tools.ShowMOTD(who); Tools.ShowMOTD(who);
if (HackedHealth(who)) if (HackedHealth(who))
@ -571,15 +577,14 @@ namespace TShockAPI
if (cmd == null) if (cmd == null)
{ {
Tools.SendMessage(ply, "That command does not exist, try /help", new float[] { 255, 0, 0 }); Tools.SendMessage(ply, "That command does not exist, try /help", Color.Red);
} }
else else
{ {
if (!cmd.Run(text, players[ply])) if (!cmd.Run(text, players[ply]))
{ {
Log.Info(Tools.FindPlayer(ply) + " tried to execute " + cmd.Name() + Tools.SendLogs(Tools.FindPlayer(ply) + " tried to execute " + cmd.Name(), Color.Red);
" that s/he did not have access to!"); Tools.SendMessage(ply, "You do not have access to that command.", Color.Red);
Tools.SendMessage(ply, "You do not have access to that command.", new float[] { 255, 0, 0 });
} }
} }
e.Handled = true; e.Handled = true;

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Microsoft.Xna.Framework;
using Terraria; using Terraria;
namespace TShockAPI namespace TShockAPI
@ -85,24 +86,60 @@ 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 red, float green, float blue)
{ {
for (int i = 0; i < Main.player.Length; i++) for (int i = 0; i < Main.player.Length; i++)
{ {
SendMessage(i, msg, color); SendMessage(i, msg, red, green, blue);
} }
Log.Info("Broadcast: " + msg); Log.Info("Broadcast: " + msg);
} }
[Obsolete("STOP USING THIS")]
public static void SendMessage(int ply, string msg, float[] colors)
{
SendMessage(ply, msg, colors[0],colors[1],colors[2]);
}
/// <summary>
/// Sends a message out to a single player
/// </summary>
/// <param name="ply">int socket thingy for the player from the server socket</param>
/// <param name="msg">String message</param>
public static void SendMessage(int ply, string msg, float red, float green, float blue)
{
NetMessage.SendData(0x19, ply, -1, msg, 255, red, green, blue);
}
/// <summary> /// <summary>
/// Sends a message out to a single player /// Sends a message out to a single player
/// </summary> /// </summary>
/// <param name="ply">int socket thingy for the player from the server socket</param> /// <param name="ply">int socket thingy for the player from the server socket</param>
/// <param name="msg">String message</param> /// <param name="msg">String message</param>
/// <param name="color">Float containing red, blue, and green color values</param> /// <param name="color">Float containing red, blue, and green color values</param>
public static void SendMessage(int ply, string msg, float[] color) public static void SendMessage(int ply, string msg, Color color)
{ {
NetMessage.SendData(0x19, ply, -1, msg, 255, color[0], color[1], color[2]); NetMessage.SendData(0x19, ply, -1, msg, 255, color.R, color.G, color.B);
}
/// <summary>
/// Sends message to all users with 'logs' permission.
/// </summary>
/// <param name="log"></param>
/// <param name="color"></param>
public static void SendLogs(string log, Color color)
{
Log.Info(log);
for (int i = 0; i < Main.maxPlayers; i++)
{
if (TShock.players[i] == null)
continue;
if (!TShock.players[i].group.HasPermission("logs"))
continue;
SendMessage(i, log, color);
}
} }
/// <summary> /// <summary>

View file

@ -64,7 +64,7 @@ namespace TShockAPI
Tools.SendMessage(i, "The server is out of date. To update, type /updatenow."); Tools.SendMessage(i, "The server is out of date. To update, type /updatenow.");
for (int j = 4; j < changes.Length; j++) for (int j = 4; j < changes.Length; j++)
{ {
Tools.SendMessage(i, changes[j], new float[] { 255, 0, 0 }); Tools.SendMessage(i, changes[j], 255, 0, 0);
} }
} }
} }

View file

@ -14,8 +14,8 @@
#immunetoban immunetokick editspawn #immunetoban immunetokick editspawn
#ignoregriefdetection reservedslot #ignoregriefdetection reservedslot
default null default null canwater canlava
vip default reservedslot vip default reservedslot
newadmin default kick editspawn reservedslot newadmin default kick editspawn reservedslot
admin newadmin ban unban unbanip causeevents spawnboss spawnmob tp immunetokick kill admin newadmin ban unban unbanip causeevents spawnboss spawnmob tp immunetokick kill logs
trustedadmin admin maintenance cfg cheat pvpfun ignorecheatdetection immunetoban ignoregriefdetection trustedadmin admin maintenance cfg cheat pvpfun ignorecheatdetection immunetoban ignoregriefdetection