當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。