當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。