Skip to content

Commit

Permalink
Lazy initialize BlockLeveler to fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jun 20, 2024
1 parent 2f10cd2 commit b70cd56
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

public class BukkitRegionManager extends RegionManager {

private final BlockLeveler blockLeveler;
private final AuraSkills plugin;
@Nullable
private BlockLeveler blockLeveler; // Lazy initialized in handleBlockPlace

public BukkitRegionManager(AuraSkills plugin) {
super(plugin);
this.blockLeveler = plugin.getLevelManager().getLeveler(BlockLeveler.class);
this.plugin = plugin;
}

public boolean isPlacedBlock(Block block) {
Expand All @@ -40,6 +42,11 @@ public boolean isPlacedBlock(Block block) {
}

public void handleBlockPlace(Block block) {
// Lazy initialize BlockLeveler
if (blockLeveler == null) {
blockLeveler = plugin.getLevelManager().getLeveler(BlockLeveler.class);
}

SkillSource<BlockXpSource> skillSource = blockLeveler.getSource(block, BlockXpSource.BlockTriggers.BREAK);

if (skillSource == null) { // Not a source
Expand Down

0 comments on commit b70cd56

Please sign in to comment.