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


Java EntityShootBowEvent.setCancelled方法代码示例

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


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

示例1: onEntityShootBowEvent

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityShootBowEvent(EntityShootBowEvent event) {
    if ((event.getBow().hasItemMeta() && event.getBow().getItemMeta().getDisplayName().equals("Ender bow")) || event
            .getBow() instanceof EnderBowPlugin.EnderBow) {
        // Create custom event
        EntityShootEnderBowEvent entityShootEnderBowEvent = new EntityShootEnderBowEvent(event);

        // Call the custom event
        EnderBowPlugin.getInstance().getServer().getPluginManager().callEvent(entityShootEnderBowEvent);

        // Do the following, if it wasn't cancelled
        if (!entityShootEnderBowEvent.isCancelled()) {
            // Fire an ender pearl
            event.getEntity().launchProjectile(EnderPearl.class).setVelocity(event.getProjectile().getVelocity());

            // Play the 'ENDERMAN_TELEPORT' sound
            event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
        }

        // Cancel the original Event, so no arrows are fired
        event.setCancelled(true);
    }
}
 
开发者ID:jamierocks,项目名称:EnderBow,代码行数:24,代码来源:EnderBowListener.java

示例2: onShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent e){
	if (e.isCancelled() || !(e.getEntity() instanceof Player)){
		return;
	}
	
	Player p = (Player) e.getEntity();		
	Entity proj = e.getProjectile();
	List<String> Pots = RPConfig.getStringList("server-protection.deny-potions");
	
	if (proj != null && (proj instanceof TippedArrow)){
		TippedArrow arr = (TippedArrow) proj;
		if (Pots.contains(arr.getBasePotionData().getType().name())){
			RPLang.sendMessage(p, "playerlistener.denypotion");
			e.setCancelled(true);
		}
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:19,代码来源:RPMine19.java

示例3: onSkeletonShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onSkeletonShoot(EntityShootBowEvent event){
	if(event.getEntity() instanceof Skeleton){
		Skeleton s = (Skeleton) event.getEntity();
		if(DroneShocktroop.isPossiblyShocktroop(s)){
			DroneShocktroop troop = getShocktroop(s);
			if(troop == null){
				s.remove();
				//System.out.println("troop for named skeleton is null, removing!");
				event.setCancelled(true);
			} else {
				//System.out.println("Allowed fire!");
			}
		}
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:17,代码来源:SQSkywatch.java

示例4: onShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void onShoot(EntityShootBowEvent event)
{
	if ((event.getEntity() instanceof Player)) {
		Player archer = (Player)event.getEntity();
		if (archer.getAllowFlight()) {
			if ((archer.isFlying()) && (!archer.hasPermission("Fly.damage")) && 
					(archer.getGameMode() != GameMode.CREATIVE)) {
				event.setCancelled(true);
				archer.updateInventory();
			}
			if (!archer.isFlying() && archer.getGameMode() != GameMode.CREATIVE) {
				archer.setFlying(false);
				archer.setAllowFlight(false);
				archer.sendMessage(ChatColor.GOLD + "You were put out of fly mode.");
			}
		}
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:20,代码来源:FairFly.java

示例5: onArrowShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onArrowShoot(EntityShootBowEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			if(Team.getTeam((Player)event.getEntity()).equals(Minigame.getObservers())){
				event.setCancelled(true);
			}
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
开发者ID:tatanpoker09,项目名称:TCMinigames,代码行数:19,代码来源:PlayerListener.java

示例6: onEntityShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event) {
    if (event.getEntity() instanceof Player) {
        if (plugin.getMaterial("Harp").isMaterial(event.getBow())) {
            event.setCancelled(true);
            for (Player player : event.getEntity().getWorld().getPlayers()) {
                if (player.getLocation().distanceSquared(event.getEntity().getLocation()) <= 64) {
                    try {
                        File musicDirectory = new File(plugin.getDataFolder(), "music");
                        plugin.getJingleNoteManager().play(plugin, player.getName(), new MidiJingleSequencer(new File(musicDirectory, "canon.mid"), false));
                    } catch (MidiUnavailableException | InvalidMidiDataException | IOException exception) {
                        exception.printStackTrace();
                    }
                }
            }
        }
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:19,代码来源:EntityShootBowListener.java

示例7: onShootWithoutArrows

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onShootWithoutArrows(EntityShootBowEvent event)
{
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		if(player.getInventory().getItemInMainHand().getType() == event.getBow().getType())
		{
			if
			(
				player.getInventory().getItemInOffHand().getType() == Material.ARROW
				|| player.getInventory().getItemInOffHand().getType() == Material.SPECTRAL_ARROW
				|| player.getInventory().getItemInOffHand().getType() == Material.TIPPED_ARROW
			)
			{
				event.setCancelled(false);
			}
			else
			{
				event.setCancelled(true);
				player.sendMessage(ChatColor.RED + Survival.Words.get("Must load Arrows on off hand"));
				player.updateInventory();
			}
		}
		else
		{
			event.setCancelled(true);
			player.sendMessage(ChatColor.RED + Survival.Words.get("Must use a Bow with main hand"));
			player.updateInventory();
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:34,代码来源:Bow.java

示例8: onEntityShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
/**
 * Stop frozen players from firing bows
 */
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event) {
    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if (shouldFreeze(player)) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:redwallhp,项目名称:AthenaGM,代码行数:13,代码来源:PlayerFreezeModule.java

示例9: checkBowRestriction

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void checkBowRestriction(EntityShootBowEvent event) {
    if (!(event.getEntity() instanceof Player)) {
        return;
    }
    if (!LoreAttributes.loreManager.canUse((Player) event.getEntity(), event.getBow()))
        event.setCancelled(true);
}
 
开发者ID:SettingDust,项目名称:Lore-Attributes-Reloaded,代码行数:9,代码来源:LoreEvents.java

示例10: onShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent event) {
    if ((event.getEntity() instanceof Player)) {
        Player player = (Player) event.getEntity();
        if ((event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 2) || (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 3)) {
            if (player.hasPermission(PermLib.USE_ENDERBOW)) {
                if (player.getInventory().contains(Material.ENDER_PEARL)) {
                    if (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 2) {
                        event.setCancelled(true);
                        player.getInventory().removeItem(new ItemStack[] { new ItemStack(Material.ENDER_PEARL, 1)});
                        ((EnderPearl) player.launchProjectile(EnderPearl.class)).setVelocity(event.getProjectile().getVelocity().multiply(1.1D));
                        player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
                    } else if (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 3) {
                        event.setCancelled(true);
                        ((EnderPearl) player.launchProjectile(EnderPearl.class)).setVelocity(event.getProjectile().getVelocity().multiply(1.1D));
                        player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
                        event.getBow().setDurability((short) 384);
                    }
                } else {
                    event.setCancelled(true);
                }
            } else {
                player.sendMessage(ChatLib.NO_PERMS_ENDERBOW);
            }
        } else {}
    }
}
 
开发者ID:OmniWorldMC,项目名称:OmniWorldMCPlugin,代码行数:28,代码来源:EnderBowListener.java

示例11: on

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void on(EntityShootBowEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player && freezer.isCurrentlyFrozen(entity.getUniqueId())) {
        event.setCancelled(true);
    }
}
 
开发者ID:Eluinhost,项目名称:FancyFreeze,代码行数:8,代码来源:DamageListener.java

示例12: onShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
public void onShoot(EntityShootBowEvent event) {
	if ((event.getEntity() instanceof Player)) {
		Player archer = (Player) event.getEntity();
		if (isGod(archer)) {
			if (!archer.getWorld().getName().equals("EventWorld")) {
				if (archer.getGameMode() == GameMode.SURVIVAL) {
					event.setCancelled(true);
					toggleGod(archer, true);
				}
			} else {
				toggleGod(archer, true);
			}
		}
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:16,代码来源:FairGod.java

示例13: onShoot

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShoot(EntityShootBowEvent event)
{
	if(event.getEntity() instanceof Player)
	{
		Player player = (Player)event.getEntity();
		ItemStack mainItem = event.getBow();
		
		if(mainItem.getItemMeta().getLore() != null)
		{
			Random rand = new Random();
			if(event.getForce() >= 1.0F)
			{
				final Entity arrow = event.getProjectile();
				final Vector velocity = player.getLocation().getDirection().add(new Vector(0, 0.025, 0)).multiply(4);
				arrow.setVelocity(velocity);
	
	            player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
	            player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SHULKER_BULLET_HURT, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
				
				final Runnable task = new Runnable()
				{
					int times = 4;
					public void run()
					{								
						if(!arrow.isOnGround())
						{
							arrow.setVelocity(velocity);
							if(times-- > 0)
								Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 5);
						}
					}
				};
				
				Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1);
			}
			else
			{
				event.setCancelled(true);
	            player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:45,代码来源:RecurvedBow.java

示例14: onShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent event) {
	event.setCancelled(true);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:5,代码来源:PreEvents.java

示例15: onEntityShootBow

import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
    if (this.isObserving(event.getEntity())) {
        event.setCancelled(true);
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:7,代码来源:ObserverListeners.java


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