Make /explode do proper build permission checking. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-08-07 15:22:23 +10:00
parent 6170b46491
commit 0690333259
2 changed files with 18 additions and 18 deletions

View File

@ -37,14 +37,11 @@ namespace MCGalaxy.Commands {
if (args.Length == 1) {
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);
if (DoExplode(p, who.level, x, y, z))
Player.Message(p, who.ColoredName + " %Shas been exploded!");
} else if (args.Length == 3) {
try {
@ -55,15 +52,21 @@ 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 (DoExplode(p, p.level, x, y, z))
Player.Message(p, "An explosion was made at {0}, {1}, {2}).", x, y, z);
}
}
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 + ").");
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) {

View File

@ -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;