Skip to content

Commit

Permalink
Merge pull request #42 from TheNextLvl-net/fertilize-flag
Browse files Browse the repository at this point in the history
Add block fertilize protection flag
  • Loading branch information
NonSwag authored Oct 14, 2024
2 parents 748c292 + cc4def6 commit 051f237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public class Flags {
public final ProtectionFlag<Boolean> blockBurning = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_burning", true, false);
public final ProtectionFlag<Boolean> blockDrying = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_drying", true, false);
public final ProtectionFlag<Boolean> blockFading = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_fading", true, false);
public final ProtectionFlag<Boolean> blockFertilize = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_fertilize", true, false);
public final ProtectionFlag<Boolean> blockGrowth = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_growth", true, false);
public final ProtectionFlag<Boolean> blockIgniting = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_igniting", true, false);
public final ProtectionFlag<Boolean> blockMoisturising = flagRegistry().register(ProtectPlugin.this, Boolean.class, "block_moisturising", true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ public void onStructureGrow(StructureGrowEvent event) {
});
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockFertilize(BlockFertilizeEvent event) {
event.getBlocks().removeIf(block -> {
var area = plugin.areaProvider().getArea(block.getBlock());
return !area.getFlag(plugin.flags.blockFertilize);
});
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockExplode(BlockExplodeEvent event) {
event.blockList().removeIf(block -> {
Expand Down

0 comments on commit 051f237

Please sign in to comment.