Skip to content

Commit

Permalink
Mine bombs: Not a significant change. Allowed the mine bomb data to b…
Browse files Browse the repository at this point in the history
…e part of the event that is being passed along so it can be used in later updates and future features.
  • Loading branch information
rbluer committed Sep 14, 2024
1 parent a0dd244 commit 8b750f5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 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.19b 2024-09-13


* **Mine bombs: Not a significant change. Allowed the mine bomb data to be part of the event that is being passed along so it can be used in later updates and future features.**


* **Placeholders: Realized that the "uppercase" integration hook for placeholder API is not used.**
Realized that placeholder registration is done without sensitivity to the case used.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
import org.bukkit.event.block.BlockBreakEvent;

import tech.mcprison.prison.Prison;
import tech.mcprison.prison.bombs.MineBombData;
import tech.mcprison.prison.internal.block.MineTargetPrisonBlock;
import tech.mcprison.prison.internal.block.PrisonBlock.PrisonBlockType;
import tech.mcprison.prison.mines.data.Mine;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.spigot.SpigotPrison;
import tech.mcprison.prison.spigot.block.BlockBreakPriority;
import tech.mcprison.prison.spigot.block.OnBlockBreakMines.MinesEventResults;
import tech.mcprison.prison.spigot.block.SpigotBlock;
import tech.mcprison.prison.spigot.block.SpigotItemStack;
import tech.mcprison.prison.spigot.block.OnBlockBreakMines.MinesEventResults;
import tech.mcprison.prison.spigot.compat.SpigotCompatibility;
import tech.mcprison.prison.spigot.game.SpigotPlayer;
import tech.mcprison.prison.spigot.sellall.SellAllUtil;
Expand Down Expand Up @@ -88,6 +89,9 @@ public class PrisonMinesBlockBreakEvent
private String triggered;


private MineBombData mineBomb;


// If this is set during the validation process, and the validation fails, then this it will
// force the canceling of the original block event.
private boolean cancelOriginalEvent = false;
Expand Down Expand Up @@ -186,6 +190,8 @@ public PrisonMinesBlockBreakEvent(
this.blockEventType = blockEventType;
this.triggered = triggered;

this.mineBomb = null;

this.explodedBlocks = new ArrayList<>();
this.targetExplodedBlocks = new ArrayList<>();

Expand Down Expand Up @@ -229,6 +235,8 @@ public PrisonMinesBlockBreakEvent( Block theBlock, Player player,

this.triggered = triggered;

this.mineBomb = null;

this.bukkitDrops = new ArrayList<>();

this.preventedDrops = 0;
Expand Down Expand Up @@ -541,6 +549,13 @@ public HandlerList getHandlers() {
public static HandlerList getHandlerList() {
return handlers;
}

public MineBombData getMineBomb() {
return mineBomb;
}
public void setMineBomb( MineBombData mineBomb ) {
this.mineBomb = mineBomb;
}

public StringBuilder getDebugInfo() {
return debugInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import tech.mcprison.prison.autofeatures.AutoFeaturesFileConfig.AutoFeatures;
import tech.mcprison.prison.autofeatures.AutoFeaturesWrapper;
import tech.mcprison.prison.bombs.MineBombData;
import tech.mcprison.prison.mines.features.MineBlockEvent.BlockEventType;
import tech.mcprison.prison.output.Output;
import tech.mcprison.prison.spigot.SpigotPrison;
Expand Down Expand Up @@ -236,6 +237,8 @@ protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e,
PrisonMinesBlockBreakEvent pmEvent = null;
long start = System.nanoTime();

MineBombData mineBomb = e.getMineBomb();

// If the event is canceled, it still needs to be processed because of the
// MONITOR events:
// An event will be "canceled" and "ignored" if the block
Expand Down Expand Up @@ -321,17 +324,20 @@ protected void handleExplosiveBlockBreakEvent( ExplosiveBlockBreakEvent e,
// if the pseudo tool breaks, it will clear the player's in-hand
// inventory stack, which will be more mine bombs if they had more
// than one.
if ( e.getMineBomb() != null ) {
if ( mineBomb != null ) {

pmEvent.setMineBomb( mineBomb );

pmEvent.setCalculateDurability( false );

// Set if forced autoSell:
pmEvent.setForceAutoSell( e.getMineBomb().isAutosell() );
pmEvent.setForceAutoSell( mineBomb.isAutosell() );
}


// Check to see if the blockConverter's EventTrigger should have
// it's blocks suppressed from explosion events. If they should be
// removed, then it's removed within this funciton.
// removed, then it's removed within this function.
removeEventTriggerBlocksFromExplosions( pmEvent );


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,26 @@ public enum ItemLoreEnablers {



/**
* <p>The purpose of this function is to "quickly" evaluate if this event should be used,
* canceled, or ignored. Ignoring the event will mean that other plugins, and the originator
* of the event, can process EVERYTHING normally. If the event is canceled, then some plugins
* may then ignore the whole event, but some may also process it in some way or another. Prison
* uses canceled events to track block breakage when other plugins are handling the breaks.
* </p>
*
* @param event The event we're monitoring and processing
* @param player The player that caused the event by mining or breaking blocks
* @param block The "target" block that was initially broke by the player. Note that sometimes
* this is not the actual block, since the event does not preserve that information.
* @param bbPriority The priority that prison was listening at for this event.
* @param ignoreBlockReuse If set to true, then if the block was already counted, then prison
* will still process the blocks. Otherwise if the block has been already counted, then
* prison will ignore the event, which can have a huge impact if it's an explosion and
* there are many other blocks that "should" be processed, but ignoring the whole event
* would be skipping a lot of block processing.
* @return
*/
protected MinesEventResults ignoreMinesBlockBreakEvent( Cancellable event, Player player,
Block block, BlockBreakPriority bbPriority,
boolean ignoreBlockReuse ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,16 @@ private List<Mine> getAllMinesWithinTheRadialDistance( SpigotLocation location,
* or if the targetBlock has been set to ignore all block events which
* means the block has already been processed.
* </p>
*
* @param player
* @param block
*
* @param player The player that caused the event by mining or breaking blocks
* @param block The "target" block that was initially broke by the player. Note that sometimes
* this is not the actual block, since the event does not preserve that information.
* @param bbPriority The priority that prison was listening at for this event.
* @param ignoreBlockReuse If set to true, then if the block was already counted, then prison
* will still process the blocks. Otherwise if the block has been already counted, then
* prison will ignore the event, which can have a huge impact if it's an explosion and
* there are many other blocks that "should" be processed, but ignoring the whole event
* would be skipping a lot of block processing.
* @return
*/
protected MinesEventResults ignoreMinesBlockBreakEvent( Player player,
Expand Down

0 comments on commit 8b750f5

Please sign in to comment.