mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-16 23:55:23 +01:00
Route BlockDispenseEvent to RuleLists item-drop.
This commit is contained in:
parent
ef43ba2700
commit
35628d09be
@ -34,6 +34,7 @@
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
@ -728,4 +729,20 @@ public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockDispense(BlockDispenseEvent event) {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
|
||||
// RuleLists
|
||||
RuleSet rules = wcfg.getRuleList().get(KnownAttachment.ITEM_DROP);
|
||||
BukkitContext context = new BukkitContext(event);
|
||||
context.setSourceBlock(event.getBlock().getState());
|
||||
context.setItem(event.getItem());
|
||||
if (rules.process(context)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user