Skip to content
Permalink
Browse files

Fix UseGrass permission not checking permissions server side

  • Loading branch information...
UnknownShadow200 committed Oct 10, 2018
1 parent 127abdc commit ebafc6449899fd45008617de133759fa8c9edc34
Showing with 19 additions and 31 deletions.
  1. +0 −17 fCraft/Network/Player.Networking.cs
  2. +19 −14 fCraft/Player/Player.cs
@@ -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;
@@ -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;
}
@@ -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.

0 comments on commit ebafc64

Please sign in to comment.
You can’t perform that action at this time.