Java Code Examples for org.bukkit.event.entity.EntityTargetEvent

The following examples show how to use org.bukkit.event.entity.EntityTargetEvent. These examples are extracted from open source projects. 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 Project: PGM   Author: PGMDev   File: DamageMatchModule.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
  if (!(event.getEntity() instanceof ExperienceOrb)) {
    ParticipantState victimState = null;
    if (event.getTarget() instanceof Player) {
      // Don't target allies
      MatchPlayer victim = getVictim(event.getTarget());
      if (victim == null) return;
      victimState = victim.getParticipantState();
    } else if (event.getTarget() != null) {
      // Don't target other mobs owned by allies
      victimState = tracker().getOwner(event.getTarget());
    }
    if (victimState == null) return;

    DamageInfo damageInfo =
        tracker()
            .resolveDamage(
                EntityDamageEvent.DamageCause.ENTITY_ATTACK,
                event.getTarget(),
                event.getEntity());
    if (queryHostile(victimState, damageInfo).isDenied()) {
      event.setCancelled(true);
    }
  }
}
 
Example #2
Source Project: ProjectAres   Author: OvercastNetwork   File: DamageMatchModule.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onTarget(EntityTargetEvent event) {
    if(!(event.getEntity() instanceof ExperienceOrb)) {
        ParticipantState victimState = null;
        if(event.getTarget() instanceof Player) {
            // Don't target allies
            MatchPlayer victim = getVictim(event.getTarget());
            if(victim == null) return;
            victimState = victim.getParticipantState();
        } else if(event.getTarget() != null) {
            // Don't target other mobs owned by allies
            victimState = entityResolver.getOwner(event.getTarget());
        }
        if(victimState == null) return;
        DamageInfo damageInfo = damageResolver.resolveDamage(EntityDamageEvent.DamageCause.ENTITY_ATTACK, event.getTarget(), event.getEntity());
        if(queryHostile(event, victimState, damageInfo).isDenied()) {
            event.setCancelled(true);
        }
    }
}
 
Example #3
Source Project: Skript   Author: SkriptLang   File: ExprTarget.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Entity[] get(final Event e, final LivingEntity[] source) {
	return get(source, new Converter<LivingEntity, Entity>() {
		@Override
		@Nullable
		public Entity convert(final LivingEntity en) {
			if (getTime() >= 0 && e instanceof EntityTargetEvent && en.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
				final Entity t = ((EntityTargetEvent) e).getTarget();
				if (t == null || type != null && !type.isInstance(t))
					return null;
				return t;
			}
			return Utils.getTarget(en, type);
		}
	});
}
 
Example #4
Source Project: Skript   Author: SkriptLang   File: ExprTarget.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) {
	if (mode == ChangeMode.SET || mode == ChangeMode.DELETE) {
		final LivingEntity target = delta == null ? null : (LivingEntity) delta[0];
		for (final LivingEntity entity : getExpr().getArray(e)) {
			if (getTime() >= 0 && e instanceof EntityTargetEvent && entity.equals(((EntityTargetEvent) e).getEntity()) && !Delay.isDelayed(e)) {
				((EntityTargetEvent) e).setTarget(target);
			} else {
				if (entity instanceof Creature)
					((Creature) entity).setTarget(target);
			}
		}
	} else {
		super.change(e, delta, mode);
	}
}
 
Example #5
Source Project: civcraft   Author: netizen539   File: CommonCustomMob.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void onTarget(EntityTargetEvent event) {
	if (event.isCancelled()) {
		return;
	}
	
	if ((event.getReason().equals(TargetReason.CLOSEST_PLAYER) ||
			event.getReason().equals(TargetReason.OWNER_ATTACKED_TARGET)) &&
			(event.getTarget() instanceof Player)) {
		
		double followRange = this.getFollowRange();
		double distance = event.getEntity().getLocation().distance(event.getTarget().getLocation());
		if ((distance-0.5) <= followRange) {
			this.targetName = ((Player)event.getTarget()).getName();
			this.lastLocation = event.getEntity().getLocation();
		}
	} else {
		this.targetName = null;
		this.lastLocation = null;
	}
}
 
Example #6
Source Project: civcraft   Author: netizen539   File: MobListener.java    License: GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event) {
	if (!(event.getEntity() instanceof LivingEntity)) {
		return;
	}
	
	if (!MobLib.isMobLibEntity((LivingEntity) event.getEntity())) {
		return;
	}
		
	CommonCustomMob mob = CommonCustomMob.getCCM(event.getEntity());
	if (mob != null) {
		mob.onTarget(event);
	}
	
}
 
Example #7
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalMeleeAttack.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
 
Example #8
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalMeleeAttack.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
 
Example #9
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalMeleeAttack.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_8_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
 
Example #10
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalMeleeAttack.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean shouldContinue() {
    LivingEntity target = this.getControllableEntity().getTarget();

    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.getControllableEntity().getTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    if (this.getControllableEntity().getTarget() == null || (this.getControllableEntity().getTarget() != null && !((CraftLivingEntity) this.getControllableEntity().getTarget()).getHandle().isAlive())) {
        org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    }
    // CraftBukkit end

    if (target == null) {
        return false;
    }
    EntityLiving targetHandle = ((CraftLivingEntity) target).getHandle();
    return !targetHandle.isAlive() ? false : (!this.ignoreSight ? !NMSEntityUtil.getNavigation(this.getHandle()).g() : NMSEntityUtil.isInHomeArea(this.getHandle(), MathHelper.floor(targetHandle.locX), MathHelper.floor(targetHandle.locY), MathHelper.floor(targetHandle.locZ)));
}
 
Example #11
Source Project: StaffPlus   Author: Shortninja66   File: EntityTarget.java    License: GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTarget(EntityTargetEvent event)
{
	if(event.getTarget() instanceof Player)
	{
		Player player = (Player) event.getTarget();
		
		if(userManager.get(player.getUniqueId()).getVanishType() != VanishType.TOTAL)
		{
			return;
		}
		
		event.setCancelled(true);
	}
}
 
Example #12
Source Project: BedwarsRel   Author: BedwarsRel   File: TNTSheep.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.b).setValue(128D);
    this.getAttributeInstance(GenericAttributes.d)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
 
Example #13
Source Project: BedwarsRel   Author: BedwarsRel   File: TNTSheep.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(128D);
    this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
 
Example #14
Source Project: BedwarsRel   Author: BedwarsRel   File: TNTSheep.java    License: GNU General Public License v3.0 5 votes vote down vote up
public TNTSheep(Location location, Player target) {
  super(((CraftWorld) location.getWorld()).getHandle());

  this.world = location.getWorld();

  this.locX = location.getX();
  this.locY = location.getY();
  this.locZ = location.getZ();

  try {
    Field b = this.goalSelector.getClass().getDeclaredField("b");
    b.setAccessible(true);
    b.set(this.goalSelector, new ArrayList<>());
    this.getAttributeInstance(GenericAttributes.b).setValue(128D);
    this.getAttributeInstance(GenericAttributes.d)
        .setValue(
            BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
  } catch (Exception e) {
    BedwarsRel.getInstance().getBugsnag().notify(e);
    e.printStackTrace();
  }

  this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, EntityHuman.class, 1D, false));
  this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
      EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, false);
  ((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
 
Example #15
Source Project: civcraft   Author: netizen539   File: Yobo.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTarget(EntityTargetEvent event) {
	super.onTarget(event);
	
	if (event.getReason().equals(TargetReason.FORGOT_TARGET) ||
	    event.getReason().equals(TargetReason.TARGET_DIED)) {
		this.angry = false;
		for (Entity e : minions) {
			e.getBukkitEntity().remove();
		}
		
	}
	
}
 
Example #16
Source Project: civcraft   Author: netizen539   File: AngryYobo.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTarget(EntityTargetEvent event) {
	super.onTarget(event);
	
	if (event.getReason().equals(TargetReason.FORGOT_TARGET) ||
	    event.getReason().equals(TargetReason.TARGET_DIED)) {
		event.getEntity().remove();
	}
	
}
 
Example #17
Source Project: AuthMeReloaded   Author: AuthMe   File: EntityListener.java    License: GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityTarget(EntityTargetEvent event) {
    if (listenerService.shouldCancelEvent(event.getTarget())) {
        event.setTarget(null);
        event.setCancelled(true);
    }
}
 
Example #18
Source Project: AuthMeReloaded   Author: AuthMe   File: EntityListenerTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shouldCancelEntityTargetEvent() {
    // given
    EntityTargetEvent event = mock(EntityTargetEvent.class);
    Entity target = mock(Entity.class);
    given(event.getTarget()).willReturn(target);
    given(listenerService.shouldCancelEvent(target)).willReturn(true);

    // when
    listener.onEntityTarget(event);

    // then
    verify(listenerService).shouldCancelEvent(target);
    verify(event).setCancelled(true);
}
 
Example #19
Source Project: AuthMeReloaded   Author: AuthMe   File: EntityListenerTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void shouldNotCancelEntityTargetEvent() {
    // given
    EntityTargetEvent event = mock(EntityTargetEvent.class);
    Entity target = mock(Entity.class);
    given(event.getTarget()).willReturn(target);
    given(listenerService.shouldCancelEvent(target)).willReturn(false);

    // when
    listener.onEntityTarget(event);

    // then
    verify(listenerService).shouldCancelEvent(target);
    verify(event, only()).getTarget();
}
 
Example #20
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalRangedAttack.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void finish() {
    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.target.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    // CraftBukkit end
    this.target = null;
    this.inRangeTicks = 0;
    this.shootCooldown = -1;
}
 
Example #21
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalRangedAttack.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void finish() {
    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.target.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    // CraftBukkit end
    this.target = null;
    this.inRangeTicks = 0;
    this.shootCooldown = -1;
}
 
Example #22
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalRangedAttack.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void finish() {
    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.target.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    // CraftBukkit end
    this.target = null;
    this.inRangeTicks = 0;
    this.shootCooldown = -1;
}
 
Example #23
Source Project: EntityAPI   Author: EntityAPIDev   File: BehaviourGoalRangedAttack.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void finish() {
    // CraftBukkit start
    EntityTargetEvent.TargetReason reason = this.target.isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
    CraftEventFactory.callEntityTargetEvent(this.getHandle(), null, reason);
    // CraftBukkit end
    this.target = null;
    this.inRangeTicks = 0;
    this.shootCooldown = -1;
}
 
Example #24
Source Project: BedWars   Author: ScreamingSandals   File: GolemListener.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onGolemTarget(EntityTargetEvent event) {
	if (!(event.getEntity() instanceof IronGolem)) {
        return;
    }

    IronGolem ironGolem = (IronGolem) event.getEntity();
    for (String name : Main.getGameNames()) {
        Game game = Main.getGame(name);
        if ((game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) && ironGolem.getWorld().equals(game.getGameWorld())) {
            List<SpecialItem> golems = game.getActivedSpecialItems(Golem.class);
            for (SpecialItem item : golems) {
                if (item instanceof Golem) {
                    Golem golem = (Golem) item;
                    if (golem.getEntity().equals(ironGolem)) {
                        if (event.getTarget() instanceof Player) {
                            final Player player = (Player) event.getTarget();
                            if (game.isProtectionActive(player)) {
                                event.setCancelled(true);
                                return;
                            }

                            if (Main.isPlayerInGame(player)) {
                                if (golem.getTeam() == game.getTeamOfPlayer(player)) {
                                	event.setCancelled(true);
                                    // Try to find enemy
                                    Player playerTarget = MiscUtils.findTarget(game, player, golem.getFollowRange());
                                    if (playerTarget != null) {
                                    	// Oh. We found enemy!
                                        ironGolem.setTarget(playerTarget);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example #25
Source Project: PGM   Author: PGMDev   File: EventFilterMatchModule.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityTrack(final EntityTargetEvent event) {
  // Handles mobs and XP orbs
  if (event.getTarget() != null) cancelUnlessInteracting(event, event.getTarget());
}
 
Example #26
Source Project: BedWars   Author: ScreamingSandals   File: GolemListener.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
@EventHandler
public void onGolemTarget(EntityTargetEvent event) {
	if (!(event.getEntity() instanceof IronGolem)) {
        return;
    }

    IronGolem ironGolem = (IronGolem) event.getEntity();
    for (String name : Main.getGameNames()) {
        Game game = Main.getGame(name);
        if ((game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) && ironGolem.getWorld().equals(game.getGameWorld())) {
            List<SpecialItem> golems = game.getActivedSpecialItems(Golem.class);
            for (SpecialItem item : golems) {
                if (item instanceof Golem) {
                    Golem golem = (Golem) item;
                    if (golem.getEntity().equals(ironGolem)) {
                        if (event.getTarget() instanceof Player) {
                            final Player player = (Player) event.getTarget();
                            if (game.isProtectionActive(player)) {
                                event.setCancelled(true);
                                return;
                            }

                            if (Main.isPlayerInGame(player)) {
                                if (golem.getTeam() == game.getTeamOfPlayer(player)) {
                                	event.setCancelled(true);
                                    // Try to find enemy
                                    Player playerTarget = MiscUtils.findTarget(game, player, golem.getFollowRange());
                                    if (playerTarget != null) {
                                    	// Oh. We found enemy!
                                        ironGolem.setTarget(playerTarget);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example #27
Source Project: ProjectAres   Author: OvercastNetwork   File: EventFilterMatchModule.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityTrack(final EntityTargetEvent event) {
    // Handles mobs and XP orbs
    if(event.getTarget() != null) cancelUnlessInteracting(event, event.getTarget());
}
 
Example #28
Source Project: Skript   Author: SkriptLang   File: ExprTarget.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean setTime(final int time) {
	return super.setTime(time, EntityTargetEvent.class, getExpr());
}
 
Example #29
Source Project: Skript   Author: SkriptLang   File: EvtEntityTarget.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Event e) {
	return ((EntityTargetEvent) e).getTarget() == null ^ target;
}
 
Example #30
Source Project: Shopkeepers   Author: nisovin   File: LivingEntityShopListener.java    License: GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
void onEntityTarget(EntityTargetEvent event) {
	if (plugin.isShopkeeper(event.getEntity()) || plugin.isShopkeeper(event.getTarget())) {
		event.setCancelled(true);
	}
}