diff --git a/Commands/Moderation/CmdExplode.cs b/Commands/Moderation/CmdExplode.cs index b01bac7b2..50e315462 100644 --- a/Commands/Moderation/CmdExplode.cs +++ b/Commands/Moderation/CmdExplode.cs @@ -35,17 +35,14 @@ namespace MCGalaxy.Commands { ushort x, y, z; if (args.Length == 1) { - Player who = PlayerInfo.FindMatches(p, args[0]); + Player who = PlayerInfo.FindMatches(p, args[0]); if (who == null) return; - if (who.level.physics < 3 || who.level.physics == 5) { - Player.Message(p, "The physics on the player's level are not sufficient for exploding."); return; - } x = (ushort)(who.pos[0] / 32); y = (ushort)(who.pos[1] / 32); z = (ushort)(who.pos[2] / 32); - who.level.MakeExplosion(x, y, z, 1); - Player.Message(p, who.ColoredName + " %Shas been exploded!"); + if (DoExplode(p, who.level, x, y, z)) + Player.Message(p, who.ColoredName + " %Shas been exploded!"); } else if (args.Length == 3) { try { x = Convert.ToUInt16(args[0]); @@ -55,17 +52,23 @@ namespace MCGalaxy.Commands { Player.Message(p, "Invalid parameters"); return; } - Level level = p.level; if (y >= p.level.Height) y = (ushort)(p.level.Height - 1); - - if (p.level.physics < 3 || p.level.physics == 5) { - Player.Message(p, "The physics on this level are not sufficient for exploding!"); return; - } - p.level.MakeExplosion(x, y, z, 1); - Player.Message(p, "An explosion was made at (" + x + ", " + y + ", " + z + ")."); + if (DoExplode(p, p.level, x, y, z)) + Player.Message(p, "An explosion was made at {0}, {1}, {2}).", x, y, z); } } + static bool DoExplode(Player p, Level lvl, ushort x, ushort y, ushort z) { + if (lvl.physics < 3 || lvl.physics == 5) { + Player.Message(p, "The physics on this level are not sufficient for exploding!"); return false; + } + + byte old = lvl.GetTile(x, y, z); + if (!lvl.CheckAffectPermissions(p, x, y, z, old, Block.tnt, 0)) return false; + lvl.MakeExplosion(x, y, z, 1); + return true; + } + public override void Help(Player p) { Player.Message(p, "/explode - Satisfying all your exploding needs :)"); Player.Message(p, "/explode me - Explodes at your location"); diff --git a/Levels/Level.Blocks.cs b/Levels/Level.Blocks.cs index cfbffdec1..ccfa9dd26 100644 --- a/Levels/Level.Blocks.cs +++ b/Levels/Level.Blocks.cs @@ -240,11 +240,8 @@ namespace MCGalaxy { } public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, byte b, byte type, byte extType = 0) { - if (!Block.AllowBreak(b) && !Block.canPlace(p, b) && !Block.BuildIn(b)) { - return false; - } - if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref type)) - return false; + if (!Block.AllowBreak(b) && !Block.canPlace(p, b) && !Block.BuildIn(b)) return false; + if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref type)) return false; string Owners = ""; bool AllowBuild = true, inZone = false;