本文整理汇总了Java中org.bukkit.event.entity.ProjectileHitEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectileHitEvent.getEntity方法的具体用法?Java ProjectileHitEvent.getEntity怎么用?Java ProjectileHitEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.ProjectileHitEvent
的用法示例。
在下文中一共展示了ProjectileHitEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent evt) {
Projectile projectile = evt.getEntity();
String customId = projectile.getCustomName();
if (customId == null || !customId.equals("recreator.structure.turret.tnt")) return;
Location loc;
Block block = evt.getHitBlock();
if (block != null) {
loc = block.getLocation();
block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
return;
}
Entity entity = evt.getEntity();
if (entity != null) {
loc = entity.getLocation();
entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.8F, true, true);
}
}
示例2: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent evt) {
Projectile projectile = evt.getEntity();
String customId = projectile.getCustomName();
if (customId == null || !customId.equals("recreator.item.fatman")) return;
Location loc;
Block block = evt.getHitBlock();
if (block != null) {
loc = block.getLocation();
block.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
return;
}
Entity entity = evt.getEntity();
if (entity != null) {
loc = entity.getLocation();
entity.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 50F, true, true);
}
}
示例3: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的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));
}
示例4: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的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);
}
}
}
}
示例5: onHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onHit(ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (projectile instanceof Arrow) {
projectile.remove();
} else if (projectile instanceof Snowball && event.getEntity() instanceof Player) {
((Player) event.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 1));
} else if (projectile instanceof Egg && projectile.getShooter() instanceof Player) {
projectile.getWorld().createExplosion(projectile.getLocation(), 0.0F);
for (Entity entity : projectile.getNearbyEntities(5, 5, 5)) {
if (entity instanceof Player) {
Player player = (Player) entity;
if (plugin.getGameArena().isZombie(player)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 5, 1));
}
}
}
}
}
示例6: eggBreak
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void eggBreak(final ProjectileHitEvent e) {
if (e.getEntity() instanceof Egg && eggs.contains(e.getEntity())) {
final Location l = e.getEntity().getLocation();
int radius = 3;
final int[][] newLocs = { { radius, 0 }, { -radius, 0 }, { 0, radius }, { 0, -radius }
};
for (int i = 0; i < 4; i++) {
final int count = i;
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, new Runnable() {
public void run() {
e.getEntity().getWorld().createExplosion(l.getX() + newLocs[count][0], l.getY(), l.getZ() + newLocs[count][1], 2.3F, false, true);
}
}, 4 * i);
}
eggs.remove(e.getEntity());
}
}
示例7: onProjectileHitEvent
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
private void onProjectileHitEvent(final ProjectileHitEvent event) {
Projectile projectile = event.getEntity();
if (!(projectile instanceof Snowball))
return;
if (projectile.getShooter() instanceof Player) {
Player player = (Player) projectile.getShooter();
Game game = api.getGameManager().getGame(player);
if (game == null)
return;
if (game.getState() != GameState.PLAYING)
return;
PlantType type = game.getPlants().getMembers().get(player.getUniqueId());
if (type == null)
return;
if (type == PlantType.WINTER_MELON) {
freeze(getZombies(projectile, game), game);
}
}
}
示例8: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Entity entity = event.getEntity();
// Config
float size = plugin.getConfig().getInt("Size of Explosion");
boolean damage = plugin.getConfig().getBoolean("Block Damage");
boolean fire = plugin.getConfig().getBoolean("Set Fire");
if (entity instanceof Snowball) {
Snowball snowball = (Snowball) entity;
Entity shooter = snowball.getShooter();
if (shooter instanceof Player) {
Player player = (Player) shooter;
Location sb = snowball.getLocation();
if (plugin.players.contains(player.getName())) {
player.getWorld().createExplosion(sb.getX(), sb.getY(),
sb.getZ(), size, fire, damage);
}
}
}
}
示例9: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
final Entity entity = e.getEntity();
if (removeArrows.contains(entity.getEntityId())) {
entity.remove();
removeArrows.remove(entity.getEntityId());
} else if (rpgProjectiles.contains(entity.getEntityId())) {
RPGItem item = ItemManager.getItemById(rpgProjectiles.get(entity.getEntityId()));
new BukkitRunnable() {
public void run() {
rpgProjectiles.remove(entity.getEntityId());
}
}.runTask(Plugin.plugin);
if (item == null)
return;
item.projectileHit((Player) ((Projectile) entity).getShooter(), (Projectile) entity);
}
}
示例10: onArrowImpactEvent
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onArrowImpactEvent(ProjectileHitEvent event) {
if (!(event.getEntity().getShooter() instanceof Player)) return;
Player player = (Player) event.getEntity().getShooter();
if (event.getEntity() instanceof Arrow && arrows.contains(event.getEntity())) {
arrows.remove(event.getEntity());
player.sendMessage(ChatColor.YELLOW + "Boom!");
final Location target = event.getEntity().getLocation();
for (int i = 0; i < 60; i++) {
final int k = i;
Bukkit.getScheduler().scheduleSyncDelayedTask(MausWasHere.PLUGIN, new Runnable() {
@Override
public void run() {
nukeEffect(target, 110 + k, 30 * k, k / 4);
}
}, i);
}
}
}
示例11: onSnowballHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onSnowballHit(ProjectileHitEvent event) {
if(event.getEntity() instanceof Snowball) {
if(event.getHitBlock() != null && event.getHitBlock().getType() == Material.SNOW_BLOCK) {
event.getHitBlock().breakNaturally(new ItemStack(Material.AIR));
}
}
}
示例12: onProjectileHitEvent
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent event) {
final Projectile projectile = event.getEntity();
final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(projectile);
if(projectileDefinition == null) return;
final Filter filter = projectileDefinition.destroyFilter();
if(filter == null) return;
final BlockIterator blockIterator = new BlockIterator(projectile.getWorld(), projectile.getLocation().toVector(), projectile.getVelocity().normalize(), 0d, 2);
Block hitBlock = null;
while(blockIterator.hasNext()) {
hitBlock = blockIterator.next();
if(hitBlock.getType() != Material.AIR) break;
}
if(hitBlock != null) {
final MatchPlayer shooter = projectile.getShooter() instanceof Player ? getMatch().getPlayer((Player) projectile.getShooter()) : null;
final IQuery query = shooter != null ? new PlayerBlockEventQuery(shooter, event, hitBlock.getState())
: new BlockEventQuery(event, hitBlock);
if(filter.query(query).isAllowed()) {
final BlockTransformEvent bte = new BlockTransformEvent(event, hitBlock, Material.AIR);
match.callEvent(bte);
if(!bte.isCancelled()) {
hitBlock.setType(Material.AIR);
projectile.remove();
}
}
}
}
示例13: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
if (e.getEntity() instanceof Arrow) {
EntityTrail t = trails.remove(e.getEntity());
if (t != null)
t.stop();
}
}
示例14: on
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void on(ProjectileHitEvent event){
Entity entity = event.getEntity();
Location loc = entity.getLocation();
if (entity instanceof Arrow){
Arrow arrow = (Arrow) entity;
if(arrow instanceof SpectralArrow){
loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 4.0F, false, false);
}
if(particleTasks.containsKey(arrow)){
server.getScheduler().cancelTask(particleTasks.get(arrow));
}
arrow.remove();
}
}
示例15: onProjectileHit
import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Arrow) {
Arrow arrow = (Arrow) entity;
if (!(arrow.getShooter() instanceof Player) || ((CraftArrow) arrow).getHandle().fromPlayer == 2) {
arrow.remove();
}
}
}