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


Java Item.getItemStack方法代码示例

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


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

示例1: onItemDrop

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
	System.out.println("Item drop");
	Item item = event.getItemDrop();
	ItemStack stack = item.getItemStack();
	Location location = item.getLocation();
	Player player = event.getPlayer();
	String playerName = player == null ? "null" : player.getName();
	
	DropItemObsel obsel = new DropItemObsel(
			new Date().getTime(),
			stack.getType().toString(),
			stack.getAmount(),
			stack.getData().getData(),
			location.getBlockX(),
			location.getBlockY(),
			location.getBlockZ(),
			location.getWorld().getName(),
			playerName);
	JSONObselManager.getInstance().addObsel(obsel);
}
 
开发者ID:Lyon1-Asterix,项目名称:Minetrace,代码行数:23,代码来源:MinetraceListener.java

示例2: onItemPickup

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
	System.out.println("Item pickup");
	Item item = event.getItem();
	ItemStack stack = item.getItemStack();
	Location location = item.getLocation();
	Player player = event.getPlayer();
	String playerName = player == null ? "null" : player.getName();
	
	PickupItemObsel obsel = new PickupItemObsel(
			new Date().getTime(),
			stack.getType().toString(),
			stack.getAmount(),
			stack.getData().getData(),
			location.getBlockX(),
			location.getBlockY(),
			location.getBlockZ(),
			location.getWorld().getName(),
			playerName);
	JSONObselManager.getInstance().addObsel(obsel);
}
 
开发者ID:Lyon1-Asterix,项目名称:Minetrace,代码行数:23,代码来源:MinetraceListener.java

示例3: StopDrops

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void StopDrops(PlayerDropItemEvent event)
{
    Player player = event.getPlayer();
    Item item = event.getItemDrop();
    if(item != null)
    {
	    ItemStack stack = item.getItemStack();
	    if(stack != null)
	    {
		    if(KitUtils.isSoulbound(stack))
		    {
			    player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1.0F, 0.3F);
			    event.getItemDrop().remove();
		    }
	    }
    }
}
 
开发者ID:MrLittleKitty,项目名称:AnnihilationPro,代码行数:19,代码来源:KitLoading.java

示例4: addLots

import org.bukkit.entity.Item; //导入方法依赖的package包/类
public int addLots(List<Item> items)
{
    int addedCount = 0;
    for(Item itemEntity : items)
    {

        ItemStack item = itemEntity.getItemStack();
        AuctionableItem ai = regionalConfigManager.getAuctionableItemConfig(itemEntity);
        
        if(null == ai) continue;

        double startingPrice = (((int)(ai.getStartingPrice() * 100)) * item.getAmount()) / 100D;
        double minimumIncrement = (((int)(ai.getMinimumIncrement() * 100)) * item.getAmount()) / 100D;
        
        Lot lot = new Lot(item, false, startingPrice, null, null, null, -1, minimumIncrement, System.currentTimeMillis() + ai.getPreserveTimeInSeconds() * 1000, ai.getAuctionDurationInSeconds() * 1000);
        lots.add(lot);

        addedCount++;
        
    }
    
    LotShowcase.updateAll();
    return addedCount;
}
 
开发者ID:Cnly,项目名称:WowSuchCleaner,代码行数:25,代码来源:AuctionDataManager.java

示例5: clearDropInfo

import org.bukkit.entity.Item; //导入方法依赖的package包/类
private void clearDropInfo(Item item) {
    ItemStack stack = item.getItemStack();
    ItemMeta meta = stack.getItemMeta();
    if (meta != null) {
        List<String> lore = meta.getLore();
        if (lore != null && !lore.isEmpty()) {
            for (Iterator<String> it = lore.iterator(); it.hasNext(); ) {
                String line = it.next();
                if (line.contains(tr("Owner: {0}", ""))) {
                    it.remove();
                }
            }
            meta.setLore(lore);
            stack.setItemMeta(meta);
            item.setItemStack(stack);
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:19,代码来源:ItemDropEvents.java

示例6: onItemPickup

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
	Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
			.getGameManager().getGameOfPlayer(e.getPlayer());
	if (bw == null) {
		return;
	}
	if (!Config.isGameEnabledXP(bw.getName())) {
		return;
	}
	Player p = e.getPlayer();
	Item entity = e.getItem();
	ItemStack stack = entity.getItemStack();
	int count = Res.convertResToXP(stack);
	if (count == 0) {
		return;
	}
	e.setCancelled(true);
	XPManager.addXP(bw.getName(), p, count);
	p.playSound(p.getLocation(),
			SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
			10.0F, 1.0F);
	if (!Config.Message.equals("")) {
		ActionBarUtils.sendActionBar(p,
				Config.Message.replaceAll("%xp%", Integer.toString(count)));
		/*
		 * if (!ActionBarUtils.works) {
		 * p.sendMessage(Config.Message.replaceAll("%xp%",
		 * Integer.toString(count))); }
		 */
	}
	entity.remove();
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:34,代码来源:NewEventListeners.java

示例7: onItemPickup

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
	Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
			.getGameOfPlayer(e.getPlayer());
	if (bw == null) {
		return;
	}
	if (!Config.isGameEnabledXP(bw.getName())) {
		return;
	}
	Player p = e.getPlayer();
	Item entity = e.getItem();
	ItemStack stack = entity.getItemStack();
	int count = Res.convertResToXP(stack);
	if (count == 0) {
		return;
	}
	e.setCancelled(true);
	XPManager.addXP(bw.getName(), p, count);
	p.playSound(p.getLocation(),
			SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
			10.0F, 1.0F);
	if (!Config.Message.equals("")) {
		ActionBarUtils.sendActionBar(p,
				Config.Message.replaceAll("%xp%", Integer.toString(count)));
		/*
		 * if (!ActionBarUtils.works) {
		 * p.sendMessage(Config.Message.replaceAll("%xp%",
		 * Integer.toString(count))); }
		 */
	}
	entity.remove();
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:34,代码来源:OldEventListeners.java

示例8: handleItemDrop

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleItemDrop(final PlayerDropItemEvent event) {
    ParticipantState player = PGM.getMatchManager().getParticipantState(event.getPlayer());
    if(player == null) return;

    Competitor team = player.getParty();
    Item itemDrop = event.getItemDrop();
    ItemStack item = itemDrop.getItemStack();

    if (this.isDestroyableWool(item, team)) {
        this.droppedWools.put(itemDrop, player.getPlayerId());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:RaindropListener.java

示例9: onItemSpawn

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
	Item item = event.getEntity();
	ItemStack stack = item.getItemStack();
	World world = item.getWorld();
	
	if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
			|| stack.hasItemMeta()) return;
	
	DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
	DragonLoot loot = dragon.getLoot();
	
	String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
	List<String> eggLore = loot.getEggLore().stream()
			.map(s -> s.replace("%dragon%", dragon.getName()))
			.collect(Collectors.toList());

	ItemMeta eggMeta = stack.getItemMeta();
	
	if (eggName != null && !eggName.isEmpty()) {
		eggMeta.setDisplayName(eggName);
	}
	if (eggLore != null && !eggLore.isEmpty()) {
		eggMeta.setLore(eggLore);
	}
	
	stack.setItemMeta(eggMeta);
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:29,代码来源:LootListeners.java

示例10: onItemSpawn

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
    if (e.isCancelled()) {
        return;
    }

    Item item = e.getEntity();
    ItemStack is = item.getItemStack();

    if (isMoneyItem(is)) {
        item.setCustomName(is.getItemMeta().getDisplayName());
        item.setCustomNameVisible(true);
    }
}
 
开发者ID:diecode,项目名称:KillerMoney,代码行数:15,代码来源:MoneyHandler.java

示例11: onItemPickUp

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickUp(PlayerPickupItemEvent e) {
    if (e.isCancelled()) {
        return;
    }

    Item item = e.getItem();
    ItemStack is = item.getItemStack();

    if (isMoneyItem(is)) {
        e.setCancelled(true);

        BigDecimal money = new BigDecimal(Double.valueOf(ChatColor.stripColor(is.getItemMeta().getLore().get(0))
                .replaceAll("[^0-9.]", "")))
                .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN);

        EntityType entityType = EntityType.valueOf(is.getItemMeta().getLore().get(1));
        EntityProperties ep = EntityManager.getEntityProperties(entityType);

        if (ep == null) {
            return;
        }

        UUID uuid = UUID.fromString(is.getItemMeta().getLore().get(2));

        if (!DefaultConfig.isMoneyItemAnyonePickUp() && !uuid.equals(e.getPlayer().getUniqueId())) {
            return;
        }

        WorldProperties wp = EntityManager.getWorldProperties(ep, e.getItem().getLocation().getWorld().getName());

        if (wp != null) {
            item.remove();

            Bukkit.getPluginManager().callEvent(new KMEarnMoneyPickedUpEvent(wp.getMoneyProperties(),
                    e.getPlayer(), money));
        }
    }
}
 
开发者ID:diecode,项目名称:KillerMoney,代码行数:40,代码来源:MoneyHandler.java

示例12: init

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
protected boolean init(final @Nullable Class<? extends Item> c, final @Nullable Item e) {
	if (e != null) {
		final ItemStack i = e.getItemStack();
		if (i == null)
			return false;
		types = new ItemType[] {new ItemType(i)};
	}
	return true;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:11,代码来源:DroppedItemData.java

示例13: 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

示例14: onCatch

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onCatch(final PlayerFishEvent event) {
    if (!(event.getCaught() instanceof Item))
        return;

    final Item caught = (Item)event.getCaught();
    final ItemStack item = caught.getItemStack();
    if (!Enchantments.getAllEnchantments(item).isEmpty()) {
        Enchantments.removeAllEnchantments(item);
        mechanics.generateEnchantments(event.getPlayer(), item, bookLevel, false, random.nextLong())
                .getEnchantments().forEach((enchant, level) -> enchant.addToItem(item, level));
        caught.setItemStack(item);
    }
}
 
开发者ID:Eniripsa96,项目名称:EnchantmentAPI,代码行数:15,代码来源:FishingListener.java

示例15: onPlayerPickupItem

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Handle PlayerPickupItemEvents at the highest priority.
 * <p>
 * These events are used to handle item sharing between party members and
 * are also used to handle item pickup for the Unarmed skill.
 *
 * @param event The event to modify
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player)) {
        return;
    }

    McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);

    Item drop = event.getItem();
    ItemStack dropStack = drop.getItemStack();

    if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
        if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
            event.setCancelled(true);
        }

        return;
    }

    if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
        event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));

        if (event.isCancelled()) {
            player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
            return;
        }
    }

    if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
        boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
        boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
        event.setCancelled(cancel);

        if (pickupSuccess) {
            player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
            player.updateInventory();
            return;
        }
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:51,代码来源:PlayerListener.java


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