Java Code Examples for org.spongepowered.api.event.block.ChangeBlockEvent#Post

The following examples show how to use org.spongepowered.api.event.block.ChangeBlockEvent#Post . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventForwarder.java    From BlueMap with MIT License 5 votes vote down vote up
@Listener(order = Order.POST)
@Exclude({ChangeBlockEvent.Post.class, ChangeBlockEvent.Pre.class, ChangeBlockEvent.Modify.class})
public void onBlockChange(ChangeBlockEvent evt) {
	for (Transaction<BlockSnapshot> tr : evt.getTransactions()) {
		if(!tr.isValid()) continue;
		
		Optional<Location<org.spongepowered.api.world.World>> ow = tr.getFinal().getLocation();
		if (ow.isPresent()) {
			listener.onBlockChange(ow.get().getExtent().getUniqueId(), ow.get().getPosition().toInt());
		}
	}
}
 
Example 2
Source File: JailListener.java    From UltimateCore with MIT License 5 votes vote down vote up
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player p) {
    if (event instanceof ChangeBlockEvent.Pre || event instanceof ChangeBlockEvent.Post) {
        return;
    }
    UltimateUser up = UltimateCore.get().getUserService().getUser(p);
    if (up.get(JailKeys.JAIL).isPresent()) {
        if (!Modules.JAIL.get().getConfig().get().get().getNode("allow-block-modify").getBoolean()) {
            JailData data = up.get(JailKeys.JAIL).get();
            event.setCancelled(true);
            Messages.send(p, "jail.event.block", "%time%", (data.getEndtime() == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.formatDateDiff(data.getEndtime())), "%reason%", data.getReason());
        }
    }
}