public static void blockSquash(object sender, PlayerPlacingBlockEventArgs e) { try { Player player = e.Player; World world = player.World; if (null == world) { return; } lock (world.SyncRoot) { if (null != world.Map && world.IsLoaded && world.plantPhysics) { if (e.NewBlock == Block.Plant) { world.AddPhysicsTask(new PlantTask(world, ( short )e.Coords.X, ( short )e.Coords.Y, ( short )e.Coords.Z), PlantTask.GetRandomDelay()); } Vector3I z = new Vector3I(e.Coords.X, e.Coords.Y, e.Coords.Z - 1); if (world.Map.GetBlock(z) == Block.Grass && e.NewBlock != Block.Air) { world.Map.QueueUpdate(new BlockUpdate(null, z, Block.Dirt)); } else if (Physics.CanSquash(world.Map.GetBlock(z)) && e.NewBlock != Block.Air) { e.Result = CanPlaceResult.Revert; Player.RaisePlayerPlacedBlockEvent(player, world.Map, z, world.Map.GetBlock(z), e.NewBlock, BlockChangeContext.Physics); world.Map.QueueUpdate(new BlockUpdate(null, z, e.NewBlock)); } } } } catch (Exception ex) { Logger.Log(LogType.SeriousError, "BlockSquash" + ex); } }
public static void PlayerPlaced(object sender, PlayerPlacingBlockEventArgs e) { try { if (e.Player.World == null) { return; } foreach (Player p in e.Player.World.Players) { if (e.OldBlock != Block.Water && e.OldBlock != Block.Lava) { continue; } if (p.orangePortal.Contains(e.Coords) || p.bluePortal.Contains(e.Coords)) { e.Result = CanPlaceResult.Revert; } } } catch (Exception ex) { Logger.Log(LogType.SeriousError, "PlacingInPortal: " + ex); } }
private static void PlayerPlacing(object sender, PlayerPlacingBlockEventArgs e) { World world = e.Player.World; if (world.gameMode == GameMode.MineField) { e.Result = CanPlaceResult.Revert; } }
internal static CanPlaceResult RaisePlayerPlacingBlockEvent(Player player, short x, short y, short h, Block oldBlock, Block newBlock, bool manual, CanPlaceResult result) { var handler = PlayerPlacingBlock; if (handler == null) { return(result); } var e = new PlayerPlacingBlockEventArgs(player, x, y, h, oldBlock, newBlock, manual, result); handler(null, e); return(e.Result); }
static void DoClickEffect(int prob1, int prob2, PlayerPlacingBlockEventArgs e, Block target1, Block target2) { int effect = rnd.Next(100); if (effect >= prob1) { map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, target1)); } else if (effect >= prob2) { map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, target2)); } e.Result = CanPlaceResult.CTFDenied; }
static void ClickOpposingFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) { if (opposition.HasFlag) { e.Player.Message("You can't capture the opposing team's flag, " + "if you're not in posession of your own flag."); e.Result = CanPlaceResult.CTFDenied; } else { e.Result = CanPlaceResult.Allowed; e.Player.Team.HasFlag = true; e.Player.IsHoldingFlag = true; world.Players.Message("{0} &Sgot the {1}&S flag.", e.Player.ClassyName, opposition.ClassyName); } }
public static void PlayerPlacingBlock(object sender, PlayerPlacingBlockEventArgs e) { foreach (FeedData feed in e.Player.World.Feeds.Values) { for (int x = feed.StartPos.X; x <= feed.FinishPos.X; x++) { for (int y = feed.StartPos.Y; y <= feed.FinishPos.Y; y++) { for (int z = feed.StartPos.Z; z <= feed.FinishPos.Z; z++) { if (e.Coords == new Vector3I(x, y, z)) { e.Result = CanPlaceResult.Revert; } } } } } }
public static void OnPlayerPlacingBlock(object sender, PlayerPlacingBlockEventArgs e) { if (e.Context != BlockChangeContext.Manual) { return; } if (e.NewBlock != Block.GoldOre) { return; } if (e.Player.GetBind(Block.Aqua) != Block.Water) { return; } CheckHistory(e.Player, e.Coords); e.Result = CanPlaceResult.PluginDenied; }
static void ClickOwnFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) { if (!e.Player.IsHoldingFlag) { e.Player.Message("You don't have the {0}&S flag.", opposition.ClassyName); e.Result = CanPlaceResult.CTFDenied; } else { world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposition.FlagPos, opposition.FlagBlock)); CtfTeam team = e.Player.Team; team.Score++; team.HasFlag = false; e.Player.IsHoldingFlag = false; world.Players.Message("{0} &Sscored a point for {1}&S team.", e.Player.ClassyName, team.ClassyName); e.Result = CanPlaceResult.CTFDenied; Check(); } }
public static void PlayerPlacingPhysics(object sender, PlayerPlacingBlockEventArgs e) { World world = e.Player.World; if (e.Result != CanPlaceResult.Allowed) { return; } if (e.NewBlock == Block.Gold) { if (e.Context == BlockChangeContext.Manual) { if (e.Player.fireworkMode && world.fireworkPhysics) { if (world.FireworkCount > 10) { e.Result = CanPlaceResult.Revert; e.Player.Message("&WThere are too many active fireworks on this world"); return; } world.FireworkCount++; world.AddPhysicsTask(new Firework(world, e.Coords), 300); } } } if (e.NewBlock == Block.TNT) { if (world.tntPhysics) { if (e.Context == BlockChangeContext.Manual) { lock (world.SyncRoot) { world.AddPhysicsTask(new TNTTask(world, e.Coords, e.Player, false, true), 3000); return; } } } } if (e.NewBlock == Block.Sand || e.NewBlock == Block.Gravel) { if (e.Context == BlockChangeContext.Manual) { if (world.sandPhysics) { lock (world.SyncRoot) { world.AddPhysicsTask(new SandTask(world, e.Coords, e.NewBlock), 150); return; } } } } if (Physics.CanFloat(e.NewBlock)) { if (world.waterPhysics) { if (e.Context == BlockChangeContext.Manual) { world.AddPhysicsTask(new BlockFloat(world, e.Coords, e.NewBlock), 200); return; } } } if (!Physics.CanFloat(e.NewBlock) && e.NewBlock != Block.Air && e.NewBlock != Block.Water && e.NewBlock != Block.Lava && e.NewBlock != Block.BrownMushroom && e.NewBlock != Block.RedFlower && e.NewBlock != Block.RedMushroom && e.NewBlock != Block.YellowFlower && e.NewBlock != Block.Plant) { if (e.Context == BlockChangeContext.Manual) { if (world.waterPhysics) { world.AddPhysicsTask(new BlockSink(world, e.Coords, e.NewBlock), 200); return; } } } }
static void PlayerPlacing(object sender, PlayerPlacingBlockEventArgs e) { if (e.Player.World != world || e.Result != CanPlaceResult.Allowed) { return; } if (e.NewBlock == Opposition(e.Player.Team).FlagBlock) { e.Player.Message("You cannot place {0}&S blocks, you are on the {1}&S Team.", Opposition(e.Player.Team).ClassyName, e.Player.Team.ClassyName); e.Result = CanPlaceResult.CTFDenied; } else if (e.NewBlock == Block.Lava || e.NewBlock == Block.Water) { if (e.Context == BlockChangeContext.Manual) { e.Player.Message("You are not allowed to place water or lava blocks in CTF."); } e.Result = CanPlaceResult.CTFDenied; } else if (e.Context != BlockChangeContext.Manual) { e.Result = CanPlaceResult.CTFDenied; } else { if ((e.Coords == RedTeam.FlagPos || e.Coords == BlueTeam.FlagPos) && (e.NewBlock == RedTeam.FlagBlock || e.NewBlock == BlueTeam.FlagBlock || e.NewBlock == Block.Air)) { if (e.Coords == BlueTeam.FlagPos && e.Player.Team == RedTeam) { ClickOpposingFlag(e, BlueTeam); } else if (e.Coords == RedTeam.FlagPos && e.Player.Team == BlueTeam) { ClickOpposingFlag(e, RedTeam); } else if (e.Coords == RedTeam.FlagPos && e.Player.Team == RedTeam) { ClickOwnFlag(e, BlueTeam); } else if (e.Coords == BlueTeam.FlagPos && e.Player.Team == BlueTeam) { ClickOwnFlag(e, RedTeam); } } else if (e.Coords == RedTeam.FlagPos || e.Coords == BlueTeam.FlagPos) { e.Result = CanPlaceResult.CTFDenied; } else if (e.OldBlock == RedTeam.FlagBlock || e.OldBlock == BlueTeam.FlagBlock) { DoClickEffect(99, 75, e, Block.CobbleSlab, Block.Stone); } else if (e.OldBlock == Block.Stone) { DoClickEffect(99, 75, e, Block.Gravel, Block.Cobblestone); } else if (e.OldBlock == Block.Cobblestone) { DoClickEffect(99, 75, e, Block.Air, Block.Gravel); } else if (e.OldBlock == Block.Gravel) { DoClickEffect(75, 1000, e, Block.Air, Block.None); } else if (e.OldBlock == Block.Grass) { DoClickEffect(25, 1000, e, Block.Dirt, Block.None); } else if (e.OldBlock == Block.Water) { e.Result = CanPlaceResult.CTFDenied; } else if (e.NewBlock == Block.TNT) { HandleTNT(e.Player, e.Coords); e.Result = CanPlaceResult.CTFDenied; world.Map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, Block.Air)); world.Map.ProcessUpdates(); } else { e.Result = CanPlaceResult.Allowed; } } if (world != null) { world.Map.ProcessUpdates(); } }
public static void OnPlayerPlacingBlock(object sender, PlayerPlacingBlockEventArgs e) { if (e.Context != BlockChangeContext.Manual && e.Context != BlockChangeContext.Replaced) { return; } if (e.Result != CanPlaceResult.ZoneDenied) { return; } if (e.Player.Info.Rank != RankManager.LowestRank) { return; } if (e.NewBlock != Block.Air) { return; } Player player = e.Player; TrapInfo ptrapinfo; if (trapinfo.ContainsKey(player)) { ptrapinfo = trapinfo[player]; } else { ptrapinfo = trapinfo[player] = new TrapInfo(); } Zone deniedZone = player.World.Map.Zones.FindDenied(e.Coords, player); if (deniedZone == null) { return; } PlayerExceptions playerList = deniedZone.ExceptionList; bool trapzone = false; for (int i = 0; i < playerList.Included.Length; i++) { if (playerList.Included[i].Name == "trap") { trapzone = true; break; } } if (!trapzone) { return; } if (DateTime.UtcNow.Subtract(ptrapinfo.timer).TotalMinutes >= 5) { ptrapinfo.timer = DateTime.UtcNow; ptrapinfo.count = 0; } ptrapinfo.count++; if (ptrapinfo.count > 20) { player.Info.BanIP(Player.Console, "Griefing Detection (" + deniedZone.Name + ")", true, true); } e.Result = CanPlaceResult.PluginDeniedNoUpdate; }