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


Java Arrow.setMetadata方法代码示例

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


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

示例1: use

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public boolean use(Player player) {
    boolean containsBow = false;
    for (ItemStack item : player.getInventory().getContents()) {
        if (item != null) {
            if (item.getType() == Material.BOW) {
                containsBow = true;
                break;
            }
        }
    }
    if (containsBow) {
        if (player.getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1) && player.getInventory().containsAtLeast(new ItemStack(Material.FERMENTED_SPIDER_EYE), 1)) {
            Plugin plugin = Bukkit.getServer().getServicesManager().getRegistration(SkillsPlugin.class).getProvider();
            final Arrow arrow = player.launchProjectile(Arrow.class);
            arrow.setMetadata("isPoisonArrow", new FixedMetadataValue(plugin, true));
            player.getInventory().removeItem(new ItemStack(Material.ARROW), new ItemStack(Material.FERMENTED_SPIDER_EYE));
            return true;
        } else {
            player.sendMessage(ChatColor.RED + "You require a fermented spider eye and an arrow to create a poisoned arrow.");
        }
    } else {
        player.sendMessage(ChatColor.RED + "You require a bow to launch a poisoned arrow.");
    }
    return false;
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:27,代码来源:PoisonArrowSkill.java

示例2: use

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public boolean use(Player player) {
    boolean containsBow = false;
    for (ItemStack item : player.getInventory().getContents()) {
        if (item != null) {
            if (item.getType() == Material.BOW) {
                containsBow = true;
                break;
            }
        }
    }
    if (containsBow) {
        if (player.getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1)) {
            Arrow arrow = player.launchProjectile(Arrow.class);
            arrow.setMetadata("isPowerShot", new FixedMetadataValue(plugin, true));
            player.getInventory().removeItem(new ItemStack(Material.ARROW));
            return true;
        } else {
            player.sendMessage(ChatColor.RED + "You require an arrow.");
        }
    } else {
        player.sendMessage(ChatColor.RED + "You require a bow.");
    }
    return false;
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:26,代码来源:PowerShotSkill.java

示例3: use

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public boolean use(Player player) {
    boolean containsBow = false;
    for (ItemStack item : player.getInventory().getContents()) {
        if (item != null) {
            if (item.getType() == Material.BOW) {
                containsBow = true;
                break;
            }
        }
    }
    if (containsBow) {
        if (player.getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1)) {
            Arrow arrow = player.launchProjectile(Arrow.class);
            arrow.setMetadata("isRazorShot", new FixedMetadataValue(plugin, true));
            player.getInventory().removeItem(new ItemStack(Material.ARROW));
            return true;
        } else {
            player.sendMessage(ChatColor.RED + "You require an arrow.");
        }
    } else {
        player.sendMessage(ChatColor.RED + "You require a bow.");
    }
    return false;
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:26,代码来源:RazorShotSkill.java

示例4: use

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public boolean use(Player player) {
    boolean containsBow = false;
    for (ItemStack item : player.getInventory().getContents()) {
        if (item != null) {
            if (item.getType() == Material.BOW) {
                containsBow = true;
                break;
            }
        }
    }
    if (containsBow) {
        if (player.getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1) && player.getInventory().containsAtLeast(new ItemStack(Material.STRING), 1)) {
            Plugin plugin = Bukkit.getServer().getServicesManager().getRegistration(SkillsPlugin.class).getProvider();
            final Arrow arrow = player.launchProjectile(Arrow.class);
            arrow.setMetadata("isSnareShot", new FixedMetadataValue(plugin, true));
            player.getInventory().removeItem(new ItemStack(Material.ARROW), new ItemStack(Material.STRING));
            return true;
        } else {
            player.sendMessage(ChatColor.RED + "You require some string and an arrow to create a snare shot.");
        }
    } else {
        player.sendMessage(ChatColor.RED + "You require a bow to launch a snare shot.");
    }
    return false;
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:27,代码来源:SnareShotSkill.java

示例5: launch

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
@Override
public void launch(Player p, Vector vector) {
    Arrow arrow = p.launchProjectile(Arrow.class);
    if (vector == null) {
        arrow.setVelocity(p.getEyeLocation().getDirection().multiply(2));
    } else {
        arrow.setVelocity(vector);
    }
    arrow.setShooter(p);
    arrow.setMetadata("skill_type", new FixedMetadataValue(Main.getInstance(), getName()));
    CooldownManager.getInstance().add(p);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:13,代码来源:Archer.java

示例6: volley

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
private void volley(EntityShootBowEvent e, ItemStack item, int lvl) {
    Player p = (Player) e.getEntity();
    int amount = 1 + 2 * lvl; // Keep amount of arrows uneven, 2 extra arrows in a volley per level.

    Arrow oldArrow = (Arrow) e.getProjectile();
    int fireTicks = oldArrow.getFireTicks();
    int knockbackStrength = oldArrow.getKnockbackStrength();
    boolean critical = oldArrow.isCritical();
    String metadata = oldArrow.getMetadata("ce.bow.enchantment").get(0).asString();

    double angleBetweenArrows = (CONE_DEGREES / (amount - 1)) * Math.PI / 180;
    double pitch = (p.getLocation().getPitch() + 90) * Math.PI / 180;
    double yaw = (p.getLocation().getYaw() + 90 - CONE_DEGREES / 2) * Math.PI / 180;

    // Starting direction values for the cone, each arrow increments it's direction on these values.
    double sZ = Math.cos(pitch);

    for (int i = 0; i < amount; i++) { // spawn all arrows in a cone of 90 degrees (equally distributed).;
        double nX = Math.sin(pitch) * Math.cos(yaw + angleBetweenArrows * i);
        double nY = Math.sin(pitch) * Math.sin(yaw + angleBetweenArrows * i);
        Vector newDir = new Vector(nX, sZ, nY);

        Arrow arrow = p.launchProjectile(Arrow.class);
        arrow.setShooter(p);
        arrow.setVelocity(newDir.normalize().multiply(oldArrow.getVelocity().length())); // Need to make sure arrow has same speed as original arrow.
        arrow.setFireTicks(fireTicks); // Set the new arrows on fire if the original one was 
        arrow.setKnockbackStrength(knockbackStrength);
        arrow.setCritical(critical);

        if (i == 0) {
            if (p.getGameMode().equals(GameMode.CREATIVE))
                arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        } else {
            arrow.setMetadata("ce.Volley", new FixedMetadataValue(getPlugin(), null)); //Control metadata to prevent players from duplicating arrows
        }
        arrow.setMetadata("ce.bow.enchantment", new FixedMetadataValue(getPlugin(), metadata));
    }
    oldArrow.remove(); // Remove original arrow.
}
 
开发者ID:Taiterio,项目名称:ce,代码行数:40,代码来源:Volley.java

示例7: playerInteraction

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
public static void playerInteraction(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	if (event.getAction() == Action.RIGHT_CLICK_AIR
			|| event.getAction() == Action.RIGHT_CLICK_BLOCK) {
		ItemStack item = ParticleCondenser.getItem();
		boolean isItemType = event.getPlayer().getItemInHand().getType()
				.equals(item.getType());
		boolean hasMeta = event.getPlayer().getItemInHand().hasItemMeta();
		boolean hasName = false;
		if (hasMeta) {
			hasName = event.getPlayer().getItemInHand().getItemMeta()
					.hasDisplayName();
		}
		boolean equalsName = false;
		if (hasName) {
			equalsName = event.getPlayer().getItemInHand().getItemMeta()
					.getDisplayName()
					.equalsIgnoreCase(item.getItemMeta().getDisplayName());
		}
		if (isItemType && hasMeta && hasName && equalsName) {
			if (event.getPlayer().getItemInHand().getDurability() < 385) {
				Arrow arrow = player.launchProjectile(Arrow.class);
				arrow.setMetadata("miningLaser", new MiningLaserData(
						HyperDriveCraft.me, "block"));
				arrow.setFireTicks(10000);

				event.getPlayer()
						.getItemInHand()
						.setDurability(
								(short) (event.getPlayer().getItemInHand()
										.getDurability() + 2));
			}
		} else if (hasMeta
				&& hasName
				&& event.getPlayer()
						.getItemInHand()
						.getItemMeta()
						.getDisplayName()
						.equalsIgnoreCase(
								ReturnToShip.getItem().getItemMeta()
										.getDisplayName())) {
			event.getPlayer().setItemInHand(new ItemStack(Material.AIR, 1));
			Teleportation.teleportToPlayer(player, player.getName());
		}
	}

	if (event.getClickedBlock() != null
			&& event.getClickedBlock().getType().equals(Material.WORKBENCH)
			&& event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
		event.setCancelled(true);
		openInventory(event.getPlayer(), event.getClickedBlock());
		return;
	} else if (event.getClickedBlock() != null
			&& event.getClickedBlock().getType()
					.equals(Material.ACTIVATOR_RAIL)) {
		PartPlacer.place(event);
		return;
	}

	if (event.getClickedBlock() != null
			&& event.getClickedBlock().getType().equals(Material.BEACON)
			&& event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
			&& ProtectedBlock.isTeleporter(event.getClickedBlock())) {
		Teleportation.doTeleportation(event.getPlayer());
		event.setCancelled(true);
		return;
	}

	if (event.getItem() != null
			&& event.getItem().hasItemMeta()
			&& event.getItem().getItemMeta().hasDisplayName()
			&& event.getItem().getItemMeta().getDisplayName()
					.endsWith("(Part)")) {
		event.setCancelled(true);
		event.getPlayer().sendMessage(
				ChatColor.RED + "You need to place this on a rail!");
	}
}
 
开发者ID:mineglow-network,项目名称:HyperDriveCraft,代码行数:79,代码来源:WorldInteraction.java

示例8: fireBlaster

import org.bukkit.entity.Arrow; //导入方法依赖的package包/类
public static void fireBlaster(Player player) {
	
	ItemStack handItem = player.getItemInHand();
	
	if (handItem.getType() == Material.BOW && !player.hasMetadata("reload_timer") && !player.hasMetadata("fire_timer") && handItem.getItemMeta().hasLore()) {
		
		List<String> bowLore = handItem.getItemMeta().getLore();
		int bowFlame = handItem.getEnchantmentLevel(Enchantment.ARROW_FIRE);
		
		if (!bowLore.get(0).substring(10).equals("new blaster")) {
			
			int ammo = Integer.parseInt(bowLore.get(2).substring(10));
			int ammoPerPack = Integer.parseInt(bowLore.get(1).substring(19));
			int fireTime = Integer.parseInt(bowLore.get(5).substring(15));
			
			if (ammo != 0) {
				
				Bukkit.getWorlds().get(0).playSound(player.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
				
				Arrow arrow = player.launchProjectile(Arrow.class);
			
				arrow.setMetadata("damage", new FixedMetadataValue(Main.getPluginMain(), bowLore.get(3).substring(12)));
				arrow.setMetadata("no_pickup", new FixedMetadataValue(Main.getPluginMain(), true));
				arrow.setShooter(player);
			
				drainBlasterAmmo(player);
				
				if (bowFlame == 1) {
				
					arrow.setFireTicks(Main.getPluginConfig().getInt(bowLore.get(0).substring(10) + ".flame ticks"));
				
				}
				
				(new Timer()).run(player, ammoPerPack, "fire_timer", fireTime);
				
			} else {
				
				reloadBlaster(player);
				
			}
			
		}
		
	}
	
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:47,代码来源:Events.java


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