Permalink
Browse files

Made BetterPhysics update the above block on block break.

  • Loading branch information...
me4502 committed Nov 14, 2016
1 parent c516dbe commit 83038fc3c4510991831686fad32f02928a36dc9c
Showing with 11 additions and 8 deletions.
  1. +11 −8 src/main/java/com/sk89q/craftbook/mechanics/BetterPhysics.java
@@ -3,7 +3,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
-import org.bukkit.entity.FallingBlock;
+import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
@@ -32,17 +32,16 @@ public void onBlockBreak(BlockBreakEvent event) {
if (!EventUtil.passesFilter(event))
return;
- if(FallingLadders.isValid(event.getBlock()))
- Bukkit.getScheduler().runTask(CraftBookPlugin.inst(), new FallingLadders(event.getBlock()));
+ checkForPhysics(event.getBlock());
+ checkForPhysics(event.getBlock().getRelative(BlockFace.UP));
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
if (!EventUtil.passesFilter(event)) return;
- if(FallingLadders.isValid(event.getBlock()))
- Bukkit.getScheduler().runTask(CraftBookPlugin.inst(), new FallingLadders(event.getBlock()));
+ checkForPhysics(event.getBlock());
}
@EventHandler(priority = EventPriority.MONITOR)
@@ -51,12 +50,16 @@ public void onBlockUpdate(BlockPhysicsEvent event) {
if (!EventUtil.passesFilter(event))
return;
- if(FallingLadders.isValid(event.getBlock()))
- Bukkit.getScheduler().runTask(CraftBookPlugin.inst(), new FallingLadders(event.getBlock()));
+ checkForPhysics(event.getBlock());
+ }
+
+ private static void checkForPhysics(Block block) {
+ if(FallingLadders.isValid(block))
+ Bukkit.getScheduler().runTask(CraftBookPlugin.inst(), new FallingLadders(block));
}
private static class FallingLadders implements Runnable {
- Block ladder;
+ private Block ladder;
FallingLadders(Block ladder) {

0 comments on commit 83038fc

Please sign in to comment.