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


Java Projectile类代码示例

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


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

示例1: MagicMobDeathEvent

import org.bukkit.entity.Projectile; //导入依赖的package包/类
public MagicMobDeathEvent(MageController controller, EntityData entityData, EntityDeathEvent deathEvent) {
    this.controller = controller;
    this.entityData = entityData;
    this.deathEvent = deathEvent;
    
    LivingEntity killed = deathEvent.getEntity();
    EntityDamageEvent damageEvent = killed.getLastDamageCause();
    if (damageEvent instanceof EntityDamageByEntityEvent)
    {
        EntityDamageByEntityEvent damageByEvent = (EntityDamageByEntityEvent)damageEvent;
        Entity damagingEntity = damageByEvent.getDamager();
        if (damagingEntity instanceof Projectile) {
            Projectile projectile = (Projectile)damagingEntity;
            damagingEntity = (LivingEntity)projectile.getShooter();
        }
        if (damagingEntity != null && damagingEntity instanceof Player)
        {
            player = (Player)damagingEntity;
            mage = controller.getRegisteredMage(player.getUniqueId().toString());
        }
    }
}
 
开发者ID:elBukkit,项目名称:MagicAPI,代码行数:23,代码来源:MagicMobDeathEvent.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;

            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

示例3: 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

示例4: 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

示例5: 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

示例6: shoot

import org.bukkit.entity.Projectile; //导入依赖的package包/类
/**
 * A basic shoot method, it _can_ be overridden but take care.
 * Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
 * 
 * @param begin The location to shoot from
 * @param bulletType the Bullet type of this bullet
 * @param shooter the entity shooting
 * @param velocity the velocity to use as base for this shooting, if any
 * @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
 * @return the new Projectile that has been unleashed.
 */
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
	World world = begin.getWorld();
	begin = begin.clone();
	begin.setDirection(velocity);
	Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
			
	newBullet.setCustomName(this.bulletTag);
	newBullet.setBounce(false);
	newBullet.setGravity(true);
	newBullet.setShooter(shooter);
	
	bulletType.configureBullet(newBullet, world, shooter, velocity);
	
	if (overrideVelocity) {
		newBullet.setVelocity(velocity);
	}

	return newBullet;
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例7: tick

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@Repeatable(scope = MatchScope.RUNNING)
public void tick() {
    EntityUtils.entities(match.getWorld(), Projectile.class)
         .filter(projectile -> projectile.hasMetadata(TRAIL_META))
         .forEach(projectile -> {
             if(projectile.isDead() || projectile.isOnGround()) {
                 projectile.removeMetadata(TRAIL_META, PGM.get());
             } else {
                 final Color color = (Color) projectile.getMetadata(TRAIL_META, PGM.get()).value();
                 // Certain particles can have a specific color if:
                 // - Count is 0
                 // - Speed is 1
                 // - Delta vectors are RGB values from (0,1]
                 match.getWorld().spawnParticle(
                     Particle.REDSTONE,
                     projectile.getLocation(),
                     0,
                     rgbToParticle(color.getRed()),
                     rgbToParticle(color.getGreen()),
                     rgbToParticle(color.getBlue()),
                     1
                 );
             }
         });
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:ProjectileTrailMatchModule.java

示例8: onAttack

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@EventHandler
public void onAttack(EntityDamageByEntityEvent e) {
	if(!(e.getEntity() instanceof Player)) return;
	if(e.getDamager() instanceof Player || e.getDamager() instanceof Projectile) {
		
		
		
	if(mayPvP) {
		if(e.getDamager() instanceof Projectile) {
			
			
			handleShooting(e);
		} else {
			handleMelee(e);
		}
	} else {
		e.setCancelled(true);
		return;
	}
	} else {
		return;
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:24,代码来源:PvPManager.java

示例9: fireGun

import org.bukkit.entity.Projectile; //导入依赖的package包/类
private void fireGun(final Player shooter, final Class<? extends Projectile> projectile, final int count) {
    // 枪械射击
    new MoonLakeRunnable() {
        private int currentCount = count;

        @Override
        public void run() {
            if(currentCount <= 0) {
                cancel();
                return;
            }
            shooter.launchProjectile(projectile, shooter.getLocation().getDirection().normalize().multiply(3d));
            shooter.playSound(shooter.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 0.5f, 2f);
            shooter.playSound(shooter.getLocation(), Sound.ENTITY_SKELETON_HURT, 0.5f, 2f);
            shooter.playSound(shooter.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD, 0.5f, 2f);
            currentCount--;
        }
    }.runTaskTimer(getMain(), 0L, 2L);
}
 
开发者ID:lgou2w,项目名称:scp,代码行数:20,代码来源:PlayerInteractListener.java

示例10: onPvP

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPvP(EntityDamageByEntityEvent evt) {
    if (Parties.isParty(evt.getDamager()))
        return;

    Player attacker = evt.getDamager() instanceof Player ? (Player) evt.getDamager() :
            (evt.getDamager() instanceof Projectile && ((Projectile) evt.getDamager()).getShooter() instanceof Player
            ? (Player) ((Projectile) evt.getDamager()).getShooter() : null); // Yuck, maybe we can make a method for this later.
    if (attacker == null || !(evt.getEntity() instanceof Player))
        return; // One or both of the combatants isn't a player.

    boolean outgoingFail = !getToggle(attacker, Toggle.PVP);
    boolean incomingFail = !getToggle(evt.getEntity(), Toggle.PVP);

    if (outgoingFail || incomingFail) {
        attacker.sendMessage(ChatColor.RED + (outgoingFail ? "You have PvP disabled. (/togglepvp)"
                : evt.getEntity().getName() + " has PvP disabled."));
        evt.setCancelled(true);
        evt.getEntity().setFireTicks(-1); // Disable fire damage.
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:22,代码来源:Toggles.java

示例11: onProjectileLaunch

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
    Projectile projectile = event.getEntity();
    if (projectile instanceof EnderPearl) {
        EnderPearl enderPearl = (EnderPearl) projectile;
        ProjectileSource source = enderPearl.getShooter();
        if (source instanceof Player) {
            Player shooter = (Player) source;
            long remaining = getRemaining(shooter);
            if (remaining > 0L) {
                shooter.sendMessage(ChatColor.RED + "You are still on " + ChatColor.LIGHT_PURPLE + getName() + ChatColor.RED + " cooldown for another " + ChatColor.BOLD
                        + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.RED + '.');

                event.setCancelled(true);
                return;
            }

            if (setCooldown(shooter, shooter.getUniqueId(), defaultCooldown, true)) {
                startDisplaying(shooter);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:24,代码来源:EnderPearlTimer.java

示例12: notify

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@Override
public void notify(Player player, Object extra) {
    Location eye = player.getEyeLocation();
    Vector direction = eye.getDirection().multiply(2);
    Block source = (Block) extra;
    Projectile projectile = player.getWorld().spawn(source.getRelative(BlockFace.UP).getLocation().setDirection(direction), LargeFireball.class);
    projectile.setShooter(player);
    projectile.setVelocity(direction);
    
    Inventory inv = player.getInventory();
    if (inv.contains(Material.TNT)) {
        int slot = inv.first(Material.TNT);
        ItemStack ammo = inv.getItem(slot);
        int amount = ammo.getAmount();
        if (amount > 1) {
            ammo.setAmount(amount - 1);
            inv.setItem(slot, ammo);
        } else {
            inv.setItem(slot, null);
        }
        
        projectile.setCustomName("recreator.structure.turret.tnt");
    }
    
    AzureAPI.playSound(player, Sound.ITEM_FIRECHARGE_USE, true);
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:27,代码来源:StructureTurret.java

示例13: onHit

import org.bukkit.entity.Projectile; //导入依赖的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);
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:21,代码来源:StructureTurret.java

示例14: onHit

import org.bukkit.entity.Projectile; //导入依赖的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);
    }
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:21,代码来源:ItemFatMan.java

示例15: event

import org.bukkit.entity.Projectile; //导入依赖的package包/类
@EventHandler
public void event(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player) {
        OMGPlayer damaged = get((Player) e.getEntity());
        if (g.state != GameState.INGAME || damaged.team == g.spectatorTeam || damaged.invulnerable || (Area.registeredAreas.values().stream().anyMatch(a -> a.isInside(e.getEntity().getLocation().getBlock().getLocation()) && (!a.cancelDamage.containsKey(damaged.team) || a.cancelDamage.get(damaged.team).contains(OMGDamageCause.getByBukkit(e.getCause())))))) {
            e.setCancelled(true);
            return;
        }
        if (e.getDamager() instanceof Projectile) damaged.lastProjectileShotBy = (Projectile) e.getDamager();
        if (e.getDamager() instanceof Player || (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof Player)) {
            OMGPlayer damager = e.getDamager() instanceof Player ? get((Player) e.getDamager()) : get((Player) ((Projectile) e.getDamager()).getShooter());
            if (damaged.team == damager.team && !damaged.team.allowFriendlyFire) {
                e.setCancelled(true);
                e.setDamage(0);
                return;
            }
            damaged.lastDamager = damager;
        }
        new OMGDamageEvent(e, get((Player) e.getEntity()), e.getDamager(), OMGDamageCause.getByBukkit(e.getCause()), (float) e.getDamage());
    }
}
 
开发者ID:BurnyDaKath,项目名称:OMGPI,代码行数:22,代码来源:BukkitEventHandler.java


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