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


Java Item.setItemStack方法代码示例

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


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

示例1: executeFishingActions

import org.bukkit.entity.Item; //导入方法依赖的package包/类
private void executeFishingActions(Player catcher, PlayerFishEvent event) {
    CaughtFish fish = plugin.getFishManager().generateRandomFish(catcher);

    PlayerCatchCustomFishEvent customEvent = new PlayerCatchCustomFishEvent(catcher, fish, event);
    plugin.getServer().getPluginManager().callEvent(customEvent);

    if (customEvent.isCancelled()) {
        return;
    }

    boolean new1st = contest.hasStarted() && contest.isNew1st(fish);
    announceMessages(catcher, fish, new1st);

    if (fish.getRarity().hasFirework())
        launchFirework(catcher.getLocation().add(0, 1, 0));
    if (!fish.getCommands().isEmpty())
        executeCommands(catcher, fish);

    if (new1st) {
        contest.addRecord(catcher, fish);
    }

    ItemStack itemStack = plugin.getFishManager().getItemStack(fish, event.getPlayer().getName());
    Item caught = (Item) event.getCaught();
    caught.setItemStack(itemStack);
}
 
开发者ID:elsiff,项目名称:MoreFish,代码行数:27,代码来源:FishingListener.java

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

示例3: nerfFishing

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void nerfFishing(PlayerFishEvent event) {
    if (Config.Fishing.disableTreasure() && event.getCaught() instanceof Item) {
        Item caught = (Item) event.getCaught();
        if (caught.getItemStack().getType() != Material.RAW_FISH) {
            caught.setItemStack(new ItemStack(Material.RAW_FISH));
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:PGMListener.java

示例4: onPlayerCatchEvent

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onPlayerCatchEvent(PlayerFishEvent event){
	if(event.getCaught() instanceof Item){
		Item drop = (Item)event.getCaught();
		drop.setItemStack(new ItemStack(Material.APPLE, 1));
	}
}
 
开发者ID:DamoclesProject,项目名称:Damocles,代码行数:8,代码来源:Fishing.java

示例5: onPlayerDropItemEvent

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
	User user = API.to(event.getPlayer());
	if (user == null) return;
	Item entity = event.getItemDrop();
	ItemStack item = entity.getItemStack().clone();
	UItem object = UItemManager.getInstance().getItem(item);
	if (object == null) return;
	
	UItemEvent result = object.call(new UItemEventDrop(user, object, item));
	if (result.isCancelled()) event.setCancelled(true);
	item = result.getItem();
	if (item == null) entity.remove();
	else entity.setItemStack(item.clone());
}
 
开发者ID:imfanhua,项目名称:Minecraft-UAPI,代码行数:16,代码来源:UItemListener.java

示例6: run

import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
public void run()
{
	for(Player player : Bukkit.getServer().getOnlinePlayers())
	{
		if(player.getInventory().firstEmpty() == -1 && (player.hasPermission("backpack") || player.hasPermission("backpack.use")) && player.hasPermission("backpack.fullpickup"))
		{
			// Only check loaded backpacks (loading them would take to much time for a repeating task, the will be loaded async soon enough)
			Backpack backpack = plugin.DB.getBackpack(player);
			if(backpack == null)
			{
				continue;
			}
			List<Entity> entities = player.getNearbyEntities(radius, radius, radius);
			for(Entity entity : entities)
			{
				if(entity instanceof Item)
				{
					Item item = (Item) entity;
					if(!item.isDead() && item.getPickupDelay() <= 0)
					{
						HashMap<Integer, ItemStack> full = backpack.getInventory().addItem(item.getItemStack());
						backpack.setChanged();
						if(!full.isEmpty())
						{
							item.setItemStack(full.get(0));
						}
						else
						{
							item.remove();
						}
					}
				}
			}
		}
	}
}
 
开发者ID:GeorgH93,项目名称:Minepacks,代码行数:38,代码来源:ItemsCollector.java

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

示例8: giveLot

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Gives the items to a player, drops excess on ground or saves all of it to orphanage if the player is offline.
 * 
 * @param playerName who receives the items
 */
private void giveLot(String playerName) 
{
	this.ownerName = playerName;
	if (this.quantity == 0) 
	{
		return;
	}
	ItemStack lotTypeLock = getTypeStack();
	Player player = Bukkit.getPlayer(playerName);
	
	int maxStackSize = lotTypeLock.getType().getMaxStackSize();
	if (player != null && player.isOnline()) 
	{
		int amountToGive = 0;
		if (Items.hasSpace(player, this.quantity, lotTypeLock)) 
		{
			amountToGive = this.quantity;
		} 
		else 
		{
			amountToGive = Items.getSpaceForItem(player, lotTypeLock);
		}
		// Give whatever items space permits at this time.
		ItemStack typeStack = getTypeStack();
		if (amountToGive > 0) 
		{
			FloAuction.getMessageManager().sendPlayerMessage(new CArrayList<String>("lot-give"), playerName, (AuctionScope) null);
		}
		while (amountToGive > 0) 
		{
			ItemStack givingItems = lotTypeLock.clone();
			givingItems.setAmount(Math.min(maxStackSize, amountToGive));
			this.quantity -= givingItems.getAmount();
			Items.saferItemGive(player.getInventory(), givingItems);
			
			amountToGive -= maxStackSize;
		}
		if (this.quantity > 0) 
		{
			// Drop items at player's feet.
			
			// Move items to drop lot.
			while (this.quantity > 0) 
			{
				ItemStack cloneStack = typeStack.clone();
				cloneStack.setAmount(Math.min(this.quantity, Items.getMaxStackSize(typeStack)));
				quantity -= cloneStack.getAmount();
				
				// Drop lot.
				Item drop = player.getWorld().dropItemNaturally(player.getLocation(), cloneStack);
				drop.setItemStack(cloneStack);
			}
			FloAuction.getMessageManager().sendPlayerMessage(new CArrayList<String>("lot-drop"), playerName, (AuctionScope) null);
		}
	} 
	else 
	{
		// Player is offline, queue lot for give on login.
		// Create orphaned lot to try to give when inventory clears up.
		final AuctionLot orphanLot = new AuctionLot(lotTypeLock, playerName);
		
		// Move items to orphan lot
		orphanLot.addItems(this.quantity, false);
		this.quantity = 0;
		
		// Queue for distribution on space availability.
		FloAuction.saveOrphanLot(orphanLot);
	}
}
 
开发者ID:virustotalop,项目名称:ObsidianAuctions,代码行数:75,代码来源:AuctionLot.java

示例9: handleFishing

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Process the results from a successful fishing trip
 *
 * @param fishingCatch The {@link Item} initially caught
 */
public void handleFishing(Item fishingCatch) {
    this.fishingCatch = fishingCatch;
    int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
    int treasureXp = 0;
    Player player = getPlayer();
    FishingTreasure treasure = null;

    if (Config.getInstance().getFishingDropsEnabled() && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHING_TREASURE_HUNTER)) {
        treasure = getFishingTreasure();
        this.fishingCatch = null;
    }

    if (treasure != null) {
        ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
        Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();

        if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.MAGIC_HUNTER) && ItemUtils.isEnchantable(treasureDrop)) {
            enchants = handleMagicHunter(treasureDrop);
        }

        McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);

        if (!event.isCancelled()) {
            treasureDrop = event.getTreasure();
            treasureXp = event.getXp();
        }
        else {
            treasureDrop = null;
            treasureXp = 0;
        }

        // Drop the original catch at the feet of the player and set the treasure as the real catch
        if (treasureDrop != null) {
            boolean enchanted = false;

            if (!enchants.isEmpty()) {
                treasureDrop.addUnsafeEnchantments(enchants);
                enchanted = true;
            }

            if (enchanted) {
                player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
            }

            if (Config.getInstance().getFishingExtraFish()) {
                Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
            }

            fishingCatch.setItemStack(treasureDrop);
        }
    }

    applyXpGain(fishXp + treasureXp, XPGainReason.PVE);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:60,代码来源:FishingManager.java

示例10: onPlayerFishHighest

import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
 * Handle PlayerFishEvents at the highest priority.
 * <p>
 * These events are used for the purpose of handling our anti-exploit
 * code, as well as dealing with ice fishing.
 *
 * @param event The event to modify
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) {
    Player player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player) || !SkillType.FISHING.getPermissions(player)) {
        return;
    }

    FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();

    switch (event.getState()) {
        case FISHING:
            if (!Permissions.krakenBypass(player)) {
                event.setCancelled(fishingManager.exploitPrevention());
            }
            return;

        case CAUGHT_FISH:
            //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
            Item fishingCatch = (Item) event.getCaught();

            if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
                fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
            }

            if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
                event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
            }
            return;

        case IN_GROUND:
            Block block = player.getTargetBlock(null, 100);

            if (fishingManager.canIceFish(block)) {
                event.setCancelled(true);
                fishingManager.iceFishing(event.getHook(), block);
            }
            return;

        default:
            return;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:52,代码来源:PlayerListener.java


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