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


Java PlayerPickupItemEvent.getPlayer方法代碼示例

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


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

示例1: onPickUp

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onPickUp(PlayerPickupItemEvent e) {
    Player p = e.getPlayer();
    
    if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Disable")) {
		if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.World.All_World")) {
			if (WorldUtils.getWItemPickUp().contains(p.getWorld().getName())) {
 			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
                 if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
                     e.setCancelled(true);
                 }
             } else {
                 e.setCancelled(true);
             }
			}
		} else {
			if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.PickUp.Bypass")) {
                if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.pickup")) {
                    e.setCancelled(true);
                }
            } else {
                e.setCancelled(true);
            }
		}
    }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:27,代碼來源:BasicFeatures.java

示例2: onPickupToQuickSlot

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPickupToQuickSlot(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player) || !ItemManager.allowedForPlayer(player, event.getItem().getItemStack(), false)) {
        return;
    }

    for (Slot quickSlot : SlotManager.instance().getQuickSlots()) {
        int slotId = quickSlot.getQuickSlot();
        if (quickSlot.isCup(player.getInventory().getItem(slotId)) && quickSlot.isValidItem(event.getItem().getItemStack())) {
            player.getInventory().setItem(slotId, event.getItem().getItemStack());
            event.getItem().remove();

            player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, .3f, 1.7f);
            if (Config.getConfig().getBoolean("attack.auto-held")) {
                player.getInventory().setHeldItemSlot(quickSlot.getQuickSlot());
            }

            event.setCancelled(true);
        }
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:24,代碼來源:InventoryListener.java

示例3: onPlayerPickupItem

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

示例4: onItemPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
	System.out.println("Item pickup");
	Item item = event.getItem();
	ItemStack stack = item.getItemStack();
	Location location = item.getLocation();
	Player player = event.getPlayer();
	String playerName = player == null ? "null" : player.getName();
	
	PickupItemObsel obsel = new PickupItemObsel(
			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: onPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPickupItem(PlayerPickupItemEvent event)
{
    Player player = event.getPlayer();
    if(featureEnabled(Features.SortInventory, player))
    {
        PlayerData playerData = PlayerData.FromPlayer(player);
        if(playerData.firstEmptySlot >= 0) return;
        
        PlayerInventory inventory = player.getInventory();
        int firstEmpty = inventory.firstEmpty();
        if(firstEmpty < 9) return;
        playerData.firstEmptySlot = firstEmpty; 
        PickupSortTask task = new PickupSortTask(player, playerData, inventory);
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.instance, task, 100L);
    }
}
 
開發者ID:BigScary,項目名稱:AutomaticInventory,代碼行數:18,代碼來源:AIEventHandler.java

示例6: onPlayerPickUp

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

	final PlayerStat stat = PlayerStat.ITEMS_PICKED_UP;

	// 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.getItem().getItemStack().getAmount(), "world", player.getWorld().getName(), "item", event.getItem().getItemStack().getType().toString()));

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

示例7: onPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onPickup(PlayerPickupItemEvent ppie) {
  Player player = ppie.getPlayer();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    game = BedwarsRel.getInstance().getGameManager().getGameByLocation(player.getLocation());
    if (game == null) {
      return;
    }
  }

  if (game.getState() != GameState.WAITING && game.isInGame(player)) {
    return;
  }

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

示例8: onPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
    public void onPickup(PlayerPickupItemEvent e){
        Item item = e.getItem();
        if(item.getCustomName()!=null) {
            String name = ChatColor.stripColor(item.getCustomName());
//		if(name!=null && ChatColor.stripColor(language.get("nameSyntax")).replace("{money}", "").equals(name.replaceAll(regex, ""))){
            e.setCancelled(true);
            String money = plugin.getMoney(name);
            Player p = e.getPlayer();
            if (p.hasPermission("PickupMoney.pickup")) {
                item.remove();
                float amount = Float.parseFloat(money);
                if(plugin.pickupMulti.containsKey(p.getUniqueId())) amount*=plugin.pickupMulti.get(p.getUniqueId());
                plugin.giveMoney(amount, p);
                p.sendMessage(plugin.language.get("pickup").replace("{money}", String.valueOf(amount)));
                if (plugin.fc.getBoolean("sound.enable")) {
                    p.getLocation().getWorld().playSound(p.getLocation(), Sound.valueOf(plugin.fc.getString("sound.type"))
                            , (float) plugin.fc.getDouble("sound.volumn")
                            , (float) plugin.fc.getDouble("sound.pitch"));
                }
            }
//		}
        }
    }
 
開發者ID:KickVN,項目名稱:PickupMoney,代碼行數:25,代碼來源:MainListener.java

示例9: onPlayerPickupBook

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
public void onPlayerPickupBook(PlayerPickupItemEvent event) {
		final Player player = event.getPlayer();
		if (player.getWorld().equals(griefFree)) {
			Item drop = event.getItem();
			if (drop.equals(droppedBook) || drop.equals(droppedShovel) || drop.equals(droppedStick)) {
//				PlayerInventory playerInv = player.getInventory();
				if (!recieved.contains(player)) {
					if (drop.equals(droppedBook)) {
						spawnBook(false);
						plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
							@Override 
							public void run() {
								recieved.add(player);
							}
						}, 2);
					}
				} else {
					event.setCancelled(true);
				}
			}
		}
	}
 
開發者ID:Esaych,項目名稱:DDCustomPlugin,代碼行數:23,代碼來源:DirectionBook.java

示例10: PickupItem

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

        // Pickup item check.
        if (player != null && !player.hasPermission("antibuild.bypass")) {
            if (!player.hasPermission("antibuild.pickupitems")) {
                event.setCancelled(true);
                // We can't message the player here or it spams.
            }
        }

//        // 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);
//                // We can't message the player here or it spams.
//            }
//        }
    }
 
開發者ID:MutinyCraft,項目名稱:AntiBuild,代碼行數:29,代碼來源:ItemPickup.java

示例11: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerPickupItem(PlayerPickupItemEvent 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

示例12: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
	Player p = event.getPlayer();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// Is the current player playing
	if(am.isInArena(p)) {
		ArenaPlayer ap = am.getPlayer(p);
		
		// Is the player in the lobby of the arena
		if(ap.isInLobby()) {
			
			// Has the player a arena spawn assigned
			if(ap.hasAssignedAreanSpawn())
				event.setCancelled(true);
		}

		// Is the player an spectators
		if(ap.isSpectator())
			event.setCancelled(true);
	}
}
 
開發者ID:timvisee,項目名稱:simple-survival-games,代碼行數:23,代碼來源:SSGPlayerListener.java

示例13: onPlayerPickupItem

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

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

	if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
	{
		if (!Permissions.PICKUP.isAuthorized(user, item.getType(), item.getData()))
		{
			event.setCancelled(true);
			event.getItem().setPickupDelay(50);
		}
	}
}
 
開發者ID:Curtis3321,項目名稱:Essentials,代碼行數:17,代碼來源:EssentialsAntiBuildListener.java

示例14: onItemPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
	Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
			.getGameManager().getGameOfPlayer(e.getPlayer());
	if (bw == null) {
		return;
	}
	if (!Config.isGameEnabledXP(bw.getName())) {
		return;
	}
	Player p = e.getPlayer();
	Item entity = e.getItem();
	ItemStack stack = entity.getItemStack();
	int count = Res.convertResToXP(stack);
	if (count == 0) {
		return;
	}
	e.setCancelled(true);
	XPManager.addXP(bw.getName(), p, count);
	p.playSound(p.getLocation(),
			SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
			10.0F, 1.0F);
	if (!Config.Message.equals("")) {
		ActionBarUtils.sendActionBar(p,
				Config.Message.replaceAll("%xp%", Integer.toString(count)));
		/*
		 * if (!ActionBarUtils.works) {
		 * p.sendMessage(Config.Message.replaceAll("%xp%",
		 * Integer.toString(count))); }
		 */
	}
	entity.remove();
}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:34,代碼來源:NewEventListeners.java

示例15: onItemPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
	Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
			.getGameOfPlayer(e.getPlayer());
	if (bw == null) {
		return;
	}
	if (!Config.isGameEnabledXP(bw.getName())) {
		return;
	}
	Player p = e.getPlayer();
	Item entity = e.getItem();
	ItemStack stack = entity.getItemStack();
	int count = Res.convertResToXP(stack);
	if (count == 0) {
		return;
	}
	e.setCancelled(true);
	XPManager.addXP(bw.getName(), p, count);
	p.playSound(p.getLocation(),
			SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
			10.0F, 1.0F);
	if (!Config.Message.equals("")) {
		ActionBarUtils.sendActionBar(p,
				Config.Message.replaceAll("%xp%", Integer.toString(count)));
		/*
		 * if (!ActionBarUtils.works) {
		 * p.sendMessage(Config.Message.replaceAll("%xp%",
		 * Integer.toString(count))); }
		 */
	}
	entity.remove();
}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:34,代碼來源:OldEventListeners.java


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