當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerDropItemEvent.getPlayer方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerDropItemEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerDropItemEvent.getPlayer方法的具體用法?Java PlayerDropItemEvent.getPlayer怎麽用?Java PlayerDropItemEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerDropItemEvent的用法示例。


在下文中一共展示了PlayerDropItemEvent.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
    Player p = e.getPlayer();

	if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Disable")) {
		if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.World.All_World")) {
			if (WorldUtils.getWItemDrop().contains(p.getWorld().getName())) {
 			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Bypass")) {
                 if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.drop")) {
                     e.setCancelled(true);
                 }
             } else {
                 e.setCancelled(true);
             }
			}
		} else {
			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Drop.Bypass")) {
                if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.drop")) {
                    e.setCancelled(true);
                }
            } else {
                e.setCancelled(true);
            }
		}
    }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:27,代碼來源:BasicFeatures.java

示例3: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onPlayerDropItem(PlayerDropItemEvent event)
{
    Player player = event.getPlayer();
    if(!player.isSneaking() && PhantomAdmin.instance.isInvisible(player))
    {
        event.setCancelled(true);
        PlayerData data = PlayerData.FromPlayer(player);
        if(!data.gotItemDropInfo)
        {
            PhantomAdmin.sendMessage(player, TextMode.Warn, Messages.NoItemDropWhileInvisible);
            data.gotItemDropInfo = true;
        }
        return;
    }
}
 
開發者ID:BigScary,項目名稱:PhantomAdmin,代碼行數:17,代碼來源:PAEventHandler.java

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

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

示例6: onPlayerDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDrop(final PlayerDropItemEvent event) {

	final PlayerStat stat = PlayerStat.ITEMS_DROPPED;

	// Get player
	final Player player = event.getPlayer();

	// Do general check
	if (!plugin.doGeneralCheck(player, stat))
		return;

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
			player.getUniqueId().toString(), "value", event.getItemDrop().getItemStack().getAmount(), "world", player.getWorld().getName(), "item", event.getItemDrop().getItemStack().getType().toString()));

}
 
開發者ID:Staartvin,項目名稱:Statz,代碼行數:18,代碼來源:ItemsDroppedListener.java

示例7: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent e) {
	Player p = e.getPlayer();
	if (e.getItemDrop().getItemStack().getItemMeta().hasLore()) {
		if (e.getItemDrop().getItemStack().getItemMeta().getLore().get(0)
				.equals("Fury")
				|| e.getItemDrop().getItemStack().getItemMeta().getLore()
						.get(0).equals("Sheild")
				|| e.getItemDrop().getItemStack().getItemMeta().getLore()
						.get(0).equals("Sprint")
				|| e.getItemDrop().getItemStack().getItemMeta().getLore()
						.get(0).equals("Regen")) {
			e.setCancelled(true);
			p.sendMessage(ChatColor.DARK_RED + "You can't drop this item!");
		}
	}
}
 
開發者ID:ckm499,項目名稱:MythsOfCreation,代碼行數:18,代碼來源:ItemDropListener.java

示例8: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrop(PlayerDropItemEvent die) {
  Player p = die.getPlayer();
  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() != GameState.WAITING) {
    if (g.isSpectator(p)) {
      die.setCancelled(true);
    }

    return;
  }

  die.setCancelled(true);
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:19,代碼來源:PlayerListener.java

示例9: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
  Player p = event.getPlayer();
  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() == GameState.RUNNING
      && event.getItemDrop().getItemStack().getItemMeta().getDisplayName() != null
      && event.getItemDrop().getItemStack().getItemMeta().getDisplayName()
      .equals(BedwarsRel._l("ingame.specials.warp-powder.cancel"))) {
    event.setCancelled(true);
  }

}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:17,代碼來源:WarpPowderListener.java

示例10: onDropEvent

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onDropEvent(PlayerDropItemEvent event) {
    if (event.isCancelled() || event.getPlayer() == null) {
        return;
    }
    Player player = event.getPlayer();
    if (!plugin.isSkyWorld(player.getWorld())) {
        return;
    }
    if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
        event.setCancelled(true);
        plugin.notifyPlayer(player, tr("\u00a7eVisitors can't drop items!"));
        return;
    }
    addDropInfo(player, event.getItemDrop().getItemStack());
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:17,代碼來源:ItemDropEvents.java

示例11: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
/**
 * On player drop item.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {

	Player player = event.getPlayer();
	IPlayerConfEntry entry = playerConf.get(player);

	if (entry != null && !entry.isAdminMod()) {
		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
				player.getLocation());

		if (!checkPermission(land, event.getPlayer(),
				PermissionList.DROP.getPermissionType())) {
			messagePermission(player);
			event.setCancelled(true);
		}
	}
}
 
開發者ID:Tabinol,項目名稱:Factoid,代碼行數:24,代碼來源:PlayerListener.java

示例12: DropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
/**
     * Checks if player has proper permission to drop items.
     *
     * @param event that triggers listener.
     */
    @EventHandler(priority = EventPriority.LOW)
    private void DropItem(PlayerDropItemEvent event) {
        Player player = event.getPlayer();

        // Drop item check.
        if (player != null && !player.hasPermission("antibuild.bypass")) {
            if (!player.hasPermission("antibuild.dropitems")) {
                event.setCancelled(true);
                PlayerMessenger.messageHandler(plugin.getConfigHandler().getNoDropItemsMessage(), player);
            }
        }

//        // World Check
//        if (!event.isCancelled() && plugin.isUsingLock()) {
//            if (plugin.isLockedWorld(player.getWorld().getName())
//                    && !player.hasPermission("antibuild.lock.bypass") && !player.hasPermission("antibuild.lock
// .bypass" +
//                    "." + player.getWorld().getName())) {
//                event.setCancelled(true);
//                messageHandler(plugin.getLockedWorldMessage(), player);
//            }
//        }

    }
 
開發者ID:MutinyCraft,項目名稱:AntiBuild,代碼行數:30,代碼來源:ItemDrop.java

示例13: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event) 
{
	Player pl = event.getPlayer();
	if (pl != null)
	{
		if (plugin.isInArena(pl)) 
		{
			if (plugin.getArena(pl).type.equals("Hunger"))
			{
				event.setCancelled(false);
			}
			else 
			{
				event.setCancelled(true);
			}
		}
	}
}
 
開發者ID:whitegem,項目名稱:UltimateArena,代碼行數:20,代碼來源:PlayerListener.java

示例14: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerDropItem(final PlayerDropItemEvent event)
{

	final Player user = event.getPlayer();
	final ItemStack item = event.getItemDrop().getItemStack();

	if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
	{
		return;
	}
	{
		if (!Permissions.DROP.isAuthorized(user, item.getType(), item.getData()))
		{
			event.setCancelled(true);
			user.getPlayer().updateInventory();
			if (antib.getSettings().getData().isWarnOnBuildDisallow())
			{
				user.sendMessage(_("§4You are not permitted to drop§c {0}§4.", item.getType().toString()));
			}
		}
	}
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:24,代碼來源:EssentialsAntiBuildListener.java

示例15: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onDrop(PlayerDropItemEvent evt) {
    if(ConfigPatch.fixDupeDropItem){
        Player player = evt.getPlayer();
        if (AzurePlayerList.contains(player) && player.isDead()) evt.setCancelled(true);
    }
}
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:8,代碼來源:AntiDupeDropItem.java


注:本文中的org.bukkit.event.player.PlayerDropItemEvent.getPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。