当前位置: 首页>>代码示例>>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;未经允许,请勿转载。