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


Java PlayerDropItemEvent類代碼示例

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


PlayerDropItemEvent類屬於org.bukkit.event.player包,在下文中一共展示了PlayerDropItemEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onVisitorDrop

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorDrop(final PlayerDropItemEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Util.inWorld(e.getPlayer())) {
        return;
    }
    Island island = plugin.getIslands().getIslandAt(e.getItemDrop().getLocation());
    if ((island != null && island.getFlag(SettingsFlag.ITEM_DROP)) 
            || e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getItemDrop().getLocation())) {
        return;
    }
    Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
    e.setCancelled(true);
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:18,代碼來源:VisitorGuard.java

示例2: onCraft

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
@EventHandler
public void onCraft(PlayerDropItemEvent e) {
	//e.getPlayer().sendMessage(e.getItemDrop().getItemStack().toString());
	/*for (CustomCraftingRecipe r : recipes) {
		//if (r.ncon.equals("ground")) {
			ArrayList<Item> items = new ArrayList<Item>();
			items.add(e.getItemDrop());
			for (Entity it : e.getItemDrop().getNearbyEntities(5, 5, 5)) {
				if (it instanceof Item) {
					items.add((Item) it);
				}
			}
			e.getPlayer().sendMessage(String.valueOf(items.size()));
		//}
	}*/
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:17,代碼來源:CustomCrafting.java

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

示例4: on

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
@EventHandler
public void on(PlayerDropItemEvent event) {
    ItemStack item = event.getItemDrop().getItemStack();

    if (item == null) {
        return;
    }

    if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
        return;
    }

    String name = item.getItemMeta().getDisplayName();

    if (name.equals("§4§lBlocked Slot")) {
        event.setCancelled(true);
    }
}
 
開發者ID:LeonTG,項目名稱:NineSlots,代碼行數:19,代碼來源:ClickListener.java

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

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

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

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

示例9: load

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
public static void load(CSCoreLib plugin) {
	if (ReflectionUtils.getVersion().startsWith("v1_9_")) {
		plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
	}
	else if (ReflectionUtils.getVersion().startsWith("v1_10_")) {
		plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
	}
	else if (ReflectionUtils.getVersion().startsWith("v1_11_")) {
		plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
	}
	else if (ReflectionUtils.getVersion().startsWith("v1_12_")) {
		plugin.getServer().getPluginManager().registerEvents(new CustomBookOverlay1_9(), plugin);
	}

	plugin.getServer().getPluginManager().registerEvents(new Listener() {

		@EventHandler
		public void onDrop(PlayerDropItemEvent e) {
			if (opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true);
		}

	}, plugin);
}
 
開發者ID:TheBusyBiscuit,項目名稱:CS-CoreLib,代碼行數:24,代碼來源:CustomBookOverlay.java

示例10: onInventoryChange

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryChange(PlayerDropItemEvent e) {
	if (this.participants == null) {
		return;
	}
	if (state) {
		return;
	}
	if (!e.isCancelled() && e.getItemDrop().getItemStack().getType() == itemType) {
		
		for (QuestPlayer qp : participants.getParticipants()) {
			if (qp.getPlayer().getUniqueId().equals(e.getPlayer().getUniqueId())) {
				final Requirement req = this;
				Bukkit.getScheduler().runTaskLater(QuestManagerPlugin.questManagerPlugin, req::update, 1);
			}
		
		}
	}
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:20,代碼來源:DeliverRequirement.java

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

示例12: coinCheck

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
public void coinCheck(PlayerDropItemEvent event){
        int LocationX = event.getItemDrop().getLocation().getBlockX();
        if (coinDropper.equalsIgnoreCase(event.getPlayer().getDisplayName())  && (LocationX == coinLocationX)){
            Location pitDropModifier = new Location(worldPit,pit.getBlockX(),pit.getBlockY()+3,pit.getBlockZ());
            Location Fireworks = new Location(worldPit,pit.getBlockX(),pit.getBlockY()+6,pit.getBlockZ());
            ItemStack Diamonds = new ItemStack(Material.DIAMOND);
            Diamonds.setAmount(40);
            int RandomProbability = (int)(Math.random()*100);
            if (RandomProbability<50){
                event.getPlayer().sendMessage("§6"+LuckyBlocksMainController.instance.language.getString("LUCKY_THIS_TIME"));
            worldPit.dropItemNaturally(pitDropModifier,Diamonds);
            for (int i=0;i<5;i++) homeFireworks(Fireworks,worldPit);}
            else{
                TNTPrimed TNT = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(pitDropModifier,EntityType.PRIMED_TNT);
                TNT.setYield(50);
                TNT.setFuseTicks(10);
            }
            event.getItemDrop().remove();
        }
    else{
             event.getPlayer().sendMessage(LuckyBlocksMainController.instance.language.getString("DROP_IT_CLOSER"));
        }
}
 
開發者ID:josegrobles,項目名稱:LuckyBlocksBukkit,代碼行數:24,代碼來源:LuckyBlocksActionController.java

示例13: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    if (!event.isCancelled() && TeamUtils.getTeamByPlayer(event.getPlayer()) != null && event.getItemDrop().getItemStack().getType().equals(Material.WOOL)) {
        for (TeamModule team : TeamUtils.getTeams()) {
            if (!team.isObserver() && TeamUtils.getTeamByPlayer(event.getPlayer()) != team) {
                for (GameObjective obj : TeamUtils.getShownObjectives(team)) {
                    if (obj instanceof WoolObjective && event.getItemDrop().getItemStack().getData().getData() == ((WoolObjective) obj).getColor().getData()) {
                        if (!items.containsKey(event.getPlayer())) {
                            items.put(event.getPlayer(), new ArrayList<Item>());
                        }
                        List<Item> list = items.get(event.getPlayer());
                        list.add(event.getItemDrop());
                        items.put(event.getPlayer(), list);
                    }
                }
            }
        }
    }
}
 
開發者ID:dentmaged,項目名稱:Cardinal-Plus,代碼行數:20,代碼來源:Snowflakes.java

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

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


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