Skip to content

Commit

Permalink
Mines: checking access. This change breaks down the access checks to …
Browse files Browse the repository at this point in the history
…see if a player has access to a given mine so it can be properly logged when in debug mode.

It's been a problem trying to figure out why some events would work or wouldn't, now this will help identify access related conditions.  Example is the use of mine bombs.
  • Loading branch information
rbluer committed Sep 28, 2024
1 parent 95e4c3a commit 1478e95
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.19d 2024-09-28


* **Mines: checking access. This change breaks down the access checks to see if a player has access to a given mine so it can be properly logged when in debug mode.**
It's been a problem trying to figure out why some events would work or wouldn't, now this will help identify access related conditions. Example is the use of mine bombs.


* **Mines: Hooking up a test dump to the mines commands so I can more easily test what JSON is generated with the current settings and configurations.**


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,16 +1022,50 @@ public boolean hasTPAccess( Player player ) {
public boolean hasMiningAccess( Player player ) {
boolean results = false;

if ( isMineAccessByRank() &&
Prison.get().getPlatform().isMineAccessibleByRank( player, this ) ||
!isMineAccessByRank() &&
isAccessPermissionEnabled() && player.hasPermission( getAccessPermission() )

/// Note: the following cannot be added here since it will grant access if both are disabled
// || !isMineAccessByRank() && !isAccessPermissionEnabled()
) {
StringBuilder dbug = new StringBuilder();

dbug.append( "&3## hasMineAccess: mineAccessByRank: " ).append( isMineAccessByRank() );

/// Note: the following cannot be added here since it will grant access if both are disabled
// || !isMineAccessByRank() && !isAccessPermissionEnabled()

results = true;
if ( isMineAccessByRank() ) {

if ( Prison.get().getPlatform().isMineAccessibleByRank( player, this ) ) {

dbug.append( "Success!" );
results = true;
}
else {
dbug.append( "&cFailed! &aPlayer does not have access based upon their rank." );
}

}
else {

dbug.append( " accessByPerms: " ).append( isAccessPermissionEnabled() );

if ( isAccessPermissionEnabled() ) {

if ( player.hasPermission( getAccessPermission() )) {

dbug.append( "Success!" );
results = true;
}
else {
dbug.append( "&cFailed! &aPlayer does not have access based upon the permission: [" )
.append( getAccessPermission() == null ? "null" : getAccessPermission() );
}
}
else {

dbug.append( " &cFailed! &aMust have either accessByRank or accessByPerm enabled. " );
}

}

if ( Output.get().isDebug() ) {
Output.get().logInfo( dbug.toString() );
}

return results;
Expand Down

0 comments on commit 1478e95

Please sign in to comment.