Skip to content

Commit

Permalink
Merge pull request #61 from squareblob/master
Browse files Browse the repository at this point in the history
Stop explosions breaking reinforced hanging entities
  • Loading branch information
Maxopoly authored Nov 2, 2020
2 parents a4ee03a + 0ddf4b7 commit 52a266d
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
Expand Down Expand Up @@ -129,7 +130,7 @@ private List<Block> getGolemBlocks(EntityType type, Block base) {
public void playerJoinEvent(PlayerJoinEvent event) {
Player p = event.getPlayer();
final UUID uuid = p.getUniqueId();


new BukkitRunnable() {
@Override
Expand Down Expand Up @@ -228,6 +229,26 @@ public void hangingEntityBreakEvent(HangingBreakByEntityEvent event) {
event.setCancelled(true);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void HangingBreakEvent(HangingBreakEvent event) {
if (!Citadel.getInstance().getConfigManager().doHangersInheritReinforcements()) {
return;
}
if (event.getCause() != HangingBreakEvent.RemoveCause.EXPLOSION){
return;
}
Hanging entity = event.getEntity();
Block host = entity.getLocation().getBlock().getRelative(entity.getAttachedFace());
Reinforcement reinforcement = ReinforcementLogic.getReinforcementProtecting(host);
if (reinforcement == null) {
return;
}
if (reinforcement.isInsecure()) {
return;
}
event.setCancelled(true);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void entityDamageEvent(EntityDamageByEntityEvent event) {
if (!Citadel.getInstance().getConfigManager().doHangersInheritReinforcements()) {
Expand Down

0 comments on commit 52a266d

Please sign in to comment.