Add tracking support for piston item spawns.

This will allow servers to stop piston farms spawning items.

Ex. If you want to stop pistons from spawning items in all basic claims
you would enter the following command

'/cf item-spawn any false context[source=piston, override=basic]'
This commit is contained in:
bloodshot 2020-05-07 03:21:14 -04:00
parent d6b2958580
commit 67e5641d40
2 changed files with 4 additions and 0 deletions

View File

@ -126,6 +126,7 @@ public void onBlockBurn(BlockBurnEvent event) {
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onBlockPistonExtend(BlockPistonExtendEvent event) { public void onBlockPistonExtend(BlockPistonExtendEvent event) {
GDCauseStackManager.getInstance().pushCause(event.getBlock());
if (lastBlockPreTick == NMSUtil.getInstance().getRunningServerTicks()) { if (lastBlockPreTick == NMSUtil.getInstance().getRunningServerTicks()) {
// IGNORE // IGNORE
event.setCancelled(lastBlockPreCancelled); event.setCancelled(lastBlockPreCancelled);

View File

@ -646,6 +646,9 @@ public void handleEntitySpawn(Event event, Object source, Entity entity) {
user = CauseContextHelper.getEventUser(sourceLocation); user = CauseContextHelper.getEventUser(sourceLocation);
} else if (source instanceof Player) { } else if (source instanceof Player) {
user = PermissionHolderCache.getInstance().getOrCreateUser((Player) source); user = PermissionHolderCache.getInstance().getOrCreateUser((Player) source);
} else if (source instanceof Block) {
sourceLocation = ((Block) source).getLocation();
user = CauseContextHelper.getEventUser(sourceLocation);
} }
} }