public static CheckSpawn ( int x, int y ) : bool | ||
x | int | x - The x coordinate to check. |
y | int | y - The y coordinate to check. |
Résultat | bool |
public static bool CheckTilePermission(TSPlayer player, int tileX, int tileY) { if (!player.Group.HasPermission(Permissions.canbuild)) { player.SendMessage("You do not have permission to build!", Color.Red); return(true); } if (!player.Group.HasPermission(Permissions.editspawn) && !TShock.Regions.CanBuild(tileX, tileY, player) && TShock.Regions.InArea(tileX, tileY)) { player.SendMessage("Region protected from changes.", Color.Red); return(true); } if (TShock.Config.DisableBuild) { if (!player.Group.HasPermission(Permissions.editspawn)) { player.SendMessage("World protected from changes.", Color.Red); return(true); } } if (TShock.Config.SpawnProtection) { if (!player.Group.HasPermission(Permissions.editspawn)) { var flag = TShock.CheckSpawn(tileX, tileY); if (flag) { player.SendMessage("Spawn protected from changes.", Color.Red); return(true); } } } return(false); }
private static bool HandleTileKill(GetDataHandlerArgs args) { int tilex = args.Data.ReadInt32(); int tiley = args.Data.ReadInt32(); if (tilex < 0 || tilex >= Main.maxTilesX || tiley < 0 || tiley >= Main.maxTilesY) { return(false); } if (Main.tile[tilex, tiley].type != 0x15 && (!Tools.MaxChests() && Main.tile[tilex, tiley].type != 0)) //Chest { Log.Debug(string.Format("TileKill(TileXY:{0}_{1}, Type:{2})", tilex, tiley, Main.tile[tilex, tiley].type)); Tools.ForceKick(args.Player, string.Format(TShock.Config.TileKillAbuseReason, Main.tile[tilex, tiley].type)); return(true); } if (!args.Player.Group.HasPermission(Permissions.canbuild)) { args.Player.SendMessage("You do not have permission to build!", Color.Red); args.Player.SendTileSquare(tilex, tiley); return(true); } if (!args.Player.Group.HasPermission(Permissions.editspawn) && !TShock.Regions.CanBuild(tilex, tiley, args.Player) && TShock.Regions.InArea(tilex, tiley)) { 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(Permissions.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(Permissions.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); }
private static bool HandleLiquidSet(GetDataHandlerArgs args) { int x = args.Data.ReadInt32(); int y = args.Data.ReadInt32(); byte liquid = args.Data.ReadInt8(); bool lava = args.Data.ReadBoolean(); //The liquid was picked up. if (liquid == 0) { return(false); } int plyX = Math.Abs(args.Player.TileX); int plyY = Math.Abs(args.Player.TileY); int tileX = Math.Abs(x); int tileY = Math.Abs(y); bool bucket = false; for (int i = 0; i < 44; i++) { if (args.TPlayer.inventory[i].type >= 205 && args.TPlayer.inventory[i].type <= 207) { bucket = true; break; } } if (!args.Player.Group.HasPermission(Permissions.canbuild)) { args.Player.SendMessage("You do not have permission to build!", Color.Red); args.Player.SendTileSquare(x, y); return(true); } if (lava && !args.Player.Group.HasPermission(Permissions.canlava)) { args.Player.SendMessage("You do not have permission to use lava", Color.Red); Tools.SendLogs(string.Format("{0} tried using lava", args.Player.Name), Color.Red); args.Player.SendTileSquare(x, y); return(true); } if (!lava && !args.Player.Group.HasPermission(Permissions.canwater)) { args.Player.SendMessage("You do not have permission to use water", Color.Red); Tools.SendLogs(string.Format("{0} tried using water", args.Player.Name), Color.Red); args.Player.SendTileSquare(x, y); 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, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), liquid)); return(Tools.HandleGriefer(args.Player, TShock.Config.IllogicalLiquidUseReason));; } if (TShock.Config.RangeChecks && ((Math.Abs(plyX - tileX) > 32) || (Math.Abs(plyY - tileY) > 32))) { Log.Debug(string.Format("Liquid(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Amount:{6})", plyX, plyY, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), liquid)); return(Tools.HandleGriefer(args.Player, TShock.Config.LiquidAbuseReason)); } if (TShock.Config.SpawnProtection) { if (!args.Player.Group.HasPermission(Permissions.editspawn)) { var flag = TShock.CheckSpawn(x, y); if (flag) { args.Player.SendMessage("The spawn is protected!", Color.Red); args.Player.SendTileSquare(x, y); return(true); } } } return(false); }
private static bool HandleTile(GetDataHandlerArgs args) { byte type = args.Data.ReadInt8(); int x = args.Data.ReadInt32(); int y = args.Data.ReadInt32(); byte tiletype = args.Data.ReadInt8(); if (args.Player.AwaitingName) { if (TShock.Regions.InAreaRegionName(x, y) == null) { args.Player.SendMessage("Region is not protected", Color.Yellow); } else { args.Player.SendMessage("Region Name: " + TShock.Regions.InAreaRegionName(x, y), Color.Yellow); } args.Player.SendTileSquare(x, y); args.Player.AwaitingName = false; return(true); } if (args.Player.AwaitingTempPoint > 0) { args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].X = x; args.Player.TempPoints[args.Player.AwaitingTempPoint - 1].Y = y; args.Player.SendMessage("Set Temp Point " + args.Player.AwaitingTempPoint, Color.Yellow); args.Player.SendTileSquare(x, y); args.Player.AwaitingTempPoint = 0; return(true); } if (!args.Player.Group.HasPermission(Permissions.canbuild)) { if (!args.Player.HasBeenSpammedWithBuildMessage) { args.Player.SendMessage("You do not have permission to build!", Color.Red); args.Player.HasBeenSpammedWithBuildMessage = true; } args.Player.SendTileSquare(x, y); return(true); } if (type == 1 || type == 3) { int plyX = Math.Abs(args.Player.TileX); int plyY = Math.Abs(args.Player.TileY); int tileX = Math.Abs(x); int tileY = Math.Abs(y); if (tiletype >= ((type == 1) ? Main.maxTileSets : Main.maxWallTypes)) { Tools.HandleGriefer(args.Player, string.Format(TShock.Config.TileAbuseReason, "Invalid tile type")); return(true); } if (TShock.Config.RangeChecks && ((Math.Abs(plyX - tileX) > 32) || (Math.Abs(plyY - tileY) > 32))) { if (!(type == 1 && ((tiletype == 0 && args.Player.TPlayer.selectedItem == 114) || (tiletype == 53 && args.Player.TPlayer.selectedItem == 266)))) { Log.Debug(string.Format("TilePlaced(PlyXY:{0}_{1}, TileXY:{2}_{3}, Result:{4}_{5}, Type:{6})", plyX, plyY, tileX, tileY, Math.Abs(plyX - tileX), Math.Abs(plyY - tileY), tiletype)); return(Tools.HandleGriefer(args.Player, TShock.Config.RangeCheckBanReason)); } } if (tiletype == 48 && !args.Player.Group.HasPermission(Permissions.canspike)) { args.Player.SendMessage("You do not have permission to place spikes.", Color.Red); Tools.SendLogs(string.Format("{0} tried to place spikes", args.Player.Name), Color.Red); args.Player.SendTileSquare(x, y); return(true); } if (type == 1 && tiletype == 21 && Tools.MaxChests()) { args.Player.SendMessage("Reached world's max chest limit, unable to place more!", Color.Red); Log.Info("Reached world's chest limit, unable to place more."); args.Player.SendTileSquare(x, y); return(true); } } if (!args.Player.Group.HasPermission(Permissions.editspawn) && !TShock.Regions.CanBuild(x, y, args.Player) && TShock.Regions.InArea(x, y)) { if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000) { args.Player.SendMessage("Region Name: " + TShock.Regions.InAreaRegionName(x, y) + " protected from changes.", Color.Red); args.Player.LastTileChangeNotify = DateTime.UtcNow; } args.Player.SendTileSquare(x, y); return(true); } if (TShock.Config.DisableBuild) { if (!args.Player.Group.HasPermission(Permissions.editspawn)) { if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000) { args.Player.SendMessage("World protected from changes.", Color.Red); args.Player.LastTileChangeNotify = DateTime.UtcNow; } args.Player.SendTileSquare(x, y); return(true); } } if (TShock.Config.SpawnProtection) { if (!args.Player.Group.HasPermission(Permissions.editspawn)) { var flag = TShock.CheckSpawn(x, y); if (flag) { if ((DateTime.UtcNow - args.Player.LastTileChangeNotify).TotalMilliseconds > 1000) { args.Player.SendMessage("Spawn protected from changes.", Color.Red); args.Player.LastTileChangeNotify = DateTime.UtcNow; } args.Player.SendTileSquare(x, y); return(true); } } } if (type == 0 && BlacklistTiles[Main.tile[x, y].type] && args.Player.Active) { args.Player.TileThreshold++; var coords = new Vector2(x, y); if (!args.Player.TilesDestroyed.ContainsKey(coords)) { args.Player.TilesDestroyed.Add(coords, Main.tile[x, y].Data); } } if ((DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds < 1000) { args.Player.SendMessage("Please wait another " + (1000 - (DateTime.UtcNow - args.Player.LastExplosive).TotalMilliseconds) + " milliseconds before placing/destroying tiles", Color.Red); args.Player.SendTileSquare(x, y); return(true); } return(false); }