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


Java ProjectileSource类代码示例

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


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

示例1: shoot

import org.bukkit.projectiles.ProjectileSource; //导入依赖的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

示例2: onDamage

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
/**
 * Switch players on arrow hit
 *
 * @param event Event instance
 */
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageByEntityEvent event)
{
    if (!event.isCancelled() && event.getDamager() instanceof Arrow && event.getEntity() instanceof Player)
    {
        ProjectileSource source = ((Arrow)event.getDamager()).getShooter();

        if (source == null || !(source instanceof Player))
            return;

        Player player = (Player)source;
        Location tmp = player.getLocation();

        player.teleport(event.getEntity());
        event.getEntity().teleport(tmp);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:SwitcherooModule.java

示例3: onPlayerFish

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerFish(PlayerFishEvent event) {
    double amount = event.getExpToDrop();
    if (amount > 0) {
        amount = Math.ceil(amount * SettingsYML.EXP_MULTIPLIER_FISHING);
        ProjectileSource projectileSource = event.getHook().getShooter();
        if (projectileSource instanceof Player) {
            ItemStack stack = ((Player) projectileSource).getItemInHand();
            int enchantmentLevel = stack.getEnchantmentLevel(Enchantment.LUCK);
            if (enchantmentLevel > 0L) {
                amount = Math.ceil(amount * (enchantmentLevel * SettingsYML.EXP_MULTIPLIER_LUCK_PER_LEVEL));
            }
        }

        event.setExpToDrop((int) amount);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:ExpMultiplierListener.java

示例4: onProjectileLaunch

import org.bukkit.projectiles.ProjectileSource; //导入依赖的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

示例5: onProjectileHit

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileHit(EntityDamageByEntityEvent e){
	Entity entity = e.getEntity();
	Entity damager = e.getDamager();
	if(entity != null && entity instanceof Player && damager.getType().equals(EntityType.ARROW)){
		Player player = (Player) entity;
		if(isEnabled(player.getWorld())){
			ProjectileSource shooter = ((Arrow) damager).getShooter();
			if(shooter instanceof Player){
				Player shootingPlayer = (Player) shooter;
				if(player.getUniqueId().equals(shootingPlayer.getUniqueId())){
					e.setCancelled(true);
					debug("We cancelled your bow boost", player);
				}
			}
		}
	}
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:19,代码来源:ModuleDisableBowBoost.java

示例6: onProjectileHit

import org.bukkit.projectiles.ProjectileSource; //导入依赖的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

示例7: getLivingEntityDamager

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
/**
 * Gets the {@link LivingEntity} from a {@link EntityDamageByEntityEvent}. If the {@link
 * EntityDamageByEntityEvent#getDamager()} is a LivingEntity, then that instance is returned.
 * Otherwise, if the damager is a projectile and it's shooter is a LivingEntity, that
 * LivingEntity
 * shooter instance is returned.
 *
 * @param event event to get LivingEntity from
 *
 * @return instance of {@link LivingEntity}, nullable
 */
public static LivingEntity getLivingEntityDamager(@Nonnull EntityDamageByEntityEvent event) {
  checkNotNull(event, "event cannot be null.");
  // This is the living entity
  if (event.getDamager() instanceof LivingEntity) {
    return ((LivingEntity) event.getDamager());
  }
  // Check for projectile's shooter
  if (event.getDamager() instanceof Projectile) {
    ProjectileSource shooter = ((Projectile) event.getDamager()).getShooter();
    if (shooter != null && shooter instanceof LivingEntity) {
      return ((LivingEntity) shooter);
    }
  }
  return null;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:27,代码来源:EventUtils.java

示例8: onEntityDamage

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent event) {
    if ((!killAnimalsEnabled && !killMonstersEnabled) || !plugin.isSkyAssociatedWorld(event.getDamager().getWorld())) {
        return;
    }
    if (!(event.getEntity() instanceof Creature)) {
        return;
    }
    if (event.getDamager() instanceof Player
            && !plugin.playerIsOnIsland((Player)event.getDamager())) {
        if (hasPermission(event.getDamager(), "usb.mod.bypassprotection")) {
            return;
        }
        cancelMobDamage(event);
    } else if (event.getDamager() instanceof Projectile) {
        ProjectileSource shooter = ((Projectile) event.getDamager()).getShooter();
        if (!(shooter instanceof Player)) {
            return;
        }
        Player player = (Player) shooter;
        if (hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) {
            return;
        }
        cancelMobDamage(event);
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:27,代码来源:GriefEvents.java

示例9: sourcesEqual

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
/**
 * INTERNAL METHOD. Determines if the sources of two damage events are equal.
 */
static boolean sourcesEqual(DamageData a, DamageData b){
	if(a == null){
		return b == null;
	}
	if(b == null){
		return a == null;
	}
	
	if(a.getRawSource() == null){
		return b.getRawSource() == null;
	}
	if(b.getRawSource() == null){
		return a.getRawSource() == null;
	}
	
	if(a.getRawSource() instanceof Projectile){
		ProjectileSource aSrc = a.getSourceAsProjectile().getShooter();
		ProjectileSource bSrc = b.getSourceAsProjectile().getShooter();
		
		return Utilities.equals(aSrc, bSrc);
	}
	
	return Utilities.equals(a.getRawSource(), b.getRawSource());
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:28,代码来源:DamageData.java

示例10: findAttacker

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@Nullable
public Player findAttacker(EntityDamageByEntityEvent event) {
    Player attackerPlayer = null;
    Entity attackerEntity = event.getDamager();

    if (attackerEntity instanceof Player) {
        attackerPlayer = (Player) attackerEntity;
    } else if (attackerEntity instanceof Projectile) {
        ProjectileSource shooter = ((Projectile) attackerEntity).getShooter();

        if (shooter instanceof Player) {
            attackerPlayer = (Player) shooter;
        }
    }

    return attackerPlayer;
}
 
开发者ID:mc-societies,项目名称:societies,代码行数:18,代码来源:DamageListener.java

示例11: projectileDamageAnimal

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
private void projectileDamageAnimal(EntityDamageByEntityEvent event) {
    final Tameable animal = (Tameable) event.getEntity();
    final ProjectileSource source = ((Projectile) event.getDamager()).getShooter();
    if (source instanceof Player) {
        // If a player harmed the animal
        final Player player = (Player) source;
        if (!canPlayerHurt(animal, player, false)) {
            event.setCancelled(true);
            new LangString("error.protected", getAnimal(event.getEntityType())).send(player);
        }
    }
    else if (source instanceof Monster) {
        // If a monster harmed the animal
        if (getProtectionConfig().getBoolean("monster-ranged"))
            event.setCancelled(true);
    }
    else {
        // If something else harmed the animal (eg, dispenser)
        if (getProtectionConfig().getBoolean("other-ranged"))
            event.setCancelled(true);
    }
}
 
开发者ID:RobotoRaccoon,项目名称:StableMaster,代码行数:23,代码来源:EntityDamageListeners.java

示例12: onProjectileLaunch

import org.bukkit.projectiles.ProjectileSource; //导入依赖的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: getDamager

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
private Player getDamager(Entity entity) {
	if (entity == null){
		return null;
	} else
	if (entity instanceof Player) {
		return (Player) entity;
	} else if (entity instanceof Projectile) {
		final ProjectileSource source = ((Projectile) entity).getShooter();
		if (source instanceof Entity) {
			return getDamager((Entity) source);
		} else {
			return null;
		}
	} else {
		return null;
	}
}
 
开发者ID:ST-DDT,项目名称:CrazyLogin,代码行数:18,代码来源:DynamicPlayerListener.java

示例14: onProjectileLaunchEvent

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@EventHandler
public void onProjectileLaunchEvent(ProjectileLaunchEvent event) {
	Projectile projectile = event.getEntity();
	ProjectileSource source = projectile.getShooter();
	
	if (!(source instanceof Player)) {
		return;
	}
	
	SpleefPlayer shooter = getHeavySpleef().getSpleefPlayer(((Player) source));
	if (!game.isIngame(shooter)) {
		return;
	}
	
	ItemStack stack = shooter.getBukkitPlayer().getItemInHand();
	stack.setDurability((short)0);
	shooter.getBukkitPlayer().setItemInHand(stack);
}
 
开发者ID:xaniox,项目名称:HeavySpleef,代码行数:19,代码来源:FlagBowspleef.java

示例15: onEntityDamageByEntity

import org.bukkit.projectiles.ProjectileSource; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamageByEntity(final ExtendedEntityDamageEvent ext) {
    if (ext.getBaseEvent() instanceof EntityDamageByEntityEvent) {
        final EntityDamageByEntityEvent event = (EntityDamageByEntityEvent)ext.getBaseEvent();
        final Player p;
        if (event.getDamager().getType() == EntityType.PLAYER) {
            p = (Player)event.getDamager();
        } else if (event.getDamager() instanceof Projectile) {
            final ProjectileSource shooter = ((Projectile)event.getDamager()).getShooter();
            if (shooter != null && shooter instanceof Player) {
                p = (Player)shooter;
            } else {
                return;
            }
        } else {
            return;
        }
        if (getAnimals().contains(event.getEntityType()) &&
            ext.getEntityRegion() != null &&
            ext.getEntityRegion().getFlag(Flag.FARM) &&
            !ext.getEntityRegion().isUser(p)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:26,代码来源:FarmFlagListener.java


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