Skip to content

Commit

Permalink
Account for block placer
Browse files Browse the repository at this point in the history
  • Loading branch information
JustAHuman-xD committed Feb 21, 2024
1 parent 62dec6f commit 445d457
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ne.fnfal113.relicsofcthonia.listeners;

import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import lombok.Getter;
import ne.fnfal113.relicsofcthonia.RelicsOfCthonia;
import ne.fnfal113.relicsofcthonia.relics.abstracts.AbstractRelic;
Expand Down Expand Up @@ -92,15 +93,25 @@ public void onBlockBreak(BlockBreakEvent event) {

@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
if(event.isCancelled()){
return;
if(!event.isCancelled()){
handlePlacedBlock(event.getBlockPlaced());
}
}

@EventHandler
public void onBlockPlacerPlaced(BlockPlacerPlaceEvent event) {
if(!event.isCancelled()){
handlePlacedBlock(event.getBlock());
}
}


public void handlePlacedBlock(Block block) {
/*
* Prevent players from block place farming any relics
* This will be detected above in the block break event
*/
event.getBlockPlaced().setMetadata("placed_block", new FixedMetadataValue(RelicsOfCthonia.getInstance(), "placed"));
block.setMetadata("placed_block", new FixedMetadataValue(RelicsOfCthonia.getInstance(), "placed"));
}

}

0 comments on commit 445d457

Please sign in to comment.