diff --git a/gradle.properties b/gradle.properties index 21076e1..d0aa395 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ -pluginVersion = 2.4.0 +pluginVersion = 2.4.1 pluginGroup = nl.thedutchmc.harotorch pluginName = HaroTorch \ No newline at end of file diff --git a/src/main/java/dev/array21/harotorch/HaroTorch.java b/src/main/java/dev/array21/harotorch/HaroTorch.java index 1dc073d..a0a42d3 100644 --- a/src/main/java/dev/array21/harotorch/HaroTorch.java +++ b/src/main/java/dev/array21/harotorch/HaroTorch.java @@ -83,7 +83,7 @@ public void run() { Bukkit.getPluginManager().registerEvents(new BlockPistonExtendEventListener(), this); Bukkit.getPluginManager().registerEvents(new BlockPistonRetractEventListener(), this); Bukkit.getPluginManager().registerEvents(new PlayerInteractEventListener(), this); - Bukkit.getPluginManager().registerEvents(new BlockPhysicsEventListener(), this); + Bukkit.getPluginManager().registerEvents(new BlockPhysicsEventListener(this), this); Bukkit.getPluginManager().registerEvents(new BlockBurnEventListener(), this); Bukkit.getPluginManager().registerEvents(new BlockFadeEventListener(), this); diff --git a/src/main/java/dev/array21/harotorch/commands/torchSubCmds/HighlightAreaOfEffectExecutor.java b/src/main/java/dev/array21/harotorch/commands/torchSubCmds/HighlightAreaOfEffectExecutor.java index 2843815..119fba3 100644 --- a/src/main/java/dev/array21/harotorch/commands/torchSubCmds/HighlightAreaOfEffectExecutor.java +++ b/src/main/java/dev/array21/harotorch/commands/torchSubCmds/HighlightAreaOfEffectExecutor.java @@ -21,7 +21,6 @@ import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import com.google.common.util.concurrent.ExecutionError; import dev.array21.bukkitreflectionlib.ReflectionUtil; import net.md_5.bungee.api.ChatColor; @@ -29,7 +28,6 @@ import dev.array21.harotorch.commands.SubCommand; import dev.array21.harotorch.config.ConfigManifest.TorchRangeShape; import dev.array21.harotorch.lang.LangHandler; -import dev.array21.harotorch.torch.Torch; import dev.array21.harotorch.torch.TorchHandler; // ReflectionUtil.getNmsClass(String) is deprecated, kept for backwards compatibility with MC:1.16 and older. diff --git a/src/main/java/dev/array21/harotorch/events/BlockPhysicsEventListener.java b/src/main/java/dev/array21/harotorch/events/BlockPhysicsEventListener.java index b84a2e0..ed5e79f 100644 --- a/src/main/java/dev/array21/harotorch/events/BlockPhysicsEventListener.java +++ b/src/main/java/dev/array21/harotorch/events/BlockPhysicsEventListener.java @@ -1,17 +1,24 @@ package dev.array21.harotorch.events; import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; import org.bukkit.block.data.Openable; import org.bukkit.block.data.type.TrapDoor; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.scheduler.BukkitRunnable; + +import dev.array21.harotorch.HaroTorch; import org.bukkit.event.Listener; public class BlockPhysicsEventListener implements Listener { + private HaroTorch plugin; + + public BlockPhysicsEventListener(HaroTorch plugin) { + this.plugin = plugin; + } + @EventHandler public void onBlockPhysicsEvent(BlockPhysicsEvent event) { @@ -26,18 +33,20 @@ public void onBlockPhysicsEvent(BlockPhysicsEvent event) { } } - //We wont break a scaffolding block when a torch is ontop of it - if(event.getBlock().getType() == Material.SCAFFOLDING) { - Location l = event.getBlock().getLocation(); - if(!Common.checkSurroundings(l)) { - Block b = event.getBlock(); - } - } //We don't want gravity blocks to fall when they (could) have a torch attached/ontop if(event.getBlock().getType().hasGravity()) { if(!Common.checkSurroundings(event.getBlock().getLocation())) { event.setCancelled(true); + + new BukkitRunnable() { + @Override + public void run() { + System.out.println("Placing back block"); + Location l = event.getBlock().getLocation(); + l.getBlock().setType(event.getBlock().getType(), false); + } + }.runTaskLater(this.plugin, 2L); } } } diff --git a/src/main/java/dev/array21/harotorch/torch/Torch.java b/src/main/java/dev/array21/harotorch/torch/Torch.java index c52a4bb..d454ff1 100644 --- a/src/main/java/dev/array21/harotorch/torch/Torch.java +++ b/src/main/java/dev/array21/harotorch/torch/Torch.java @@ -16,7 +16,7 @@ public class Torch implements Serializable { public Torch(UUID torchOwner, Location torchLocation) { this.torchOwner = torchOwner; - + this.x = torchLocation.getBlockX(); this.y = torchLocation.getBlockY(); this.z = torchLocation.getBlockZ();