org.spongepowered.api.entity.hanging.ItemFrame Java Examples

The following examples show how to use org.spongepowered.api.entity.hanging.ItemFrame. 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: EntityEventHandler.java    From GriefDefender with MIT License 5 votes vote down vote up
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityCollideEntity(CollideEntityEvent event) {
    if (!GDFlags.COLLIDE_ENTITY || event instanceof CollideEntityEvent.Impact) {
        return;
    }
    //if (GriefDefenderPlugin.isSourceIdBlacklisted(ClaimFlag.ENTITY_COLLIDE_ENTITY.toString(), event.getSource(), event.getEntities().get(0).getWorld().getProperties())) {
    //    return;
    //}

    Object rootCause = event.getCause().root();
    final boolean isRootEntityItemFrame = rootCause instanceof ItemFrame;
    if (!isRootEntityItemFrame) {
        return;
    }

    GDTimings.ENTITY_COLLIDE_EVENT.startTimingIfSync();
    event.filterEntities(new Predicate<Entity>() {
        @Override
        public boolean test(Entity entity) {
            // Avoid living entities breaking itemframes
            if (isRootEntityItemFrame && entity instanceof Living) {
                return false;
            }

            return true;
        }
    });
    GDTimings.ENTITY_COLLIDE_EVENT.stopTimingIfSync();
}
 
Example #2
Source File: InteractPermListener.java    From Nations with MIT License 5 votes vote down vote up
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractEntityEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Entity target = event.getTargetEntity();
	if (target instanceof Player || target instanceof Monster)
	{
		return;
	}
	if (target instanceof ItemFrame || target instanceof ArmorStand)
	{
		if (player.hasPermission("nations.admin.bypass.perm.build"))
		{
			return;
		}
		if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetEntity().getLocation()))
		{
			event.setCancelled(true);
			player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
		}
		return;
	}
	if (!DataHandler.getPerm("interact", player.getUniqueId(), event.getTargetEntity().getLocation()))
	{
		event.setCancelled(true);
		player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
	}
}