From 0975c7b6bf3207087689e12484e4e941885785a2 Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 3 Jul 2011 13:10:04 +0800 Subject: [PATCH 1/3] Changed some of the command permissions --- TShockAPI/Commands.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 51c264a0..3a4cb696 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -160,9 +160,9 @@ namespace TShockAPI { ChatCommands.Add(new Command("kill", Kill, "kill")); ChatCommands.Add(new Command("butcher", Butcher, "butcher")); - ChatCommands.Add(new Command("cheat", Item, "item", "i")); - ChatCommands.Add(new Command("cheat", Give, "give")); - ChatCommands.Add(new Command("cheat", Heal, "heal")); + ChatCommands.Add(new Command("item", Item, "item", "i")); + ChatCommands.Add(new Command("item", Give, "give")); + ChatCommands.Add(new Command("heal", Heal, "heal")); } } From 843d7b4469e183f7fff521d03082179c8c6f4d8a Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 3 Jul 2011 14:12:09 +0800 Subject: [PATCH 2/3] Chest KillTile is now subject to region protection. Non-working /buff --- TShockAPI/Commands.cs | 17 +++++++++++++++++ TShockAPI/ConfigFile.cs | 2 ++ TShockAPI/GetDataHandlers.cs | 28 ++++++++++++++++++++++++++++ TShockAPI/TSPlayer.cs | 7 +++++++ 4 files changed, 54 insertions(+) diff --git a/TShockAPI/Commands.cs b/TShockAPI/Commands.cs index 3a4cb696..d22ff51e 100755 --- a/TShockAPI/Commands.cs +++ b/TShockAPI/Commands.cs @@ -163,6 +163,7 @@ namespace TShockAPI ChatCommands.Add(new Command("item", Item, "item", "i")); ChatCommands.Add(new Command("item", Give, "give")); ChatCommands.Add(new Command("heal", Heal, "heal")); + //ChatCommands.Add(new Command("buff", Buff, "buff")); } } @@ -1662,6 +1663,22 @@ namespace TShockAPI } } + private static void Buff(CommandArgs args) + { + if (!args.Player.RealPlayer) + { + args.Player.SendMessage("You cant buff yourself!"); + return; + } + if (args.Parameters.Count > 0) + { + args.Player.SendMessage("Invalid syntax! Proper syntax: /buff", Color.Red); + return; + } + args.Player.Buff(); + args.Player.SendMessage("You have been buffed.", Color.Lime); + } + #endregion Cheat Comamnds } } diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 88f82be0..7e9db8d0 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -67,6 +67,8 @@ namespace TShockAPI public int MaximumLoginAttempts = 3; + public int[] Buffs = { 1, 2, 3, 5, 6, 9, 12, 14, 17, 18 }; + public static ConfigFile Read(string path) { if (!File.Exists(path)) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 377f736d..f68bf7f9 100755 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -493,6 +493,34 @@ namespace TShockAPI Tools.ForceKick(args.Player, string.Format("Tile Kill abuse ({0})", Main.tile[tilex, tiley].type)); return true; } + if (!args.Player.Group.HasPermission("editspawn") && RegionManager.InProtectedArea(tilex, tiley, Tools.GetPlayerIP(args.Player.Name))) + { + args.Player.SendMessage("Region protected from changes.", Color.Red); + args.Player.SendTileSquare(tilex, tiley); + return true; + } + if (TShock.Config.DisableBuild) + { + if (!args.Player.Group.HasPermission("editspawn")) + { + args.Player.SendMessage("World protected from changes.", Color.Red); + args.Player.SendTileSquare(tilex, tiley); + return true; + } + } + if (TShock.Config.SpawnProtection) + { + if (!args.Player.Group.HasPermission("editspawn")) + { + var flag = TShock.CheckSpawn(tilex, tiley); + if (flag) + { + args.Player.SendMessage("Spawn protected from changes.", Color.Red); + args.Player.SendTileSquare(tilex, tiley); + return true; + } + } + } return false; } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 90708586..9c71a615 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -257,6 +257,13 @@ namespace TShockAPI return; NetMessage.SendData((int)msgType, Index, -1, text, number, number2, number3, number4, number5); } + + public void Buff() + { + for (int i = 0; i < 10; i++) + TPlayer.buffType[i] = TShock.Config.Buffs[i]; + NetMessage.SendData(50, -1, -1, "", Index); + } } public class TSServerPlayer : TSPlayer From a10a0ce6ee032bf2d72f834118f7b6f6f88a9f5a Mon Sep 17 00:00:00 2001 From: Twitchy Date: Sun, 3 Jul 2011 18:27:57 +1200 Subject: [PATCH 3/3] Makes server save in background, stops server lag on save Keeping lag broadcast just in case --- TShockAPI/BackupManager.cs | 8 +++----- TShockAPI/TShock.cs | 5 +++-- TShockAPI/Tools.cs | 12 ++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/TShockAPI/BackupManager.cs b/TShockAPI/BackupManager.cs index d065ae61..0dfd5c1c 100644 --- a/TShockAPI/BackupManager.cs +++ b/TShockAPI/BackupManager.cs @@ -67,11 +67,9 @@ namespace TShockAPI if (worldpath != null && !Directory.Exists(worldpath)) Directory.CreateDirectory(worldpath); - //Tools.Broadcast("Server map saving, potential lag spike"); - WorldGen.saveWorld(); - - Console.WriteLine("World backed up"); - Log.Info(string.Format("World backed up ({0})", Main.worldPathName)); + Tools.Broadcast("Server map saving, potential lag spike"); + Thread SaveWorld = new Thread(Tools.SaveWorld); + SaveWorld.Start(); Main.worldPathName = worldname; } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index b43175db..279c15a0 100755 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -23,6 +23,7 @@ using System.Diagnostics; using System.IO; using System.Net; using System.Reflection; +using System.Threading; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Terraria; @@ -543,8 +544,8 @@ namespace TShockAPI { WorldSaving = true; Tools.Broadcast("Saving world, might lag.", Color.Red); - WorldGen.saveWorld(resettime); - Tools.Broadcast("World saved.", Color.LimeGreen); + Thread SaveWorld = new Thread(Tools.SaveWorld); + SaveWorld.Start(); WorldSaving = false; e.Handled = true; } diff --git a/TShockAPI/Tools.cs b/TShockAPI/Tools.cs index 7392b8db..59437414 100755 --- a/TShockAPI/Tools.cs +++ b/TShockAPI/Tools.cs @@ -101,6 +101,18 @@ namespace TShockAPI return result; } + /// + /// Saves the map data + /// + public static void SaveWorld() + { + WorldGen.saveWorld(); + + Broadcast("World Saved", Color.Yellow); + Console.WriteLine("World backed up"); + Log.Info(string.Format("World backed up ({0})", Main.worldPathName)); + } + /// /// Broadcasts a message to all players ///