From 5c9371c575918e80259d7d577b79429e40aff250 Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 26 May 2012 19:52:24 -0400 Subject: [PATCH] Fixed falling sand/gravel stuff not being tracked --- Changelog.txt | 1 + .../nossr50/listeners/BlockListener.java | 40 ++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index a6b31646d..47d132160 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,6 +11,7 @@ Version 1.3.09 = Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing) = Fixed bug where you could receive Archery XP from Potions = Fixed bug with duping blocks via piston pushing + = Fixed bug with falling sand/gravel not being tracked ! Changed Spout settings to be in their own config file (spout.yml) Version 1.3.08 diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 9645cb1f1..4338004ca 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -32,6 +32,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; @@ -72,6 +73,25 @@ public class BlockListener implements Listener { } } + /** + * Monitor BlockPhysics events. + * + * @param event The event to monitor + */ + @EventHandler(priority = EventPriority.MONITOR) + public void onBlockPhysics(BlockPhysicsEvent event) { + //TODO: Figure out how to REMOVE metadata from the location the sand fell from. + Material type = event.getChangedType(); + + if (type == Material.GRAVEL || type == Material.SAND) { + Block fallenBlock = event.getBlock().getRelative(BlockFace.UP); + + if (fallenBlock.getType() == type) { + mcMMO.placeStore.setTrue(fallenBlock); + } + } + } + /** * Monitor BlockPistonRetract events. * @@ -99,21 +119,6 @@ public class BlockListener implements Listener { Block block = event.getBlock(); Player player = event.getPlayer(); int id = block.getTypeId(); - Material mat = block.getType(); - - /* Code to prevent issues with placed falling Sand/Gravel not being tracked */ - if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) { - for (int y = -1; y + block.getY() >= 0; y--) { - if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) { - continue; - } - else { - Block newLocation = block.getRelative(0, y + 1, 0); - mcMMO.placeStore.setTrue(newLocation); - break; - } - } - } /* Check if the blocks placed should be monitored so they do not give out XP in the future */ if (BlockChecks.shouldBeWatched(block)) { @@ -144,6 +149,11 @@ public class BlockListener implements Listener { return; } + //DEBUG MESSAGES + if (!mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) { + player.sendMessage("Why aren't you watching me?"); + } + /* HERBALISM */ if (BlockChecks.canBeGreenTerra(block)) { /* Green Terra */