Java 类org.bukkit.event.entity.LingeringPotionSplashEvent 实例源码

项目:bskyblock    文件:IslandGuard1_9.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
        plugin.getLogger().info("1.9 entity = " + e.getEntity());
        plugin.getLogger().info("1.9 entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 radius = " + e.getAreaEffectCloud().getRadius());
        plugin.getLogger().info("1.9 id = " + e.getAreaEffectCloud().getEntityId());
        plugin.getLogger().info("1.9 hit entity = " + e.getHitEntity());
    }
    if (!Util.inWorld(e.getEntity().getLocation())) {
        return;
    }
    // Try to get the shooter
    Projectile projectile = e.getEntity();
    plugin.getLogger().info("shooter = " + projectile.getShooter());
    if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
        UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
        // Store it and remove it when the effect is gone
        thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
        plugin.getServer().getScheduler().runTaskLater(plugin, () -> thrownPotions.remove(e.getAreaEffectCloud().getEntityId()), e.getAreaEffectCloud().getDuration());
    }
}
项目:RedProtect    文件:RPMine19.java   
@EventHandler
public void onLingerPotion(LingeringPotionSplashEvent e){
    if (!(e.getEntity().getShooter() instanceof Player)){
        return;
    }

    Player p = (Player)e.getEntity().getShooter();
    Entity ent = e.getEntity();

    RedProtect.get().logger.debug("Is LingeringPotionSplashEvent event.");

    Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());
    if (r != null && !r.allowEffects(p)){
        RPLang.sendMessage(p, "playerlistener.region.cantuse");
        e.setCancelled(true);
        return;
    }    

    if (RPUtil.denyPotion(e.getEntity().getItem())){
        e.setCancelled(true);
        if (e.getEntity().getShooter() instanceof Player){
            RPLang.sendMessage((Player)e.getEntity().getShooter(), RPLang.get("playerlistener.denypotion"));
        }
    }
}
项目:QuarSK    文件:EvtLingeringPotionSplash.java   
@SuppressWarnings("SimplifiableIfStatement")
@Override
public boolean check(Event event) {
    if (event instanceof LingeringPotionSplashEvent) {
        if (effectTypes != null && effectTypes.getArray().length > 0) {
            return ((LingeringPotionSplashEvent) event).getEntity()
                                                       .getEffects()
                                                       .containsAll(Arrays.asList(effectTypes.getArray()));
        }
        return true;
    }
    return false;
}
项目:ExilePearl    文件:ExileListener.java   
/**
 * Prevent exiled players from using lingering splash potions
 * @param e The event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerThrowLingeringPotion(LingeringPotionSplashEvent e) {
    if(e.getEntity() != null && e.getEntity().getShooter() instanceof Player) {
        checkAndCancelRule(ExileRule.USE_POTIONS, e, (Player)e.getEntity().getShooter());
    }
}
项目:acidisland    文件:IslandGuard1_9.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
        plugin.getLogger().info("1.9 entity = " + e.getEntity());
        plugin.getLogger().info("1.9 entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 radius = " + e.getAreaEffectCloud().getRadius());
        plugin.getLogger().info("1.9 id = " + e.getAreaEffectCloud().getEntityId());
        plugin.getLogger().info("1.9 hit entity = " + e.getHitEntity());
    }
    if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
        return;
    }
    // Try to get the shooter
    Projectile projectile = (Projectile) e.getEntity();
    if (DEBUG)
        plugin.getLogger().info("shooter = " + projectile.getShooter());
    if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
        UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
        // Store it and remove it when the effect is gone
        thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
        plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

            @Override
            public void run() {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Effect finished");
                thrownPotions.remove(e.getAreaEffectCloud().getEntityId());

            }}, e.getAreaEffectCloud().getDuration());
    }
}
项目:askyblock    文件:IslandGuard1_9.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.9 " + e.getEventName());
        plugin.getLogger().info("1.9 entity = " + e.getEntity());
        plugin.getLogger().info("1.9 entity type = " + e.getEntityType());
        plugin.getLogger().info("1.9 radius = " + e.getAreaEffectCloud().getRadius());
        plugin.getLogger().info("1.9 id = " + e.getAreaEffectCloud().getEntityId());
        plugin.getLogger().info("1.9 hit entity = " + e.getHitEntity());
    }
    if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
        return;
    }
    // Try to get the shooter
    Projectile projectile = (Projectile) e.getEntity();
    if (DEBUG)
        plugin.getLogger().info("shooter = " + projectile.getShooter());
    if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
        UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
        // Store it and remove it when the effect is gone
        thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
        plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {

            @Override
            public void run() {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Effect finished");
                thrownPotions.remove(e.getAreaEffectCloud().getEntityId());

            }}, e.getAreaEffectCloud().getDuration());
    }
}
项目:PlotSquared    文件:PlayerEvents_1_9.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPotionSplash(LingeringPotionSplashEvent event) {
    LingeringPotion entity = event.getEntity();
    Location l = BukkitUtil.getLocation(entity);
    if (!PS.get().hasPlotArea(l.getWorld())) {
        return;
    }
    if (!parent.onProjectileHit(event)) {
        event.setCancelled(true);
    }
}