#Cancelling piston head movement
1 messages · Page 1 of 1 (latest)
if theres a block powered event cancel that
I'm currently writing a plugin which allows users to create plots to protect their possessions. I wrote PistonProtection class which ensures pistons only work inside and outside the plots and can't be used to move anything in or out other player's plot. The code works fine but I couldn't find anything whichi would help me cancel piston head movement
i tried to find something but i couldn't
i also tried using BlockPistonEvent but im getting an error
` @EventHandler
public void onBlockPistonEvent(final BlockPistonEvent event){
PlotManager plotManager = ChunkyPlots.plugin.plotManager;
Block piston = event.getBlock();
Block extendedToBlock = piston.getRelative(event.getDirection());
Plot sourcePlot = plotManager.getPlotByBlock(piston);
Plot destinationPlot = plotManager.getPlotByBlock(extendedToBlock);
if(sourcePlot == null && destinationPlot != null){
event.setCancelled(true);
} else if (sourcePlot != null && destinationPlot != null){
if(!sourcePlot.hasTheSameOwnerAs(destinationPlot)){
event.setCancelled(true);
}
}
}```
it looks like it has nothing to do with my code
maybe BlockPistonEvent is abstract?
either way i cant seem to be able to do it
Yeah, abstract event, can't listen to it
I'm not sure what you mean by
I couldn't find anything whichi would help me cancel piston head movement
because cancelling the extract and retract events should do exactly that
okay, it was a simple oversight of mine and fortunately i was able to find it with your help
i just didn't check piston along with other blocks
tysm ❤️