Properly cancel block explosions (#59)

This commit is contained in:
allinkdev 2023-08-25 16:23:24 +01:00 committed by GitHub
parent f97411ce09
commit bc5d0476ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package dev.plex.listener.impl;
import dev.plex.listener.PlexListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
@ -11,7 +12,7 @@ import org.bukkit.event.player.PlayerDropItemEvent;
public class TogglesListener extends PlexListener
{
@EventHandler
public void onBlockExplode(ExplosionPrimeEvent event)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if (!plugin.toggles.getBoolean("explosions"))
{
@ -20,6 +21,15 @@ public class TogglesListener extends PlexListener
}
}
@EventHandler
public void onBlockExplode(BlockExplodeEvent event) {
if (!plugin.toggles.getBoolean("explosions"))
{
event.getBlock().breakNaturally();
event.setCancelled(true);
}
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event)
{