org.spongepowered.api.event.entity.CollideEntityEvent Java Examples
The following examples show how to use
org.spongepowered.api.event.entity.CollideEntityEvent.
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 |
@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: EntityEventHandler.java From GriefDefender with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onProjectileImpactEntity(CollideEntityEvent.Impact event) { if (!GDFlags.PROJECTILE_IMPACT_ENTITY) { return; } if (GriefDefenderPlugin.isSourceIdBlacklisted(Flags.PROJECTILE_IMPACT_ENTITY.getName(), event.getSource(), event.getImpactPoint().getExtent().getProperties())) { return; } final User user = CauseContextHelper.getEventUser(event); if (user == null || !GriefDefenderPlugin.getInstance().claimsEnabledForWorld(event.getImpactPoint().getExtent().getUniqueId())) { return; } GDTimings.PROJECTILE_IMPACT_ENTITY_EVENT.startTimingIfSync(); Object source = event.getCause().root(); Location<World> impactPoint = event.getImpactPoint(); GDClaim targetClaim = null; for (Entity entity : event.getEntities()) { if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.PROJECTILE_IMPACT_ENTITY.getName(), entity, event.getImpactPoint().getExtent().getProperties())) { return; } targetClaim = this.dataStore.getClaimAt(impactPoint, targetClaim); final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, impactPoint, targetClaim, Flags.PROJECTILE_IMPACT_ENTITY, source, entity, user, TrustTypes.ACCESSOR, true); if (result == Tristate.FALSE) { if (GDPermissionManager.getInstance().getFinalPermission(event, impactPoint, targetClaim, Flags.PROJECTILE_IMPACT_ENTITY, source, entity, user) == Tristate.TRUE) { GDTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync(); return; } event.setCancelled(true); } } GDTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync(); }
Example #3
Source File: EntityEventHandler.java From GriefPrevention with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onEntityCollideEntity(CollideEntityEvent event) { if (!GPFlags.ENTITY_COLLIDE_ENTITY || event instanceof CollideEntityEvent.Impact) { return; } //if (GriefPreventionPlugin.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 EntityItemFrame; if (!isRootEntityItemFrame) { return; } GPTimings.ENTITY_COLLIDE_EVENT.startTimingIfSync(); event.filterEntities(new Predicate<Entity>() { @Override public boolean test(Entity entity) { // Avoid living entities breaking itemframes if (isRootEntityItemFrame && entity instanceof EntityLiving) { return false; } return true; } }); GPTimings.ENTITY_COLLIDE_EVENT.stopTimingIfSync(); }
Example #4
Source File: EntityEventHandler.java From GriefPrevention with MIT License | 5 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onProjectileImpactEntity(CollideEntityEvent.Impact event) { if (!GPFlags.PROJECTILE_IMPACT_ENTITY) { return; } if (GriefPreventionPlugin.isSourceIdBlacklisted(ClaimFlag.PROJECTILE_IMPACT_ENTITY.toString(), event.getSource(), event.getImpactPoint().getExtent().getProperties())) { return; } final User user = CauseContextHelper.getEventUser(event); if (user == null || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getImpactPoint().getExtent().getProperties())) { return; } GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.startTimingIfSync(); Object source = event.getCause().root(); Location<World> impactPoint = event.getImpactPoint(); GPClaim targetClaim = null; for (Entity entity : event.getEntities()) { if (GriefPreventionPlugin.isTargetIdBlacklisted(ClaimFlag.PROJECTILE_IMPACT_ENTITY.toString(), entity, event.getImpactPoint().getExtent().getProperties())) { return; } targetClaim = this.dataStore.getClaimAt(impactPoint, targetClaim); final Tristate result = GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_ENTITY, source, entity, user, TrustType.ACCESSOR, true); if (result == Tristate.FALSE) { if (GPPermissionHandler.getClaimPermission(event, impactPoint, targetClaim, GPPermissions.PROJECTILE_IMPACT_ENTITY, source, entity, user) == Tristate.TRUE) { GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync(); return; } event.setCancelled(true); } } GPTimings.PROJECTILE_IMPACT_ENTITY_EVENT.stopTimingIfSync(); }