Skip to content

Commit

Permalink
Implement BlockPistonExtendEvent (#1013)
Browse files Browse the repository at this point in the history
* Implement BlockPistonExtendEvent firing (addresses #922)

* Fix code style
  • Loading branch information
Red-Teapot authored and Pr0methean committed Feb 3, 2019
1 parent a133cfa commit 55b43af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/net/glowstone/block/blocktype/BlockPiston.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import java.util.ArrayList;
import java.util.List;

import lombok.Getter;
import net.glowstone.EventFactory;
import net.glowstone.GlowWorld;
import net.glowstone.block.GlowBlock;
import net.glowstone.chunk.GlowChunk;
Expand All @@ -14,6 +16,7 @@
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.PistonBaseMaterial;

Expand Down Expand Up @@ -96,6 +99,14 @@ public void onRedstoneUpdate(GlowBlock me) {
blocks.add(block);
}

BlockPistonExtendEvent event = EventFactory.getInstance().callEvent(
new BlockPistonExtendEvent(me, blocks, pistonBlockFace)
);

if (event.isCancelled()) {
return;
}

world.getRawPlayers().stream().filter(player -> player.canSeeChunk(chunkKey))
.forEach(player -> player.getSession().send(message));
world.playSound(me.getLocation(), Sound.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 0.5f,
Expand Down

0 comments on commit 55b43af

Please sign in to comment.