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


Java PlayerDropItemEvent.getItemDrop方法代码示例

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


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

示例1: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
    if(this.ignoreNextDropEvent) {
        this.ignoreNextDropEvent = false;
    } else {
        // If the ignore flag is clear, this drop was caused by something other than
        // an inventory click (e.g. drop key, death, etc), so an event has not yet been fired
        int initialQuantity = event.getItemDrop().getItemStack().getAmount();
        ItemStack stack = event.getItemDrop().getItemStack();
        PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(event, ItemTransferEvent.Type.DROP, event.getPlayer(),
                                                                            Optional.of(new InventorySlot(event.getPlayer().getInventory())),
                                                                            Optional.empty(),
                                                                            stack, event.getItemDrop(), initialQuantity,
                                                                            event.getPlayer().getOpenInventory().getCursor());
        this.callEvent(transferEvent);

        if(!transferEvent.isCancelled() && transferEvent.getQuantity() < initialQuantity) {
            int diff = initialQuantity - transferEvent.getQuantity();
            stack.setAmount(stack.getAmount() - diff);
            stack = stack.clone();
            stack.setAmount(diff);
            event.getPlayer().getInventory().addItem(stack);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:ItemTransferListener.java

示例2: onItemDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的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

示例3: StopDrops

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的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: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
	Item dropped = event.getItemDrop();
	GunPlayer gp = plugin.getGunPlayer(event.getPlayer());
	ItemStack lastHold = gp.getLastHeldItem();
	if (lastHold != null)
	{
		Gun gun = gp.getGun(dropped.getItemStack());
		if (gun != null)
		{
			if (lastHold.getType() == dropped.getItemStack().getType())
			{
				if (gun.isHasClip() && gun.isChanged() && gun.isReloadGunOnDrop())
				{
					gun.reloadGun();
					event.setCancelled(true);
				}
			}
		}
	}
}
 
开发者ID:dmulloy2,项目名称:SwornGuns,代码行数:23,代码来源:PlayerListener.java

示例5: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
	try {
		ExchangeRule[] rules = ExchangeRule.parseBulkRuleBlock(event.getItemDrop().getItemStack());
		
		Item drop = event.getItemDrop();
		
		for(ExchangeRule rule : rules) {
			ItemStack item = rule.toItemStack();
			
			Item ruleDrop = drop.getWorld().dropItem(drop.getLocation(), item);
			
			ruleDrop.setVelocity(drop.getVelocity());
		}
		
		drop.remove();
	}
	catch (ExchangeRuleParseException e) {
	}
}
 
开发者ID:gmlaxfanatic,项目名称:ItemExchange,代码行数:21,代码来源:ItemExchangeListener.java

示例6: handleItemDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的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

示例7: onItemDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent e) {
	Item item = e.getItemDrop();
	
	Bukkit.getScheduler().scheduleSyncDelayedTask(hcf, new Runnable() {
		public void run() {
			item.remove();
		}
	}, 20L * 60L * 3L);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:ItemRemoverListener.java

示例8: onPlayerDropItemEvent

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的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

示例9: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的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

示例10: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent e) {
    if (e.getItemDrop() != null && MarketManager.isMarketItem(e.getItemDrop().getItemStack())) {
        e.getItemDrop().setItemStack(new ItemStack(Material.AIR));
    }
}
 
开发者ID:NyaaCat,项目名称:HamsterEcoHelper,代码行数:7,代码来源:Events.java


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