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


Java ProjectileHitEvent.getHitEntity方法代码示例

本文整理汇总了Java中org.bukkit.event.entity.ProjectileHitEvent.getHitEntity方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectileHitEvent.getHitEntity方法的具体用法?Java ProjectileHitEvent.getHitEntity怎么用?Java ProjectileHitEvent.getHitEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.entity.ProjectileHitEvent的用法示例。


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

示例1: onProjectileHit

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
    if (event.getEntityType() != EntityType.FISHING_HOOK &&
        event.getEntityType() != EntityType.SNOWBALL &&
        event.getEntityType() != EntityType.EGG) return;
    ProjectileSource shooter = ((Projectile) event.getEntity()).getShooter();
    if (shooter != null && shooter instanceof Player && event.getHitEntity() instanceof Damageable) {
        ((Damageable) event.getHitEntity()).damage(0.01, (Player) shooter);
    }

}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:12,代码来源:EntityDamageModule.java

示例2: onEntityCollision

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityCollision(ProjectileHitEvent event) {
	if (event.getEntity().hasMetadata("mysti_projectile")) {
		CustomProjectile proj =  (CustomProjectile) event.getEntity().getMetadata("mysti_projectile");
		if (event.getHitEntity() != null) {
			proj.onEntityCollision(event.getHitEntity());
		} else if (event.getHitBlock() != null) {
			proj.onBlockCollision(event.getHitBlock());
		}
	}
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:12,代码来源:CustomProjectileListener.java

示例3: onMobCatch

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMobCatch(ProjectileHitEvent e){
    Player p;
    if (e.getEntity().getShooter() instanceof Player) {
        p = (Player) e.getEntity().getShooter();
        if (canWork) {
            if (e.getEntity() instanceof Egg) {
                if (e.getHitEntity() instanceof Monster || e.getHitEntity() instanceof Animals || e.getHitEntity() instanceof Villager) {
                    if (mu.bannedMobs().contains(e.getEntity().getType())) {
                        p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "Este mob esta prohibido");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (!files.getConfig().getStringList("mundosPermitidos").contains(e.getEntity().getLocation().getWorld().getName())) {
                        p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "No se puede usar en este mundo");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (!vu.hasEnoughMoney(p, e.getHitEntity().getType().toString())) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No tienes dinero suficiente para hacer esto");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Animals){
                        LivingEntity le = (LivingEntity)e.getEntity();
                        if (le.getHealth() <= 0 || le.isDead()){
                            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes capturar a un mob muerto");
                            p.getInventory().addItem(pe.getPokeEgg());
                            return;
                        }
                    }

                    //To Fix
                    if (e.getEntity() instanceof Mule || e.getEntity() instanceof Donkey || e.getEntity() instanceof Llama){
                        p.sendMessage(ChatColor.RED + "Estos mobs están desactivados debido a un error de Minecraft.");
                        return;
                    }

                    SNMob mob = new SNMob(e.getHitEntity(), p);
                    mob.writeConfig();
                    mob.givePlayerEgg();

                    e.getHitEntity().remove();
                    p.sendMessage(this.plugin.getPrefix() + ChatColor.GREEN + "Has atrapado un mob");
                    p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);

                    vu.removeMoney(p, e.getHitEntity().getType().toString());

                    canWork = false;

                    if (e.getHitEntity().getType() == EntityType.VILLAGER) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "Los aldeanos tienen un pequeño error ahora mismo con los tradeos. Lo sentimos");
                    }
                }
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:59,代码来源:CatchMob.java

示例4: onMobCatch

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onMobCatch(ProjectileHitEvent e){
    Player p;
    if (e.getEntity().getShooter() instanceof Player) {
        p = (Player) e.getEntity().getShooter();
        if (canWork) {
            if (e.getEntity() instanceof Egg) {
                if (e.getHitEntity() instanceof Monster || e.getHitEntity() instanceof Animals || e.getHitEntity() instanceof Villager) {
                    if (mu.bannedMobs().contains(e.getEntity().getType())) {
                        p.sendMessage(this.plugin.getPrefix() + ChatColor.RED + "Este mob esta prohibido");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (!vu.hasEnoughMoney(p, e.getHitEntity().getType().toString())) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No tienes dinero suficiente para hacer esto");
                        p.getInventory().addItem(pe.getPokeEgg());
                        return;
                    }
                    if (e.getEntity() instanceof Monster || e.getEntity() instanceof Animals){
                        LivingEntity le = (LivingEntity)e.getEntity();
                        if (le.getHealth() <= 0 || le.isDead()){
                            p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes capturar a un mob muerto");
                            p.getInventory().addItem(pe.getPokeEgg());
                            return;
                        }
                    }

                    boolean canCatch = true;
                    ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
                    for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;

                    if (!canCatch) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes capturar a un mob en parcelas ajenas");
                        return;
                    }

                    //To Fix
                    if (e.getEntity() instanceof Mule || e.getEntity() instanceof Donkey || e.getEntity() instanceof Llama || e.getEntity() instanceof Villager){
                        p.sendMessage(ChatColor.RED + "Estos mobs están desactivados debido a un error de Minecraft.");
                        return;
                    }

                    SNMob mob = new SNMob(e.getHitEntity(), p);
                    mob.writeConfig();
                    mob.givePlayerEgg();

                    e.getHitEntity().remove();
                    p.sendMessage(this.plugin.getPrefix() + ChatColor.GREEN + "Has atrapado un mob");
                    p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);

                    vu.removeMoney(p, e.getHitEntity().getType().toString());

                    canWork = false;

                    if (e.getHitEntity().getType() == EntityType.VILLAGER) {
                        p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "Los aldeanos tienen un pequeño error ahora mismo con los tradeos. Lo sentimos");
                    }
                }
            }
        }
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:63,代码来源:CatchMob.java

示例5: onRodLand

import org.bukkit.event.entity.ProjectileHitEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onRodLand(ProjectileHitEvent e) {

	Entity hookEntity = e.getEntity();
	World world = hookEntity.getWorld();

	if (!isEnabled(world)) return;

	if (e.getEntityType() != EntityType.FISHING_HOOK)
		return;


	Entity hitent = null;

	try{
		hitent = e.getHitEntity();
	}
	catch(NoSuchMethodError e1){ //For older version that don't have such method
		Collection<Entity> entities = world.getNearbyEntities(hookEntity.getLocation(), 0.25, 0.25, 0.25);

		for (Entity entity : entities) {
			if (entity instanceof Player)
				hitent = entity;
			break;

		}
	}

	if(hitent == null) return;
	if(!(hitent instanceof Player)) return;

	FishHook hook = (FishHook) hookEntity;
	Player rodder = (Player) hook.getShooter();
	Player player = (Player) hitent;

	debug("You were hit by a fishing rod!", player);

	if (player.getUniqueId().equals(rodder.getUniqueId()))
		return;

	if(player.getGameMode() == GameMode.CREATIVE) return;

	double damage = module().getDouble("damage");
	if(damage < 0) damage = 0.2;

	EntityDamageEvent event = makeEvent(rodder, player, damage);
	Bukkit.getPluginManager().callEvent(event);

	if(module().getBoolean("checkCancelled") && event.isCancelled()){

		//This is to check what plugins are listening to the event
		if(plugin.getConfig().getBoolean("debug.enabled")){
			debug("You can't do that here!", rodder);
			HandlerList hl = event.getHandlers();

			for(RegisteredListener rl : hl.getRegisteredListeners())
				debug("Plugin Listening: " + rl.getPlugin().getName(), rodder);
		}

		return;
	}

	player.damage(damage);

	Location loc = player.getLocation().add(0, 0.5, 0);
	player.teleport(loc);
	player.setVelocity(loc.subtract(rodder.getLocation()).toVector().normalize().multiply(0.4));
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:69,代码来源:ModuleFishingKnockback.java


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