diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs index 75d97cee..5257e258 100644 --- a/TShockAPI/ConfigFile.cs +++ b/TShockAPI/ConfigFile.cs @@ -205,6 +205,8 @@ namespace TShockAPI [Description("Ignores all no clip checks for players")] public bool IgnoreNoClip = false; + [Description("Allow Ice placement even when user does not have canbuild")] public bool AllowIce = false; + public static ConfigFile Read(string path) { if (!File.Exists(path)) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 010ba16c..7950bb72 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -1263,7 +1263,7 @@ namespace TShockAPI return true; } - if (TShock.CheckTilePermission(args.Player, tileX, tileY)) + if (TShock.CheckTilePermission(args.Player, tileX, tileY, tiletype)) { args.Player.SendTileSquare(tileX, tileY); return true; diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index f135033a..27620793 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -1086,6 +1086,42 @@ namespace TShockAPI return false; } + public static bool CheckTilePermission( TSPlayer player, int tileX, int tileY, byte tileType ) + { + if (!player.Group.HasPermission(Permissions.canbuild) && !(TShock.Config.AllowIce && tileType == 127) ) + { + player.SendMessage("You do not have permission to build!", Color.Red); + return true; + } + if (!player.Group.HasPermission(Permissions.editspawn) && !Regions.CanBuild(tileX, tileY, player) && + Regions.InArea(tileX, tileY)) + { + player.SendMessage("Region protected from changes.", Color.Red); + return true; + } + if (Config.DisableBuild) + { + if (!player.Group.HasPermission(Permissions.editspawn)) + { + player.SendMessage("World protected from changes.", Color.Red); + return true; + } + } + if (Config.SpawnProtection) + { + if (!player.Group.HasPermission(Permissions.editspawn)) + { + var flag = CheckSpawn(tileX, tileY); + if (flag) + { + player.SendMessage("Spawn protected from changes.", Color.Red); + return true; + } + } + } + return false; + } + public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY) { if (!player.Group.HasPermission(Permissions.canbuild))