mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-08 08:08:05 +01:00
Block change block event for shop containers/signs
This commit is contained in:
parent
9d6c2f8c1b
commit
7bd00f23be
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
/**
|
||||
@ -37,6 +38,13 @@ public class ChestBreak implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public static void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (!canBeBroken(event.getBlock(), null)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canBeBroken(Block block, Player breaker) {
|
||||
if (!uBlock.couldBeShopContainer(block) || !Properties.USE_BUILT_IN_PROTECTION) {
|
||||
return true;
|
||||
|
@ -19,6 +19,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
@ -122,6 +123,13 @@ public class SignBreak implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public static void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
if (!canBlockBeBroken(event.getBlock(), null)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canBlockBeBroken(Block block, Player breaker) {
|
||||
List<Sign> attachedSigns = getAttachedSigns(block);
|
||||
List<Sign> brokenBlocks = new LinkedList<Sign>();
|
||||
|
Loading…
Reference in New Issue
Block a user