mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Make /explode do proper build permission checking. (Thanks goodlyay)
This commit is contained in:
parent
6170b46491
commit
0690333259
@ -37,14 +37,11 @@ namespace MCGalaxy.Commands {
|
|||||||
if (args.Length == 1) {
|
if (args.Length == 1) {
|
||||||
Player who = PlayerInfo.FindMatches(p, args[0]);
|
Player who = PlayerInfo.FindMatches(p, args[0]);
|
||||||
if (who == null) return;
|
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);
|
x = (ushort)(who.pos[0] / 32);
|
||||||
y = (ushort)(who.pos[1] / 32);
|
y = (ushort)(who.pos[1] / 32);
|
||||||
z = (ushort)(who.pos[2] / 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!");
|
Player.Message(p, who.ColoredName + " %Shas been exploded!");
|
||||||
} else if (args.Length == 3) {
|
} else if (args.Length == 3) {
|
||||||
try {
|
try {
|
||||||
@ -55,15 +52,21 @@ namespace MCGalaxy.Commands {
|
|||||||
Player.Message(p, "Invalid parameters"); return;
|
Player.Message(p, "Invalid parameters"); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Level level = p.level;
|
|
||||||
if (y >= p.level.Height) y = (ushort)(p.level.Height - 1);
|
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) {
|
static bool DoExplode(Player p, Level lvl, ushort x, ushort y, ushort z) {
|
||||||
Player.Message(p, "The physics on this level are not sufficient for exploding!"); return;
|
if (lvl.physics < 3 || lvl.physics == 5) {
|
||||||
}
|
Player.Message(p, "The physics on this level are not sufficient for exploding!"); return false;
|
||||||
p.level.MakeExplosion(x, y, z, 1);
|
|
||||||
Player.Message(p, "An explosion was made at (" + x + ", " + y + ", " + z + ").");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
public override void Help(Player p) {
|
||||||
|
@ -240,11 +240,8 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, byte b, byte type, byte extType = 0) {
|
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)) {
|
if (!Block.AllowBreak(b) && !Block.canPlace(p, b) && !Block.BuildIn(b)) return false;
|
||||||
return false;
|
if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref type)) return false;
|
||||||
}
|
|
||||||
if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref type))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
string Owners = "";
|
string Owners = "";
|
||||||
bool AllowBuild = true, inZone = false;
|
bool AllowBuild = true, inZone = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user