Skip to content

Commit

Permalink
Fix UseGrass permission not checking permissions server side
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Oct 10, 2018
1 parent 127abdc commit ebafc64
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
17 changes: 0 additions & 17 deletions fCraft/Network/Player.Networking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1249,23 +1249,6 @@ bool LoginSequence()
}
}

bool CheckPlacePerm(Block block) {
switch (block) {
case Block.Air: return World.Deletable;
case Block.Grass: return Can(Permission.PlaceGrass);
case Block.Admincrete: return Can(Permission.PlaceAdmincrete);
case Block.Water:
case Block.StillWater: return Can(Permission.PlaceWater);
case Block.Lava:
case Block.StillLava: return Can(Permission.PlaceLava);
}
return true;
}

bool CheckDeletePerm(Block block) {
return block != Block.Admincrete || Can(Permission.DeleteAdmincrete);
}

internal void SendBlockPermissions() {
int max = supportsCustomBlocks ? (int)Map.MaxCustomBlockType : (int)Map.MaxLegalBlockType;
if (supportsBlockDefs) max = byte.MaxValue;
Expand Down
33 changes: 19 additions & 14 deletions fCraft/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,20 +1424,8 @@ public void Message([NotNull] byte messageType, [NotNull] string message, [NotNu
goto eventCheck;
}

// check special blocktypes
if( newBlock == Block.Admincrete && !Can( Permission.PlaceAdmincrete ) ) {
result = CanPlaceResult.BlocktypeDenied;
goto eventCheck;
} else if( (newBlock == Block.Water || newBlock == Block.StillWater) && !Can( Permission.PlaceWater ) ) {
result = CanPlaceResult.BlocktypeDenied;
goto eventCheck;
} else if( (newBlock == Block.Lava || newBlock == Block.StillLava) && !Can( Permission.PlaceLava ) ) {
result = CanPlaceResult.BlocktypeDenied;
goto eventCheck;
}

// check admincrete-related permissions
if( oldBlock == Block.Admincrete && !Can( Permission.DeleteAdmincrete ) ) {
// check blocktypes
if( !CheckPlacePerm( newBlock ) || !CheckDeletePerm( oldBlock ) ) {
result = CanPlaceResult.BlocktypeDenied;
goto eventCheck;
}
Expand Down Expand Up @@ -1487,6 +1475,23 @@ public void Message([NotNull] byte messageType, [NotNull] string message, [NotNu
return e.Result;
}

bool CheckPlacePerm( Block block ) {
switch( block ) {
case Block.Air: return World.Deletable;
case Block.Grass: return Can( Permission.PlaceGrass );
case Block.Admincrete: return Can( Permission.PlaceAdmincrete );
case Block.Water:
case Block.StillWater: return Can( Permission.PlaceWater );
case Block.Lava:
case Block.StillLava: return Can( Permission.PlaceLava );
}
return true;
}

bool CheckDeletePerm( Block block ) {
return block != Block.Admincrete || Can( Permission.DeleteAdmincrete );
}


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

0 comments on commit ebafc64

Please sign in to comment.