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