diff --git a/src/com/pwn9/PwnBuckets/EvaporateLavaTask.java b/src/com/pwn9/PwnBuckets/EvaporateLavaTask.java index 0813993..c56c528 100644 --- a/src/com/pwn9/PwnBuckets/EvaporateLavaTask.java +++ b/src/com/pwn9/PwnBuckets/EvaporateLavaTask.java @@ -3,6 +3,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Levelled; public class EvaporateLavaTask implements Runnable { @@ -41,15 +42,16 @@ public void run() public boolean isLava(Block block) { - Block b = block; - - if (b.getType() == Material.LAVA) + if ((block.getType() == Material.LAVA) && (block.getBlockData() instanceof Levelled)) { - return true; - } - else - { - return false; + Levelled levelledBlock = (Levelled) block.getBlockData(); + int level = levelledBlock.getLevel(); + //source block + if (level == 0) + { + return true; + } } + return false; } } diff --git a/src/com/pwn9/PwnBuckets/EvaporateWaterTask.java b/src/com/pwn9/PwnBuckets/EvaporateWaterTask.java index aa8bfe7..5b22e09 100644 --- a/src/com/pwn9/PwnBuckets/EvaporateWaterTask.java +++ b/src/com/pwn9/PwnBuckets/EvaporateWaterTask.java @@ -3,6 +3,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Levelled; public class EvaporateWaterTask implements Runnable { @@ -41,15 +42,16 @@ public void run() public boolean isWater(Block block) { - Block b = block; - - if (b.getType() == Material.WATER) - { - return true; - } - else + if ((block.getType() == Material.WATER) && (block.getBlockData() instanceof Levelled)) { - return false; + Levelled levelledBlock = (Levelled) block.getBlockData(); + int level = levelledBlock.getLevel(); + //source block + if (level == 0) + { + return true; + } } + return false; } } diff --git a/src/com/pwn9/PwnBuckets/WaterListener.java b/src/com/pwn9/PwnBuckets/WaterListener.java index a4f174e..4ba34b4 100644 --- a/src/com/pwn9/PwnBuckets/WaterListener.java +++ b/src/com/pwn9/PwnBuckets/WaterListener.java @@ -5,7 +5,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Levelled; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -58,9 +57,9 @@ public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) } // if its water - if ((bucket.toString().contains("WATER") || bucket.toString().contains("FISH") || bucket.toString().contains("SALMON") || bucket.toString().contains("COD")) && (!player.hasPermission("pwnbuckets.waterbucket"))) { - - + if ((bucket.toString().contains("WATER") || bucket.toString().contains("FISH") || bucket.toString().contains("SALMON") || bucket.toString().contains("COD")) && (!player.hasPermission("pwnbuckets.waterbucket"))) + { + // if the biome has a bypass allow dumping water if (PwnBuckets.containsCaseInsensitive(biome, PwnBuckets.bucketBypass)) { @@ -80,24 +79,7 @@ public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) plugin.getServer().getScheduler().runTaskLater(plugin, task, 30L); } - // need to cancel the event and manually change the inventory or else fast placing buckets can get around the plugin - if (mainBucket == bucket) { - ClearBucketTask clearTask = new ClearBucketTask(player, true); - plugin.getServer().getScheduler().runTaskLater(plugin, clearTask, 1L); - } - else if (offBucket == bucket){ - ClearBucketTask clearTask = new ClearBucketTask(player, false); - plugin.getServer().getScheduler().runTaskLater(plugin, clearTask, 1L); - } - else { - // this shouldn't happen - if (PwnBuckets.logEnabled) - { - PwnBuckets.logToFile("Couldn't identify bucket hand."); - } - } - - event.setCancelled(true); + // no need to cancel the event anymore, let it finish and evaporate the water if (PwnBuckets.logEnabled) { @@ -109,7 +91,8 @@ else if (offBucket == bucket){ } // if its lava - if (bucket.toString().contains("LAVA") && (!player.hasPermission("pwnbuckets.lavabucket"))) { + if (bucket.toString().contains("LAVA") && (!player.hasPermission("pwnbuckets.lavabucket"))) + { // if the biome has a bypass allow dumping lava if (PwnBuckets.containsCaseInsensitive(biome, PwnBuckets.lavaBucketBypass)) @@ -130,24 +113,7 @@ else if (offBucket == bucket){ plugin.getServer().getScheduler().runTaskLater(plugin, task, 120L); } - // need to cancel the event and manually change the inventory or else fast placing buckets can get around the plugin - if (mainBucket == bucket) { - ClearBucketTask clearTask = new ClearBucketTask(player, true); - plugin.getServer().getScheduler().runTaskLater(plugin, clearTask, 1L); - } - else if (offBucket == bucket){ - ClearBucketTask clearTask = new ClearBucketTask(player, false); - plugin.getServer().getScheduler().runTaskLater(plugin, clearTask, 1L); - } - else { - // this shouldn't happen - if (PwnBuckets.logEnabled) - { - PwnBuckets.logToFile("Couldn't identify bucket hand."); - } - } - - event.setCancelled(true); + // no need to cancel the event anymore, let it finish and evaporate the lava if (PwnBuckets.logEnabled) { @@ -240,7 +206,8 @@ else if(bucket.toString().contains("LAVA")) // when ice melts? @EventHandler(ignoreCancelled = true) - public void onBlockFade(BlockFadeEvent event) { + public void onBlockFade(BlockFadeEvent event) + { World world = event.getBlock().getWorld(); @@ -287,11 +254,13 @@ public void onBlockFade(BlockFadeEvent event) { // to set a source water not flowing water public boolean isWater(Block block) { - if ((block.getType() == Material.WATER) && (block.getBlockData() instanceof Levelled)) { + if ((block.getType() == Material.WATER) && (block.getBlockData() instanceof Levelled)) + { Levelled levelledBlock = (Levelled) block.getBlockData(); int level = levelledBlock.getLevel(); //source block - if (level == 0) { + if (level == 0) + { if (PwnBuckets.logEnabled) { PwnBuckets.logToFile("Placing bucket on an existing source block."); @@ -305,11 +274,13 @@ public boolean isWater(Block block) // to get a source lava not flowing lava public boolean isLava(Block block) { - if ((block.getType() == Material.LAVA) && (block.getBlockData() instanceof Levelled)) { + if ((block.getType() == Material.LAVA) && (block.getBlockData() instanceof Levelled)) + { Levelled levelledBlock = (Levelled) block.getBlockData(); int level = levelledBlock.getLevel(); //source block - if (level == 0) { + if (level == 0) + { if (PwnBuckets.logEnabled) { PwnBuckets.logToFile("Placing bucket on an existing source block.");