Skip to content

Commit

Permalink
Fixed #15
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Jul 29, 2021
1 parent d59567a commit 3f225d0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginVersion = 2.4.0
pluginVersion = 2.4.1
pluginGroup = nl.thedutchmc.harotorch
pluginName = HaroTorch
2 changes: 1 addition & 1 deletion src/main/java/dev/array21/harotorch/HaroTorch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
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;
import dev.array21.harotorch.HaroTorch;
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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {

Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/array21/harotorch/torch/Torch.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3f225d0

Please sign in to comment.