|
22 | 22 | import org.bukkit.block.data.type.WallSign; |
23 | 23 | import org.bukkit.block.sign.Side; |
24 | 24 | import org.bukkit.block.sign.SignSide; |
25 | | -import org.bukkit.entity.Player; |
26 | | -import org.bukkit.entity.Villager; |
| 25 | +import org.bukkit.entity.*; |
27 | 26 | import org.bukkit.event.EventHandler; |
28 | 27 | import org.bukkit.event.block.Action; |
29 | 28 | import org.bukkit.event.block.BlockPlaceEvent; |
@@ -273,15 +272,22 @@ private boolean isSneakPlacing(Player player) { |
273 | 272 |
|
274 | 273 | @EventHandler(ignoreCancelled = true) |
275 | 274 | public void onEntityInteract(EntityInteractEvent event) { |
276 | | - // Prevents villagers from opening doors |
277 | | - if (!(event.getEntity() instanceof Villager)) { |
278 | | - return; |
279 | | - } |
280 | | - if (plugin.getChestSettings().allowDestroyBy(AttackType.VILLAGER)) { |
281 | | - return; |
282 | | - } |
283 | | - if (isProtected(event.getBlock())) { |
284 | | - event.setCancelled(true); |
| 275 | + // Prevents villagers and golems from opening doors |
| 276 | + Entity entity = event.getEntity(); |
| 277 | + if (entity instanceof Villager) { |
| 278 | + if (plugin.getChestSettings().allowDestroyBy(AttackType.VILLAGER)) { |
| 279 | + return; |
| 280 | + } |
| 281 | + if (isProtected(event.getBlock())) { |
| 282 | + event.setCancelled(true); |
| 283 | + } |
| 284 | + } else if (entity instanceof Golem) { |
| 285 | + if (plugin.getChestSettings().allowDestroyBy(AttackType.GOLEM)) { |
| 286 | + return; |
| 287 | + } |
| 288 | + if (isProtected(event.getBlock())) { |
| 289 | + event.setCancelled(true); |
| 290 | + } |
285 | 291 | } |
286 | 292 | } |
287 | 293 |
|
|
0 commit comments