当前位置: 首页>>代码示例>>Java>>正文


Java Projectile.getShooter方法代码示例

本文整理汇总了Java中org.bukkit.entity.Projectile.getShooter方法的典型用法代码示例。如果您正苦于以下问题:Java Projectile.getShooter方法的具体用法?Java Projectile.getShooter怎么用?Java Projectile.getShooter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Projectile的用法示例。


在下文中一共展示了Projectile.getShooter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;

            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new ProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance);
            }
        }
    }
    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:20,代码来源:ProjectileDamageResolver.java

示例2: resolve

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            Location launchLocation = this.projectileDistanceTracker.getLaunchLocation(projectile);
            Double projectileDistance = null;
            OfflinePlayer dispenserOwner = dispenserTracker.getOwner(projectile);


            if(launchLocation != null) projectileDistance = event.getEntity().getLocation().distance(launchLocation);

            if(projectile.getShooter() instanceof LivingEntity) {
                return new DispensedProjectileDamageInfo(projectile, (LivingEntity) projectile.getShooter(), projectileDistance, dispenserOwner);
            }
        }
    }
    return null;
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:DispensedProjectileDamageResolver.java

示例3: onLingeringPotionSplash

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@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());
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:24,代码来源:IslandGuard1_9.java

示例4: onItemFrameDamage

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final EntityDamageByEntityEvent e) {
    // Check world
    if (!Util.inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getDamager() instanceof Projectile) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Projectile damage to itemframe");
        // Find out who fired the arrow
        Projectile p = (Projectile) e.getDamager();
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString());
        if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Shooter is mob");
            if (!Settings.allowMobDamageToItemFrames) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:IslandGuard.java

示例5: onProjectileHit

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onProjectileHit(ProjectileHitEvent event)
{
    if(event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SNOWBALL) return;
    
    Projectile arrow = event.getEntity();
    
    ProjectileSource source = arrow.getShooter();
    if(source == null || !(source instanceof Player)) return;
    
    Player player = (Player)source;
    if(player.getGameMode() == GameMode.CREATIVE) return;
    
    Flag flag = this.GetFlagInstanceAtLocation(arrow.getLocation(), player);
    if(flag == null) return;
    
    PlayerInventory inventory = player.getInventory();
    ItemMeta meta = inventory.getItemInMainHand().getItemMeta();
    if(meta != null && meta.hasEnchant(Enchantment.ARROW_INFINITE)) return;
    
    arrow.remove();
    inventory.addItem(new ItemStack(Material.ARROW));
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:24,代码来源:FlagDef_InfiniteArrows.java

示例6: getPlayerDamager

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
	Player damager = null;
	if (event.getCombuster() instanceof Player) {
		damager = (Player) event.getCombuster();
	} else if (event.getCombuster() instanceof Wolf) {
		Wolf wolf = (Wolf) event.getCombuster();
		if (wolf.getOwner() instanceof Player) {
			damager = (Player) wolf.getOwner();
		}
	} else if (event.getCombuster() instanceof Projectile) {
		Projectile projectile = (Projectile) event.getCombuster();
		if (projectile.getShooter() instanceof Player) {
			damager = (Player) projectile.getShooter();
		}
	}
	return damager;
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:22,代码来源:EntityCombustEventWrapper.java

示例7: getPlayerDamager

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
 * Gets the damager or indirect damager from any projectile.
 * @return The damager player
 */
public Player getPlayerDamager() {
	Player damager = null;
	if (event.getDamager() instanceof Player) {
		damager = (Player) event.getDamager();
	} else if (event.getDamager() instanceof Wolf) {
		Wolf wolf = (Wolf) event.getDamager();
		if (wolf.getOwner() instanceof Player) {
			damager = (Player) wolf.getOwner();
		}
	} else if (event.getDamager() instanceof Projectile) {
		Projectile projectile = (Projectile) event.getDamager();
		if (projectile.getShooter() instanceof Player) {
			damager = (Player) projectile.getShooter();
		}
	}
	return damager;
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:22,代码来源:EntityDamageEventWrapper.java

示例8: onProjectileHit

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
    Projectile projectile = event.getEntity();
    World world = projectile.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.FIRE_ARROWS) && worldConfig.getBoolean(Config.FEATURE_FIRE_ARROWS_IGNITE_TARGET)) {
        LivingEntity shooter = (LivingEntity) projectile.getShooter();
        if (shooter.getType() == EntityType.SKELETON) { //Not sure why this is here, or why fire arrows even work with it here
            return;
        }

        if (((CraftEntity) shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0) {
            //if (shooter != null && ((CraftEntity)shooter).getHandle() instanceof EntitySkeleton && projectile.getFireTicks() > 0){
            Block block = projectile.getWorld().getBlockAt(projectile.getLocation());

            if (block.getType() == Material.AIR) {
                block.setType(Material.FIRE);
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:23,代码来源:FireArrowsListener.java

示例9: onCreeperDamage

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
 * Tag creepers hurt by players.
 * 
 * Only those creepers hurt recently by players will have special drops.
 */
@EventHandler(ignoreCancelled = true)
public void onCreeperDamage(EntityDamageByEntityEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
        return;
    }

    if (event.getEntityType() == EntityType.CREEPER) {
        boolean isPlayerAttack = false;
        if (event.getDamager() instanceof Player) {
            isPlayerAttack = true;
        } else if (event.getDamager() instanceof Projectile) {
            Projectile projectile = (Projectile) event.getDamager();
            if (projectile.getShooter() instanceof Player) {
                isPlayerAttack = true;
            }
        }

        // Tag creepers hurt by players with the damage time stamp.
        if (isPlayerAttack) {
            Entity creeper = event.getEntity();
            creeper.setMetadata(PLAYER_DAMAGE_TIME_KEY,
                                new FixedMetadataValue(this, new Long(creeper.getWorld().getFullTime())));
        }
    }
}
 
开发者ID:NerdNu,项目名称:Creepocalypse,代码行数:31,代码来源:Creepocalypse.java

示例10: onKillingHit

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.MONITOR)
public void onKillingHit(EntityDamageByEntityEvent event) {
    if (event.isCancelled()) {
        return;
    }
    if (!(event.getEntity() instanceof LivingEntity)) {
        return;
    }
    LivingEntity entity = (LivingEntity) event.getEntity();
    if (entity.getHealth() > event.getFinalDamage()) {
        return;
    }
    Player player = null;
    if (event.getDamager() instanceof Player) {
        player = (Player) event.getDamager();
    } else if (event.getDamager() instanceof Projectile) {
        Projectile projectile = (Projectile) event.getDamager();
        if (projectile.getShooter() instanceof Player) {
            player = (Player) projectile.getShooter();
        }
    }
    if (player != null) {
        MobKillNotifier.addKill(player, entity);
    }
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:26,代码来源:MobKillListener.java

示例11: onBronDamageByEntity

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void onBronDamageByEntity(EntityDamageByEntityEvent edbe) {
  if (!(edbe.getDamager() instanceof Projectile) || !(edbe.getEntity() instanceof LivingEntity))
  {
    return;
  }
  Projectile proj = (Projectile) edbe.getDamager();
  if (proj == null || !(proj.getShooter() instanceof Player))
  {
    return;
  }
  Player shooter = (Player) proj.getShooter();
  Map<Projectile, Amunicja> mapeczka = plugin.nabojeMap.get(shooter.getName());
  if(mapeczka == null) {
    return;
  }
  Amunicja pobranaAmunicja = mapeczka.get(proj);
  if(pobranaAmunicja == null) {
    return;
  }
  edbe.setDamage(pobranaAmunicja.getDamage());
}
 
开发者ID:youuw,项目名称:eGuns,代码行数:23,代码来源:onDamageEntityByEntity.java

示例12: onProjectileLaunch

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile entity = event.getEntity();
    if (!(entity instanceof ThrownPotion)) {
        return;
    }
    ProjectileSource shooter = entity.getShooter();
    if (!(shooter instanceof Player)) {
        return;
    }
    Location l = BukkitUtil.getLocation(entity);
    if (!PS.get().hasPlotArea(l.getWorld())) {
        return;
    }
    PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
    Plot plot = l.getOwnedPlot();
    if (plot != null && !plot.isAdded(pp.getUUID())) {
        entity.remove();
        event.setCancelled(true);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:PlayerEvents.java

示例13: onEntityDamage

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event) {
	Player damager = null;
	if(event.getDamager() instanceof Player) {
		damager = (Player) event.getDamager();
	} else if(event.getDamager() instanceof Projectile) {
		Projectile pro = (Projectile) event.getDamager();
		if(pro.getShooter() instanceof Player) {
			damager = (Player) pro.getShooter();
		}
	}
	
	if(damager != null) {
		if(um.isSpectator(damager.getName()))
			event.setCancelled(true);
	}
}
 
开发者ID:maker56,项目名称:UltimateSurvivalGames,代码行数:18,代码来源:SpectatorListener.java

示例14: getEntity

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
 * Получает игрока, наносивший урон
 *
 * @param entity
 * @return
 */
private LivingEntity getEntity(Entity entity) {
    if (entity instanceof Projectile) {
        Projectile projectile = (Projectile) entity;

        if (!(projectile.getShooter() instanceof LivingEntity)) {

            return null;
        }

        return (LivingEntity) projectile.getShooter();
    }

    // Не живое существо
    if (!(entity instanceof LivingEntity)) {

        return null;
    }

    return (LivingEntity) entity;
}
 
开发者ID:truekenny,项目名称:MyLineagePvpSystem,代码行数:27,代码来源:RpgListener.java

示例15: onEntityDamageEvent

import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageEvent(EntityDamageByEntityEvent event) {
	if(event.getDamager() instanceof Player == false && event.getDamager() instanceof Projectile == false)
		return;
	
	if(event.getEntity() instanceof Player == false)
		return;
	
	Client damaged = Client.getClient((Player) event.getEntity());
	Player attackerPlayer = null;
	if(event.getDamager() instanceof Projectile) {
		Projectile proj = (Projectile) event.getDamager();
		if(proj.getShooter() instanceof Player == false)
			return;
		
		attackerPlayer = (Player) proj.getShooter();
	} else {
		attackerPlayer = (Player) event.getDamager();
	Client attacker = Client.getClient(attackerPlayer);
	
	if(attacker.getTeam() == damaged.getTeam() || attacker.getTeam().isObserver() || damaged.getTeam().isObserver())
		event.setCancelled(true);
	}
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:25,代码来源:PlayerEvents.java


注:本文中的org.bukkit.entity.Projectile.getShooter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。