Skip to content

Commit ebafc64

Browse files
Fix UseGrass permission not checking permissions server side
1 parent 127abdc commit ebafc64

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

fCraft/Network/Player.Networking.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,23 +1249,6 @@ internal void SendNewEntities(World world) {
12491249
}
12501250
}
12511251

1252-
bool CheckPlacePerm(Block block) {
1253-
switch (block) {
1254-
case Block.Air: return World.Deletable;
1255-
case Block.Grass: return Can(Permission.PlaceGrass);
1256-
case Block.Admincrete: return Can(Permission.PlaceAdmincrete);
1257-
case Block.Water:
1258-
case Block.StillWater: return Can(Permission.PlaceWater);
1259-
case Block.Lava:
1260-
case Block.StillLava: return Can(Permission.PlaceLava);
1261-
}
1262-
return true;
1263-
}
1264-
1265-
bool CheckDeletePerm(Block block) {
1266-
return block != Block.Admincrete || Can(Permission.DeleteAdmincrete);
1267-
}
1268-
12691252
internal void SendBlockPermissions() {
12701253
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
12711254
if (supportsBlockDefs) max = byte.MaxValue;

fCraft/Player/Player.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,20 +1424,8 @@ public CanPlaceResult CanPlace( [NotNull] Map map, Vector3I coords, Block newBlo
14241424
goto eventCheck;
14251425
}
14261426

1427-
// check special blocktypes
1428-
if( newBlock == Block.Admincrete && !Can( Permission.PlaceAdmincrete ) ) {
1429-
result = CanPlaceResult.BlocktypeDenied;
1430-
goto eventCheck;
1431-
} else if( (newBlock == Block.Water || newBlock == Block.StillWater) && !Can( Permission.PlaceWater ) ) {
1432-
result = CanPlaceResult.BlocktypeDenied;
1433-
goto eventCheck;
1434-
} else if( (newBlock == Block.Lava || newBlock == Block.StillLava) && !Can( Permission.PlaceLava ) ) {
1435-
result = CanPlaceResult.BlocktypeDenied;
1436-
goto eventCheck;
1437-
}
1438-
1439-
// check admincrete-related permissions
1440-
if( oldBlock == Block.Admincrete && !Can( Permission.DeleteAdmincrete ) ) {
1427+
// check blocktypes
1428+
if( !CheckPlacePerm( newBlock ) || !CheckDeletePerm( oldBlock ) ) {
14411429
result = CanPlaceResult.BlocktypeDenied;
14421430
goto eventCheck;
14431431
}
@@ -1487,6 +1475,23 @@ public CanPlaceResult CanPlace( [NotNull] Map map, Vector3I coords, Block newBlo
14871475
return e.Result;
14881476
}
14891477

1478+
bool CheckPlacePerm( Block block ) {
1479+
switch( block ) {
1480+
case Block.Air: return World.Deletable;
1481+
case Block.Grass: return Can( Permission.PlaceGrass );
1482+
case Block.Admincrete: return Can( Permission.PlaceAdmincrete );
1483+
case Block.Water:
1484+
case Block.StillWater: return Can( Permission.PlaceWater );
1485+
case Block.Lava:
1486+
case Block.StillLava: return Can( Permission.PlaceLava );
1487+
}
1488+
return true;
1489+
}
1490+
1491+
bool CheckDeletePerm( Block block ) {
1492+
return block != Block.Admincrete || Can( Permission.DeleteAdmincrete );
1493+
}
1494+
14901495

14911496
/// <summary> Whether this player can currently see another player as being online.
14921497
/// Players can always see themselves. Super players (e.g. Console) can see all.

0 commit comments

Comments
 (0)