Merge branch 'master' of github.com:TShock/TShock
Conflicts: TShockAPI/TShock.cs
This commit is contained in:
commit
3b250f4353
6 changed files with 81 additions and 36 deletions
|
|
@ -223,6 +223,7 @@ namespace TShockAPI
|
||||||
commands.Add(new Command("auth", "", AuthToken));
|
commands.Add(new Command("auth", "", AuthToken));
|
||||||
commands.Add(new Command("me", "", ThirdPerson));
|
commands.Add(new Command("me", "", ThirdPerson));
|
||||||
commands.Add(new Command("p", "", PartyChat));
|
commands.Add(new Command("p", "", PartyChat));
|
||||||
|
commands.Add(new Command("rules", "", Rules));
|
||||||
commands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild));
|
commands.Add(new Command("antibuild", "editspawn", ToggleAntiBuild));
|
||||||
if (ConfigurationManager.distributationAgent != "terraria-online")
|
if (ConfigurationManager.distributationAgent != "terraria-online")
|
||||||
{
|
{
|
||||||
|
|
@ -237,6 +238,11 @@ namespace TShockAPI
|
||||||
|
|
||||||
#region Command Methods
|
#region Command Methods
|
||||||
|
|
||||||
|
public static void Rules(CommandArgs args)
|
||||||
|
{
|
||||||
|
Tools.ShowFileToUser(args.PlayerID, "rules.txt");
|
||||||
|
}
|
||||||
|
|
||||||
public static void ToggleAntiBuild(CommandArgs args)
|
public static void ToggleAntiBuild(CommandArgs args)
|
||||||
{
|
{
|
||||||
Tools.SendMessage(args.PlayerID, "Toggled world anti-build.");
|
Tools.SendMessage(args.PlayerID, "Toggled world anti-build.");
|
||||||
|
|
@ -297,14 +303,14 @@ namespace TShockAPI
|
||||||
ConfigurationManager.banTnt, ConfigurationManager.kickTnt,
|
ConfigurationManager.banTnt, ConfigurationManager.kickTnt,
|
||||||
ConfigurationManager.banBoom, ConfigurationManager.kickBoom);
|
ConfigurationManager.banBoom, ConfigurationManager.kickBoom);
|
||||||
Tools.SendMessage(ply, lineTwo, Color.Yellow);
|
Tools.SendMessage(ply, lineTwo, Color.Yellow);
|
||||||
string lineThree = string.Format("InvMultiplier : {0}, ProtectS : {1}, ProtectR : {2}, DMS : {3}, SpawnRate {4}",
|
string lineThree = string.Format("RangeChecks : {0}, DisableBuild : {1}, ProtectSpawn : {2}, ProtectRadius : {3}",
|
||||||
ConfigurationManager.invasionMultiplier, ConfigurationManager.spawnProtect,
|
ConfigurationManager.rangeChecks, ConfigurationManager.disableBuild,
|
||||||
ConfigurationManager.spawnProtectRadius, ConfigurationManager.defaultMaxSpawns,
|
ConfigurationManager.spawnProtect, ConfigurationManager.spawnProtectRadius);
|
||||||
ConfigurationManager.defaultSpawnRate);
|
|
||||||
Tools.SendMessage(ply, lineThree, Color.Yellow);
|
Tools.SendMessage(ply, lineThree, Color.Yellow);
|
||||||
string lineFour = string.Format("MaxSlots : {0}, RangeChecks : {1}, SpamChecks : {2}",
|
string lineFour = string.Format("MaxSlots : {0}, SpamChecks : {1}, InvMultiplier : {2}, DMS : {3}, SpawnRate {4}",
|
||||||
ConfigurationManager.maxSlots, ConfigurationManager.rangeChecks,
|
ConfigurationManager.maxSlots, ConfigurationManager.spamChecks,
|
||||||
ConfigurationManager.spamChecks);
|
ConfigurationManager.invasionMultiplier, ConfigurationManager.defaultMaxSpawns,
|
||||||
|
ConfigurationManager.defaultSpawnRate);
|
||||||
Tools.SendMessage(ply, lineFour, Color.Yellow);
|
Tools.SendMessage(ply, lineFour, Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1006,13 +1012,11 @@ namespace TShockAPI
|
||||||
Tools.SendMessage(adminplr, "Invalid player!", Color.Red);
|
Tools.SendMessage(adminplr, "Invalid player!", Color.Red);
|
||||||
else if (player == -2)
|
else if (player == -2)
|
||||||
Tools.SendMessage(adminplr, "More than one player matched!", Color.Red);
|
Tools.SendMessage(adminplr, "More than one player matched!", Color.Red);
|
||||||
else if (player == adminplr)
|
|
||||||
Tools.SendMessage(adminplr, "Can't kill yourself!", Color.Red);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Tools.SendMessage(adminplr, string.Format("You just killed {0}!", Tools.FindPlayer(player)));
|
Tools.SendMessage(adminplr, string.Format("You just killed {0}!", Tools.FindPlayer(player)));
|
||||||
Tools.SendMessage(player, string.Format("{0} just killed you!", Tools.FindPlayer(adminplr)));
|
Tools.SendMessage(player, string.Format("{0} just killed you!", Tools.FindPlayer(adminplr)));
|
||||||
TShock.KillMe(player);
|
TShock.PlayerDamage(player, 999999);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1044,7 +1048,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
int.TryParse(args.Parameters[1], out damage);
|
int.TryParse(args.Parameters[1], out damage);
|
||||||
}
|
}
|
||||||
NetMessage.SendData(26, -1, -1, "", player, ((new Random()).Next(-1, 1)), damage, (float)0);
|
TShock.PlayerDamage(player, damage);
|
||||||
Tools.Broadcast(string.Format("{0} slapped {1} for {2} damage.",
|
Tools.Broadcast(string.Format("{0} slapped {1} for {2} damage.",
|
||||||
Tools.FindPlayer(adminplr), Tools.FindPlayer(player), damage));
|
Tools.FindPlayer(adminplr), Tools.FindPlayer(player), damage));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,7 @@ namespace TShockAPI
|
||||||
public bool RangeChecks = true;
|
public bool RangeChecks = true;
|
||||||
public bool SpamChecks = false;
|
public bool SpamChecks = false;
|
||||||
public bool DisableBuild = false;
|
public bool DisableBuild = false;
|
||||||
|
public float[] AdminChatRGB = {255, 0, 0};
|
||||||
|
public string AdminChatPrefix = "(Admin) ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,8 @@ namespace TShockAPI
|
||||||
public static int maxSlots = 8;
|
public static int maxSlots = 8;
|
||||||
public static bool spamChecks = false;
|
public static bool spamChecks = false;
|
||||||
public static bool disableBuild = false;
|
public static bool disableBuild = false;
|
||||||
|
public static float[] adminChatRGB = {255, 0, 0};
|
||||||
|
public static string adminChatPrefix = "(Admin) ";
|
||||||
|
|
||||||
public enum NPCList
|
public enum NPCList
|
||||||
{
|
{
|
||||||
|
|
@ -90,6 +92,8 @@ namespace TShockAPI
|
||||||
disableBuild = cfg.DisableBuild;
|
disableBuild = cfg.DisableBuild;
|
||||||
NPC.maxSpawns = defaultMaxSpawns;
|
NPC.maxSpawns = defaultMaxSpawns;
|
||||||
NPC.defaultSpawnRate = defaultSpawnRate;
|
NPC.defaultSpawnRate = defaultSpawnRate;
|
||||||
|
adminChatRGB = cfg.AdminChatRGB;
|
||||||
|
adminChatPrefix = cfg.AdminChatPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteJsonConfiguration()
|
public static void WriteJsonConfiguration()
|
||||||
|
|
@ -121,6 +125,8 @@ namespace TShockAPI
|
||||||
cfg.RangeChecks = rangeChecks;
|
cfg.RangeChecks = rangeChecks;
|
||||||
cfg.SpamChecks = spamChecks;
|
cfg.SpamChecks = spamChecks;
|
||||||
cfg.DisableBuild = disableBuild;
|
cfg.DisableBuild = disableBuild;
|
||||||
|
cfg.AdminChatRGB = adminChatRGB;
|
||||||
|
cfg.AdminChatPrefix = adminChatPrefix;
|
||||||
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");
|
||||||
tr.Write(json);
|
tr.Write(json);
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,14 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(SaveDir);
|
Directory.CreateDirectory(SaveDir);
|
||||||
}
|
}
|
||||||
|
if (!File.Exists(SaveDir + "rules.txt"))
|
||||||
|
{
|
||||||
|
CreateFile(SaveDir + "rules.txt");
|
||||||
|
TextWriter tw = new StreamWriter(SaveDir + "rules.txt");
|
||||||
|
tw.WriteLine("Respect the admins!");
|
||||||
|
tw.WriteLine("Don't use TNT!");
|
||||||
|
tw.Close();
|
||||||
|
}
|
||||||
if (!File.Exists(SaveDir + "motd.txt"))
|
if (!File.Exists(SaveDir + "motd.txt"))
|
||||||
{
|
{
|
||||||
CreateFile(SaveDir + "motd.txt");
|
CreateFile(SaveDir + "motd.txt");
|
||||||
|
|
|
||||||
|
|
@ -339,25 +339,25 @@ namespace TShockAPI
|
||||||
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
return Tools.HandleGriefer(e.Msg.whoAmI, "Placing impossible to place blocks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == 0 || type == 1)
|
if (ConfigurationManager.disableBuild)
|
||||||
{
|
{
|
||||||
if (ConfigurationManager.disableBuild)
|
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
||||||
{
|
{
|
||||||
if (!players[e.Msg.whoAmI].group.HasPermission("editspawn"))
|
Tools.SendMessage(e.Msg.whoAmI, "World protected from changes.", Color.Red);
|
||||||
{
|
RevertPlayerChanges(e.Msg.whoAmI, type, x, y);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
if (flag)
|
||||||
{
|
{
|
||||||
var flag = CheckSpawn(x, y);
|
Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red);
|
||||||
if (flag)
|
RevertPlayerChanges(e.Msg.whoAmI, type, x, y);
|
||||||
{
|
return true;
|
||||||
Tools.SendMessage(e.Msg.whoAmI, "Spawn protected from changes.", Color.Red);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -371,6 +371,11 @@ namespace TShockAPI
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void RevertPlayerChanges(int player, byte action, int x, int y)
|
||||||
|
{
|
||||||
|
NetMessage.SendData(20, player, -1, "", 10, (float)(x - 5), (float)(y - 5), 0f);
|
||||||
|
}
|
||||||
|
|
||||||
bool HandleTogglePvp(MemoryStream data, GetDataEventArgs e)
|
bool HandleTogglePvp(MemoryStream data, GetDataEventArgs e)
|
||||||
{
|
{
|
||||||
int id = data.ReadByte();
|
int id = data.ReadByte();
|
||||||
|
|
@ -595,6 +600,13 @@ namespace TShockAPI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (players[ply].group.HasPermission("adminchat") && !text.StartsWith("/"))
|
||||||
|
{
|
||||||
|
Tools.Broadcast(ConfigurationManager.adminChatPrefix + "<" + Main.player[ply].name + "> " + text, ConfigurationManager.adminChatRGB);
|
||||||
|
e.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int x = (int)Main.player[ply].position.X;
|
int x = (int)Main.player[ply].position.X;
|
||||||
int y = (int)Main.player[ply].position.Y;
|
int y = (int)Main.player[ply].position.Y;
|
||||||
|
|
||||||
|
|
@ -833,10 +845,9 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void KillMe(int plr)
|
public static void PlayerDamage(int plr, int damage)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Main.player.Length; i++)
|
NetMessage.SendData(26, -1, -1, "", plr, ((new Random()).Next(-1, 1)), damage, (float)0);
|
||||||
NetMessage.SendData(44, i, -1, "", plr, 1, 9999999, (float)0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?)
|
//TODO : Notify the player if there is more than one match. (or do we want a First() kinda thing?)
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,16 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Main.player.Length; i++)
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
{
|
{
|
||||||
SendMessage(i, msg, red, green, blue);
|
SendMessage(i, msg, Tools.Clamp(red, 255, 0), Tools.Clamp(green, 255, 0), Tools.Clamp(blue, 255, 0));
|
||||||
|
}
|
||||||
|
Log.Info(string.Format("Broadcast: {0}", msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Broadcast(string msg, float[] colors)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Main.player.Length; i++)
|
||||||
|
{
|
||||||
|
SendMessage(i, msg, Tools.Clamp(colors[0], 255, 0), Tools.Clamp(colors[1], 255, 0), Tools.Clamp(colors[2], 255, 0));
|
||||||
}
|
}
|
||||||
Log.Info(string.Format("Broadcast: {0}", msg));
|
Log.Info(string.Format("Broadcast: {0}", msg));
|
||||||
}
|
}
|
||||||
|
|
@ -342,15 +351,20 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
[Obsolete("Use ShowFileToUser(int ply, string file) instead.")]
|
||||||
/// <summary>
|
|
||||||
/// Shows a MOTD to the player
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="ply">int player</param>
|
|
||||||
public static void ShowMOTD(int ply)
|
public static void ShowMOTD(int ply)
|
||||||
|
{
|
||||||
|
ShowFileToUser(ply, "motd.txt");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Shows a file to the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ply">int player</param>
|
||||||
|
/// <param name="file">string filename reletave to savedir</param>
|
||||||
|
public static void ShowFileToUser(int ply, string file)
|
||||||
{
|
{
|
||||||
string foo = "";
|
string foo = "";
|
||||||
TextReader tr = new StreamReader(FileTools.SaveDir + "motd.txt");
|
TextReader tr = new StreamReader(FileTools.SaveDir + file);
|
||||||
while ((foo = tr.ReadLine()) != null)
|
while ((foo = tr.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
foo = foo.Replace("%map%", Main.worldName);
|
foo = foo.Replace("%map%", Main.worldName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue