當前位置: 首頁>>代碼示例>>Java>>正文


Java Item.setMetadata方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Item.setMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java Item.setMetadata方法的具體用法?Java Item.setMetadata怎麽用?Java Item.setMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Item的用法示例。


在下文中一共展示了Item.setMetadata方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onInteract

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getClickedBlock().getType() == Material.CAULDRON) {
			if (e.getClickedBlock().getLocation().add(0, -1, 0).getBlock().getType() == Material.DIAMOND_BLOCK) {
				Item item = e.getPlayer().getWorld().dropItem(e.getClickedBlock().getLocation().add(0.5, 2, 0.5), e.getPlayer().getEquipment().getItemInMainHand());
				item.setMetadata("item-owner", new FixedMetadataValue(NationZ.plugin, e.getPlayer().getUniqueId().toString()));
				item.setVelocity(new Vector(0, 0, 0));
				item.setCustomName(item.getName());
				item.setCustomNameVisible(true);
				e.getPlayer().getEquipment().setItemInMainHand(null);
				e.setCancelled(true);
			}
		}
	}
}
 
開發者ID:crazyhorse961,項目名稱:NationZ,代碼行數:17,代碼來源:JobEnchanter.java

示例2: disarmCheck

import org.bukkit.entity.Item; //導入方法依賴的package包/類
/**
 * Check for disarm.
 *
 * @param defender The defending player
 */
public void disarmCheck(Player defender) {
    if (SkillUtils.activationSuccessful(SecondaryAbility.DISARM, getPlayer(), getSkillLevel(), activationChance) && !hasIronGrip(defender)) {
        if (EventUtils.callDisarmEvent(defender).isCancelled()) {
            return;
        }

        Item item = Misc.dropItem(defender.getLocation(), defender.getItemInHand());

        if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
            item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
        }

        defender.setItemInHand(new ItemStack(Material.AIR));
        defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:22,代碼來源:UnarmedManager.java

示例3: cast

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
    Location loc = p.getLocation().add(0, p.getEyeHeight() * 0.8, 0);
    loc.add(p.getLocation().getDirection().normalize().multiply(0.4));
    final Item item = p.getWorld().dropItem(loc, new ItemStack(Material.FIREBALL));
    item.setMetadata(RMetadata.META_NO_PICKUP, new FixedMetadataValue(Spell.plugin, 0));
    //        ItemManager.attachLabel(item, ChatColor.BOLD + "= " + p.getName() + "'s Bomb =");
    Spell.plugin.getInstance(DropManager.class).attachLabel(item, ChatColor.DARK_GRAY.toString() + ChatColor.ITALIC + p.getName());
    Vector dir = p.getLocation().getDirection().normalize();
    dir.setY(dir.getY() * 1.1);
    dir.multiply(0.6);
    item.setVelocity(dir);
    int damage = pd.getDamage(true);
    damage *= this.functions[0].applyAsDouble(level) / 100.0;
    final int fDamage = damage;
    RScheduler.schedule(Spell.plugin, new Runnable() {
        public void run() {
            if (item == null || !item.isValid())
                return;
            RParticles.show(ParticleEffect.EXPLOSION_LARGE, item.getLocation(), 5);
            Spell.damageNearby(fDamage, p, item.getLocation(), 3, new ArrayList<Entity>());
            DropManager.removeLabel(item);
            item.remove();
        }
    }, RTicks.seconds(1));
    Spell.notify(p, "You throw a small bomb.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:29,代碼來源:Bomb.java

示例4: insertItem

import org.bukkit.entity.Item; //導入方法依賴的package包/類
private void insertItem(Player p, Block b) {
	final ItemStack stack = p.getInventory().getItemInMainHand();
	if (stack != null) {
		PlayerInventory.consumeItemInHand(p);
		String nametag = StringUtils.formatItemName(stack, false);
		Item entity = b.getWorld().dropItem(b.getLocation().add(0.5, 1.2, 0.5), new CustomItem(new CustomItem(stack, 1), "&5&dALTAR &3Probe - &e" + System.nanoTime()));
		entity.setVelocity(new Vector(0, 0.1, 0));
		entity.setMetadata("no_pickup", new FixedMetadataValue(SlimefunStartup.instance, "altar_item"));
		entity.setCustomNameVisible(true);
		entity.setCustomName(nametag);
		p.playSound(b.getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.3F, 0.3F);
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:14,代碼來源:AncientAltarListener.java

示例5: onPlayerDropItem

import org.bukkit.entity.Item; //導入方法依賴的package包/類
/**
 * Monitor PlayerDropItemEvents.
 * <p>
 * These events are monitored for the purpose of flagging sharable
 * dropped items, as well as removing ability buffs from pickaxes
 * and shovels.
 *
 * @param event The event to monitor
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    Item drop = event.getItemDrop();
    ItemStack dropStack = drop.getItemStack();

    if (ItemUtils.isSharable(dropStack)) {
        drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
    }

    SkillUtils.removeAbilityBuff(dropStack);
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:21,代碼來源:PlayerListener.java

示例6: cast

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
    int damage = pd.getDamage(true);
    int amount = 0;
    damage *= functions[1].applyAsDouble(level) / 100.0;
    amount = (int) functions[0].applyAsDouble(level);
    Location loc = p.getLocation().add(0, p.getEyeHeight() * 0.8, 0);
    loc.add(p.getLocation().getDirection().normalize().multiply(0.4));
    for (int count = 0; count < amount; count++) {
        final Item item = p.getWorld().dropItem(loc, new ItemStack(Material.FIREWORK_CHARGE));
        item.setMetadata(RMetadata.META_NO_PICKUP, new FixedMetadataValue(Spell.plugin, 0));
        //            ItemManager.attachLabel(item, ChatColor.BOLD + "= " + p.getName() + "'s Mine =");
        Spell.plugin.getInstance(DropManager.class).attachLabel(item, ChatColor.DARK_GRAY.toString() + ChatColor.ITALIC + p.getName());
        Vector dir = Vector.getRandom();
        dir.setX(dir.getX() - 0.5f);
        dir.setZ(dir.getZ() - 0.5f);
        dir = dir.normalize().multiply(Math.random() * 0.5 + 0.2);
        item.setVelocity(dir);
        final int fDamage = damage;
        RScheduler.schedule(Spell.plugin, new Runnable() {
            int tick = 1;
            ArrayList<Entity> hit = new ArrayList<Entity>();

            public void run() {
                if (item == null || !item.isValid())
                    return;
                hit.addAll(Spell.damageNearby(fDamage, p, item.getLocation(), 2.0, hit));
                if (hit.size() > 0) {
                    Spell.damageNearby(fDamage, p, item.getLocation(), 3, hit);
                    DropManager.removeLabel(item);
                    item.remove();
                    RParticles.show(ParticleEffect.EXPLOSION_LARGE, item.getLocation(), 5);
                }
                if (tick == 20) {
                    RParticles.show(ParticleEffect.CLOUD, item.getLocation().add(0, 0.1, 0));
                    DropManager.removeLabel(item);
                    item.remove();
                }
                tick++;
                if (tick <= 20)
                    RScheduler.schedule(Spell.plugin, this, (int) (Math.random() * 7 + 6));
            }
        }, 5);
    }
    Spell.notify(p, "You scatter a field of explosive mines.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:48,代碼來源:Minefield.java

示例7: cast

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
    Location loc = p.getLocation().add(0, p.getEyeHeight() * 0.8, 0);
    loc.add(p.getLocation().getDirection().normalize().multiply(0.4));
    final Item item = p.getWorld().dropItem(loc, new ItemStack(Material.FURNACE));
    item.setMetadata(RMetadata.META_NO_PICKUP, new FixedMetadataValue(Spell.plugin, 0));
    //        ItemManager.attachLabel(item, ChatColor.BOLD + "= " + p.getName() + "'s Smoke =");
    Spell.plugin.getInstance(DropManager.class).attachLabel(item, ChatColor.DARK_GRAY.toString() + ChatColor.ITALIC + p.getName());
    Vector dir = p.getLocation().getDirection().normalize();
    dir.setY(dir.getY() * 1.1);
    dir.multiply(0.6);
    item.setVelocity(dir);
    int duration = 1;
    switch (level) {
        case 1:
            duration = 3;
            break;
        case 2:
            duration = 5;
            break;
        case 3:
            duration = 7;
            break;
    }
    final int fDuration = duration * 2;
    for (int k = 1; k <= fDuration; k++) {
        final int kVal = k;
        RScheduler.schedule(Spell.plugin, new Runnable() {
            static final int RANGE = 10;

            public void run() {
                if (item == null || !item.isValid())
                    return;
                for (int k = 0; k < 25; k++) {
                    switch ((int) (Math.random() * 4)) {
                        case 0:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.SMOKE_LARGE, item.getLocation(), RANGE, 30);
                            break;
                        case 1:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.SMOKE_NORMAL, item.getLocation(), RANGE, 30);
                            break;
                        case 2:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.CLOUD, item.getLocation(), RANGE, 30);
                            break;
                        case 3:
                            RParticles.showWithOffsetPositiveY(ParticleEffect.EXPLOSION_LARGE, item.getLocation(), RANGE, 20);
                            break;
                    }
                }
                if (kVal == fDuration) {
                    DropManager.removeLabel(item);
                    item.remove();
                }
            }
        }, k * 10);
    }
    Spell.notify(p, "You throw a device that generates smoke.");
    return true;
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:60,代碼來源:QuickSmoke.java

示例8: displayDeathBlood

import org.bukkit.entity.Item; //導入方法依賴的package包/類
public static void displayDeathBlood(Player p) {
	for (int i = 0 ; i < 5 ; i++) {
		ItemStack redDust = new ItemStack(Material.INK_SACK, 1, (byte) 1);
		ItemMeta redDustMeta = redDust.getItemMeta();
		redDustMeta.setDisplayName("" + i);
		redDust.setItemMeta(redDustMeta);
		
		Location loc = p.getEyeLocation();
		loc.setY(loc.getY() - 0.5);
		final Item redstoneItem = p.getWorld().dropItem(loc, redDust);
		double X = Math.random() * 0.40 - 0.20;
		double Z = Math.random() * 0.40 - 0.20;
		Vector v = redstoneItem.getLocation().toVector();
		redstoneItem.setVelocity(v.normalize().setX(X).setZ(Z));
		
		redstoneItem.setMetadata("CODnoPickup", new FixedMetadataValue(ThisPlugin.getPlugin(), redstoneItem));
		
		BukkitRunnable br1 = new BukkitRunnable() {
			public void run() {
				if (!Bukkit.getOnlinePlayers().isEmpty()) ParticleEffect.REDSTONE.display((float) 0.01, (float) 0.01, (float) 0.01, 0, 10, redstoneItem.getLocation());
				redstoneItem.remove();
			}
		};
		
		int time = new Random().nextInt(/*Max*/4 - /*Min*/2 + 1) + 2;
		br1.runTaskLater(ThisPlugin.getPlugin(), 20 * time);
		
		//================================================================================
		
		ItemStack redDye = new ItemStack(Material.INK_SACK, 1, (byte) 1);
		ItemMeta redDyeMeta = redDye.getItemMeta();
		redDyeMeta.setDisplayName("" + i);
		redDust.setItemMeta(redDyeMeta);
		
		final Item redDyeItem = p.getWorld().dropItem(loc, redDye);
		X = Math.random() * 0.40 - 0.20;
		Z = Math.random() * 0.40 - 0.20;
		v = redDyeItem.getLocation().toVector();
		redDyeItem.setVelocity(v.normalize().setX(X).setZ(Z));
		
		redDyeItem.setMetadata("CODnoPickup", new FixedMetadataValue(ThisPlugin.getPlugin(), redDyeItem));
		
		BukkitRunnable br2 = new BukkitRunnable() {
			public void run() {
				if (!Bukkit.getOnlinePlayers().isEmpty()) ParticleEffect.REDSTONE.display((float) 0.01, (float) 0.01, (float) 0.01, 0, 10, redDyeItem.getLocation());
				redDyeItem.remove();
			}
		};
		
		time = new Random().nextInt(/*Max*/4 - /*Min*/2 + 1) + 2;
		br2.runTaskLater(ThisPlugin.getPlugin(), 20 * time);
	}
}
 
開發者ID:frostythedev,項目名稱:COD-Warfare,代碼行數:54,代碼來源:DeathBloodEffect.java

示例9: execute

import org.bukkit.entity.Item; //導入方法依賴的package包/類
@Override
public boolean execute(Location loc) {
    int thresholdDist = RADIUS * RADIUS;
    loc.add(0.5, 0.5, 0.5);
    for (final Item item : getItemEntities(loc.getWorld())) {
        if (!item.isValid()) {
            // important, since we're looking at entities cached in the last second
            continue;
        }
        double dist = loc.distanceSquared(item.getLocation());
        if (dist >= thresholdDist) {
            continue;
        }
        final ItemStack onGround = item.getItemStack();
        ItemStack buffer = getItemRouter().getBufferItem();
        Location itemLoc = item.getLocation();
        if (item.getPickupDelay() <= 0
                && getFilter().shouldPass(onGround)
                && rightDirection(itemLoc, loc)
                && (buffer == null || buffer.isSimilar(onGround))
                && STBUtil.getMetadataValue(item, STB_VACUUMED) == null) {
            double rtrY = loc.getY();
            Vector vel = loc.subtract(itemLoc).toVector().normalize().multiply(Math.min(dist * 0.06, 0.7));
            if (itemLoc.getY() < rtrY) {
                vel.setY(vel.getY() + (rtrY - itemLoc.getY()) / 10);
            }
            item.setMetadata(STB_VACUUMED, new FixedMetadataValue(getProviderPlugin(), getItemRouter()));
            item.setVelocity(vel);
            Bukkit.getScheduler().runTaskLater(getProviderPlugin(), new Runnable() {
                @Override
                public void run() {
                    if (item.isValid()) {
                        ItemStack newBuffer = getItemRouter().getBufferItem();
                        int toSlurp = 0;
                        if (newBuffer == null) {
                            toSlurp = onGround.getAmount();
                            getItemRouter().setBufferItem(onGround);
                            item.remove();
                        } else if (newBuffer.isSimilar(onGround)) {
                            toSlurp = Math.min(onGround.getAmount(), newBuffer.getType().getMaxStackSize() - newBuffer.getAmount());
                            getItemRouter().setBufferAmount(newBuffer.getAmount() + toSlurp);
                            onGround.setAmount(onGround.getAmount() - toSlurp);
                            if (onGround.getAmount() == 0) {
                                item.remove();
                            } else {
                                item.setItemStack(onGround);
                            }
                        }
                        if (toSlurp > 0) {
                            getItemRouter().playParticles();
                            getItemRouter().update(false);
                        }
                    }
                }
            }, (long) (dist / 3));
        }
    }
    return false; // any work done is deferred
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:60,代碼來源:VacuumModule.java


注:本文中的org.bukkit.entity.Item.setMetadata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。