Skip to content

Commit

Permalink
Block Break Listeners: If in debug mode, and there is a fast fail, or…
Browse files Browse the repository at this point in the history
… an ignore on the blocks being broken, log the reasons why.
  • Loading branch information
rbluer committed Sep 9, 2024
1 parent e3d3945 commit 138794b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ These change logs represent the work that has been going on within prison.
# 3.3.0-alpha.19 2024-09-09


* **Block Break Listeners: If in debug mode, and there is a fast fail, or an ignore on the blocks being broken, log the reasons why.**


* **Minor: variable not being used, so commented out to eliminate a compile warning.**


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ public enum ItemLoreEnablers {
protected MinesEventResults ignoreMinesBlockBreakEvent( Cancellable event, Player player,
Block block, BlockBreakPriority bbPriority,
boolean ignoreBlockReuse ) {

String eventName = event.getClass().getSimpleName();

MinesEventResults eventResults = ignoreMinesBlockBreakEvent( player, block,
bbPriority, ignoreBlockReuse );
eventResults.setEventName( eventName );

if ( eventResults.isCancelEvent() ) {
event.setCancelled( eventResults.isCancelEvent() );
}

eventResults.logDebugInfo();

// return eventResults.isIgnoreEvent();
return eventResults;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public class MinesEventResults {
private boolean cancelEvent = false;
private boolean ignoreEvent = false;

BlockBreakPriority bbPriority;
private String eventName;

private BlockBreakPriority bbPriority;
private Mine mine = null;
private SpigotPlayer sPlayer;

Expand All @@ -90,17 +92,21 @@ public MinesEventResults( BlockBreakPriority bbPriority, SpigotPlayer sPlayer, B
}

public void logDebugInfo() {
if ( isIgnoreEvent() &&
if ( (isIgnoreEvent() || isCancelEvent()) &&
Output.get().isDebug() ) {

String eventName = getEventName() != null && getEventName().trim().length() > 0 ?
"[event: " + getEventName() + "] " : "";

String blockName = getSpigotBlock() == null ?
"noPrisonBlock" :
getSpigotBlock().getBlockName();
String blockLocation = getSpigotBlock() == null ?
"" :
getSpigotBlock().getLocation().toWorldCoordinates();

Output.get().logInfo( "Prison AutoFeatures Fast-Fail: %s %s %s %s%s",
Output.get().logInfo( "Prison AutoFeatures Fast-Fail: %s%s %s %s %s%s",
eventName,
getResultsReason().name(),
//getBbPriority().name(),
getSpigotPlayer().getName(),
Expand Down Expand Up @@ -140,6 +146,13 @@ public void setResultsReason(EventResultsReasons resultsReason) {
this.resultsReason = resultsReason;
}

public String getEventName() {
return eventName;
}
public void setEventName(String eventName) {
this.eventName = eventName;
}

public BlockBreakPriority getBbPriority() {
return bbPriority;
}
Expand Down Expand Up @@ -668,7 +681,7 @@ else if ( !ignoreBlockReuse && targetBlock.isCounted() ) {
results.setResultsReason( EventResultsReasons.results_passed );
}

results.logDebugInfo();
//results.logDebugInfo();

return results;
}
Expand Down

0 comments on commit 138794b

Please sign in to comment.