Fixed merge
This commit is contained in:
commit
bdd55a4d06
9 changed files with 120 additions and 36 deletions
2
README.md
Normal file
2
README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
TShock is a server modification based upon High6's mod API that allows for basic server administration commands.
|
||||||
|
Constant builds: http://ci.shankshock.com/
|
||||||
|
|
@ -54,6 +54,7 @@ namespace TShockAPI
|
||||||
TShock.admincommandList.Add("kill", new CommandDelegate(Kill));
|
TShock.admincommandList.Add("kill", new CommandDelegate(Kill));
|
||||||
TShock.admincommandList.Add("help", new CommandDelegate(Help));
|
TShock.admincommandList.Add("help", new CommandDelegate(Help));
|
||||||
TShock.admincommandList.Add("slap", new CommandDelegate(Slap));
|
TShock.admincommandList.Add("slap", new CommandDelegate(Slap));
|
||||||
|
TShock.admincommandList.Add("off-nosave", new CommandDelegate(OffNoSave));
|
||||||
TShock.commandList.Add("help", new CommandDelegate(Help));
|
TShock.commandList.Add("help", new CommandDelegate(Help));
|
||||||
TShock.commandList.Add("kill", new CommandDelegate(Kill));
|
TShock.commandList.Add("kill", new CommandDelegate(Kill));
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +64,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
string plStr = args.Message.Remove(0, 5).Trim();
|
string plStr = args.Message.Remove(0, 5).Trim();
|
||||||
int ply = args.PlayerID;
|
int ply = args.PlayerID;
|
||||||
if (!(Tools.FindPlayer(plStr) == -1 || plStr == ""))
|
if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == ""))
|
||||||
{
|
{
|
||||||
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
|
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
|
||||||
{
|
{
|
||||||
|
|
@ -73,6 +74,8 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f });
|
Tools.SendMessage(ply, "You can't kick another admin!", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
|
else if (Tools.FindPlayer(plStr) == -2)
|
||||||
|
Tools.SendMessage(ply, "More than one player matched!", new float[] { 255f, 0f, 0f });
|
||||||
else
|
else
|
||||||
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
|
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +84,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
string plStr = args.Message.Remove(0, 4).Trim();
|
string plStr = args.Message.Remove(0, 4).Trim();
|
||||||
int ply = args.PlayerID;
|
int ply = args.PlayerID;
|
||||||
if (!(Tools.FindPlayer(plStr) == -1 || plStr == ""))
|
if (!(Tools.FindPlayer(plStr) == -1 || Tools.FindPlayer(plStr) == -2 || plStr == ""))
|
||||||
{
|
{
|
||||||
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
|
if (!TShock.players[Tools.FindPlayer(plStr)].IsAdmin())
|
||||||
{
|
{
|
||||||
|
|
@ -91,11 +94,19 @@ namespace TShockAPI
|
||||||
else
|
else
|
||||||
Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f });
|
Tools.SendMessage(ply, "You can't ban another admin!", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
|
else if (Tools.FindPlayer(plStr) == -2)
|
||||||
|
Tools.SendMessage(ply, "More than one player matched!", new float[] { 255f, 0f, 0f });
|
||||||
else
|
else
|
||||||
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
|
Tools.SendMessage(ply, "Invalid player!", new float[] { 255f, 0f, 0f });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Off(CommandArgs args)
|
public static void Off(CommandArgs args)
|
||||||
|
{
|
||||||
|
WorldGen.saveWorld();
|
||||||
|
Netplay.disconnect = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OffNoSave(CommandArgs args)
|
||||||
{
|
{
|
||||||
Netplay.disconnect = true;
|
Netplay.disconnect = true;
|
||||||
}
|
}
|
||||||
|
|
@ -437,9 +448,9 @@ namespace TShockAPI
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.Message.Split(' ').Length == 2)
|
if (args.Message.Split(' ').Length == 2)
|
||||||
int.TryParse(args.Message.Split(' ')[1], out page);
|
int.TryParse(args.Message.Split(' ')[1], out page);
|
||||||
if (commands.Count > (20 * (page - 1)))
|
if (commands.Count > (15 * (page - 1)))
|
||||||
{
|
{
|
||||||
for (int j = (20 * (page - 1)); j < commands.Count; j++)
|
for (int j = (15 * (page - 1)); j < commands.Count; j++)
|
||||||
{
|
{
|
||||||
if (i == 3) break;
|
if (i == 3) break;
|
||||||
if (j == commands.Count - 1)
|
if (j == commands.Count - 1)
|
||||||
|
|
@ -450,7 +461,7 @@ namespace TShockAPI
|
||||||
if ((h - 1) % 5 == 0 && (h - 1) != 0)
|
if ((h - 1) % 5 == 0 && (h - 1) != 0)
|
||||||
{
|
{
|
||||||
Tools.SendMessage(ply, tempstring.TrimEnd(new char[] { ' ', ',' }), new float[] { 255f, 255f, 0f });
|
Tools.SendMessage(ply, tempstring.TrimEnd(new char[] { ' ', ',' }), new float[] { 255f, 255f, 0f });
|
||||||
tempstring = "";
|
tempstring = "/" + commands.Keys.ElementAt(j) + ", ";
|
||||||
i++;
|
i++;
|
||||||
h++;
|
h++;
|
||||||
}
|
}
|
||||||
|
|
@ -461,7 +472,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (commands.Count > (20 * page))
|
if (commands.Count > (15 * page))
|
||||||
{ Tools.SendMessage(ply, "Type /help " + (page + 1).ToString() + " for more commands.", new float[] { 255f, 0f, 255f }); }
|
{ Tools.SendMessage(ply, "Type /help " + (page + 1).ToString() + " for more commands.", new float[] { 255f, 0f, 255f }); }
|
||||||
Tools.SendMessage(ply, "Terraria commands:");
|
Tools.SendMessage(ply, "Terraria commands:");
|
||||||
Tools.SendMessage(ply, "/playing, /p, /me", new float[] { 255f, 255f, 0f });
|
Tools.SendMessage(ply, "/playing, /p, /me", new float[] { 255f, 255f, 0f });
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,7 @@ namespace TShockAPI
|
||||||
public bool BanGriefers = true;
|
public bool BanGriefers = true;
|
||||||
public bool BanKillTileAbusers = false;
|
public bool BanKillTileAbusers = false;
|
||||||
public bool KickKillTileAbusers = false;
|
public bool KickKillTileAbusers = false;
|
||||||
|
public bool BanExplosives = true;
|
||||||
|
public bool KickExplosives = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ namespace TShockAPI
|
||||||
public static bool banGriefer = true;
|
public static bool banGriefer = true;
|
||||||
public static bool banTnt = false;
|
public static bool banTnt = false;
|
||||||
public static bool kickTnt = false;
|
public static bool kickTnt = false;
|
||||||
|
public static bool banBoom = true;
|
||||||
|
public static bool kickBoom = true;
|
||||||
|
|
||||||
public enum NPCList : int
|
public enum NPCList : int
|
||||||
{
|
{
|
||||||
WORLD_EATER = 0,
|
WORLD_EATER = 0,
|
||||||
|
|
@ -53,6 +56,8 @@ namespace TShockAPI
|
||||||
banGriefer = cfg.BanGriefers;
|
banGriefer = cfg.BanGriefers;
|
||||||
banTnt = cfg.BanKillTileAbusers;
|
banTnt = cfg.BanKillTileAbusers;
|
||||||
kickTnt = cfg.KickKillTileAbusers;
|
kickTnt = cfg.KickKillTileAbusers;
|
||||||
|
banBoom = cfg.BanExplosives;
|
||||||
|
kickBoom = cfg.KickExplosives;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteJsonConfiguration()
|
public static void WriteJsonConfiguration()
|
||||||
|
|
@ -80,6 +85,8 @@ namespace TShockAPI
|
||||||
cfg.BanGriefers = banGriefer;
|
cfg.BanGriefers = banGriefer;
|
||||||
cfg.BanKillTileAbusers = true;
|
cfg.BanKillTileAbusers = true;
|
||||||
cfg.KickKillTileAbusers = true;
|
cfg.KickKillTileAbusers = true;
|
||||||
|
cfg.BanExplosives = true;
|
||||||
|
cfg.KickExplosives = true;
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
|
||||||
TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
|
TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ namespace TShockAPI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ip"></param>
|
/// <param name="ip"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool CheckGreif(String ip)
|
public static bool Checkgrief(String ip)
|
||||||
{
|
{
|
||||||
ip = Tools.GetRealIP(ip);
|
ip = Tools.GetRealIP(ip);
|
||||||
if (!ConfigurationManager.banTnt) { return false; }
|
if (!ConfigurationManager.banTnt) { return false; }
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ namespace TShockAPI
|
||||||
public class TSPlayer
|
public class TSPlayer
|
||||||
{
|
{
|
||||||
public uint tileThreshold;
|
public uint tileThreshold;
|
||||||
public bool firstTimeHealth;
|
public bool syncHP = false;
|
||||||
public bool firstTimeMana;
|
public bool syncMP = false;
|
||||||
|
|
||||||
private int player;
|
private int player;
|
||||||
private bool admin;
|
private bool admin;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace TShockAPI
|
||||||
|
|
||||||
public static string saveDir = "./tshock/";
|
public static string saveDir = "./tshock/";
|
||||||
|
|
||||||
public static Version VersionNum = new Version(1, 5, 0, 0);
|
public static Version VersionNum = new Version(1, 5, 0, 1);
|
||||||
|
|
||||||
public static bool shownVersion = false;
|
public static bool shownVersion = false;
|
||||||
|
|
||||||
|
|
@ -199,14 +199,14 @@ namespace TShockAPI
|
||||||
life = br.ReadInt16();
|
life = br.ReadInt16();
|
||||||
maxLife = br.ReadInt16();
|
maxLife = br.ReadInt16();
|
||||||
}
|
}
|
||||||
if (!players[ply].firstTimeHealth)
|
|
||||||
{
|
|
||||||
players[ply].firstTimeHealth = true;
|
|
||||||
}
|
|
||||||
if (maxLife > Main.player[ply].statLifeMax + 20 || life > maxLife)
|
if (maxLife > Main.player[ply].statLifeMax + 20 || life > maxLife)
|
||||||
{
|
if (players[ply].syncHP)
|
||||||
Tools.HandleCheater(ply);
|
{
|
||||||
}
|
if (maxLife > Main.player[ply].statLifeMax + 20 || life > maxLife)
|
||||||
|
Tools.HandleCheater(ply);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
players[ply].syncHP = true;
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x2a)
|
else if (e.MsgID == 0x2a)
|
||||||
{
|
{
|
||||||
|
|
@ -218,14 +218,14 @@ namespace TShockAPI
|
||||||
mana = br.ReadInt16();
|
mana = br.ReadInt16();
|
||||||
maxmana = br.ReadInt16();
|
maxmana = br.ReadInt16();
|
||||||
}
|
}
|
||||||
if (!players[ply].firstTimeMana)
|
if (maxmana > Main.player[ply].statManaMax + 20 || mana > maxmana)
|
||||||
{
|
if (players[ply].syncMP)
|
||||||
players[ply].firstTimeMana = true;
|
{
|
||||||
}
|
if (maxmana > Main.player[ply].statManaMax + 20 || mana > maxmana)
|
||||||
else if (maxmana > Main.player[ply].statManaMax + 20 || mana > maxmana)
|
Tools.HandleCheater(ply);
|
||||||
{
|
}
|
||||||
Tools.HandleCheater(ply);
|
else
|
||||||
}
|
players[ply].syncMP = true;
|
||||||
}
|
}
|
||||||
else if (e.MsgID == 0x19)
|
else if (e.MsgID == 0x19)
|
||||||
{
|
{
|
||||||
|
|
@ -240,6 +240,45 @@ namespace TShockAPI
|
||||||
Tools.HandleCheater(ply);
|
Tools.HandleCheater(ply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (e.MsgID == 0x1B)
|
||||||
|
{
|
||||||
|
Int16 ident;
|
||||||
|
float posx;
|
||||||
|
float posy;
|
||||||
|
float velx;
|
||||||
|
float vely;
|
||||||
|
float knockback;
|
||||||
|
Int16 dmg;
|
||||||
|
byte owner;
|
||||||
|
byte type;
|
||||||
|
using (var br = new BinaryReader(new MemoryStream(e.Msg.readBuffer, e.Index, e.Length)))
|
||||||
|
{
|
||||||
|
ident = br.ReadInt16();
|
||||||
|
posx = br.ReadSingle();
|
||||||
|
posy = br.ReadSingle();
|
||||||
|
velx = br.ReadSingle();
|
||||||
|
vely = br.ReadSingle();
|
||||||
|
knockback = br.ReadSingle();
|
||||||
|
dmg = br.ReadInt16();
|
||||||
|
owner = br.ReadByte();
|
||||||
|
type = br.ReadByte();
|
||||||
|
}
|
||||||
|
if (type == 29 || type == 28)
|
||||||
|
{
|
||||||
|
if (!players[e.Msg.whoAmI].IsAdmin())
|
||||||
|
{
|
||||||
|
if (ConfigurationManager.kickBoom || ConfigurationManager.banBoom)
|
||||||
|
{
|
||||||
|
int i = e.Msg.whoAmI;
|
||||||
|
if (ConfigurationManager.banBoom)
|
||||||
|
FileTools.WriteGrief((int)i);
|
||||||
|
Tools.Kick((int)i, "Explosives was thrown.");
|
||||||
|
Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banBoom ? "banned" : "kicked") + " for throwing an explosive device.");
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGreetPlayer(int who, HandledEventArgs e)
|
void OnGreetPlayer(int who, HandledEventArgs e)
|
||||||
|
|
@ -290,9 +329,16 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
if (Main.netMode != 2) { return; }
|
if (Main.netMode != 2) { return; }
|
||||||
string ip = Tools.GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)));
|
string ip = Tools.GetRealIP((Convert.ToString(Netplay.serverSock[ply].tcpClient.Client.RemoteEndPoint)));
|
||||||
if (FileTools.CheckBanned(ip) || FileTools.CheckCheat(ip) || FileTools.CheckGreif(ip))
|
if (FileTools.CheckBanned(ip))
|
||||||
{
|
{
|
||||||
Tools.Kick(ply, "You are banned.");
|
Tools.Kick(ply, "You are banned.");
|
||||||
|
} else if (FileTools.CheckCheat(ip))
|
||||||
|
{
|
||||||
|
Tools.Kick(ply, "You were flagged for cheating.");
|
||||||
|
}
|
||||||
|
else if (FileTools.Checkgrief(ip))
|
||||||
|
{
|
||||||
|
Tools.Kick(ply, "You were flagged for griefing.");
|
||||||
}
|
}
|
||||||
if (!FileTools.OnWhitelist(ip))
|
if (!FileTools.OnWhitelist(ip))
|
||||||
{
|
{
|
||||||
|
|
@ -320,13 +366,17 @@ namespace TShockAPI
|
||||||
for (uint i = 0; i < Main.maxPlayers; i++)
|
for (uint i = 0; i < Main.maxPlayers; i++)
|
||||||
{
|
{
|
||||||
if (Main.player[i].active == false) { continue; }
|
if (Main.player[i].active == false) { continue; }
|
||||||
if (players[i].tileThreshold >= 5)
|
if (players[i].tileThreshold >= 20)
|
||||||
{
|
{
|
||||||
if (Main.player[i] != null)
|
if (Main.player[i] != null)
|
||||||
{
|
{
|
||||||
FileTools.WriteGrief((int)i);
|
if (ConfigurationManager.kickTnt || ConfigurationManager.banTnt)
|
||||||
Tools.Kick((int)i, "Kill tile abuse detected.");
|
{
|
||||||
Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse.");
|
if (ConfigurationManager.banTnt)
|
||||||
|
FileTools.WriteGrief((int)i);
|
||||||
|
Tools.Kick((int)i, "Kill tile abuse detected.");
|
||||||
|
Tools.Broadcast(Main.player[i].name + " was " + (ConfigurationManager.banTnt ? "banned" : "kicked") + " for kill tile abuse.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
players[i].tileThreshold = 0;
|
players[i].tileThreshold = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,8 @@
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>$(SolutionDir)\myass.bat</PostBuildEvent>
|
<PostBuildEvent>
|
||||||
|
</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Terraria;
|
using Terraria;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -116,7 +117,7 @@ namespace TShockAPI
|
||||||
/// <returns>int player</returns>
|
/// <returns>int player</returns>
|
||||||
public static int FindPlayer(string ply)
|
public static int FindPlayer(string ply)
|
||||||
{
|
{
|
||||||
int pl = -1;
|
/*int pl = -1;
|
||||||
for (int i = 0; i < Main.player.Length; i++)
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
{
|
{
|
||||||
if ((ply.ToLower()) == Main.player[i].name.ToLower())
|
if ((ply.ToLower()) == Main.player[i].name.ToLower())
|
||||||
|
|
@ -125,7 +126,17 @@ namespace TShockAPI
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pl;
|
return pl;*/
|
||||||
|
List<int> found = new List<int>();
|
||||||
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
|
if (Main.player[i].name.ToLower().Contains(ply.ToLower()))
|
||||||
|
found.Add(i);
|
||||||
|
if (found.Count == 1)
|
||||||
|
return found[0];
|
||||||
|
else if (found.Count > 1)
|
||||||
|
return -2;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -243,10 +254,10 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds someone to greifers.txt
|
/// Adds someone to griefers.txt
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ply">int player</param>
|
/// <param name="ply">int player</param>
|
||||||
public static void HandleGreifer(int ply)
|
public static void HandleGriefer(int ply)
|
||||||
{
|
{
|
||||||
if (!TShock.players[ply].IsAdmin())
|
if (!TShock.players[ply].IsAdmin())
|
||||||
{
|
{
|
||||||
|
|
@ -258,7 +269,7 @@ namespace TShockAPI
|
||||||
Netplay.serverSock[ply].kill = true;
|
Netplay.serverSock[ply].kill = true;
|
||||||
Netplay.serverSock[ply].Reset();
|
Netplay.serverSock[ply].Reset();
|
||||||
NetMessage.syncPlayers();
|
NetMessage.syncPlayers();
|
||||||
Tools.Broadcast(cheater + " was " + (ConfigurationManager.banCheater ? "banned " : "kicked ") + "for greifing.");
|
Tools.Broadcast(cheater + " was " + (ConfigurationManager.banGriefer ? "banned " : "kicked ") + "for griefing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue