本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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);
}
}
}
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
示例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())));
}
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}