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


Java PlayerPickupItemEvent類代碼示例

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


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

示例1: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
private void onPlayerPickupItem(PlayerPickupItemEvent event)
{
    if (event.getItem().getItemStack() != null && event.getItem().getItemStack().getItemMeta() != null && event.getItem().getItemStack().getItemMeta().getDisplayName() != null)
    {
        if (this.alive && event.getItem().getItemStack().getItemMeta().getDisplayName().equals(this.uuid.toString()))
        {
            event.setCancelled(true);

            HandlerList.unregisterAll(this);

            this.remove(true);
            this.parent.onPickup(event.getPlayer());
        }
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:17,代碼來源:ActivePowerup.java

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

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

示例4: onBlockPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onBlockPickup(PlayerPickupItemEvent event) {
    if (event.getItem().getItemStack().getType() == material && event.getItem().getItemStack().getData().getData() == data) {
        if(this.touches.contains(event.getPlayer().getUniqueId())) return;

        TeamModule teamModule = TeamManager.getTeamByPlayer(event.getPlayer());

        if (teamModule == null) return;
        if(super.isCompletedBy(teamModule)) return;

        if (teamModule.getObjectives().contains(this)) {
            this.touches.add(event.getPlayer().getUniqueId());

            for (ScoreboardModule scoreboardModule : GameHandler.getGameHandler().getMatch().getModules().getModules(ScoreboardModule.class)) {
                scoreboardModule.refresh(this);
            }

            for (Player player : Bukkit.getOnlinePlayers()) {
                player.sendMessage(teamModule.getColor() + new LocalizedChatMessage(ChatConstant.GAME_CAPTURABLE_TOUCHED, event.getPlayer().getName() + ChatColor.DARK_AQUA, ChatColor.AQUA + super.getName() + ChatColor.DARK_AQUA, teamModule.getColor() + teamModule.getName() + ChatColor.DARK_AQUA).getMessage(player.spigot().getLocale()));
            }
        }
    }
}
 
開發者ID:Minehut,項目名稱:GamePlate,代碼行數:24,代碼來源:CapturableObjective.java

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

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

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

示例8: onItemPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
	
	if (e.isCancelled()) {
		return;
	}
	
	ItemStack item = e.getItem().getItemStack();
	
	if (item.getType().equals(Material.WRITTEN_BOOK)) {
		BookMeta meta = (BookMeta) item.getItemMeta();
		
		if (meta.getTitle().equals("Quest Log")) {
			e.getItem().remove();
			e.setCancelled(true);
			
			QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
					e.getPlayer().getUniqueId()).addQuestBook();
			
		}
	}
	
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:24,代碼來源:QuestManager.java

示例9: onInventoryChange

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler
public void onInventoryChange(PlayerPickupItemEvent e) {
	if (this.participants == null) {
		return;
	}
	if (state) {
		return;
	}
	if (!e.isCancelled() && e.getItem().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

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

示例11: d

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@Override
public void d(final EntityHuman entityhuman) {
    if (!this.world.isClientSide && this.inGround && (this.shake <= 0)) {
        boolean pickup = (this.fromPlayer == 1) || ((this.fromPlayer == 2) && entityhuman.abilities.canInstantlyBuild);

        ItemStack itemstack = this.getItemStack();
        if ((this.fromPlayer == 1) && !entityhuman.inventory.pickup(itemstack)) {
            pickup = false;
        }

        final EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
        final PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
        this.world.getServer().getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        if (pickup) {
            this.makeSound("random.pop", 0.2F, (((this.random.nextFloat() - this.random.nextFloat()) * 0.7F) + 1.0F) * 2.0F);
            entityhuman.receive(this, 1);
            this.die();
        }
    }
}
 
開發者ID:MCCarbon,項目名稱:Carbon-2,代碼行數:25,代碼來源:EntityNewArrow.java

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

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

示例14: onPlayerPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPickup(PlayerPickupItemEvent event) {
	
	String name;
	boolean rare = false;
	if (event.getItem().getItemStack().getItemMeta().hasDisplayName()) {
		name = event.getItem().getItemStack().getItemMeta().getDisplayName();
		rare = true;
	} else {
		name = event.getItem().getItemStack().getType().name().replace("_", " ").toLowerCase();
	}
	
	Resident resident = CivGlobal.getResident(event.getPlayer());
	if (resident.getItemMode().equals("all")) {
		CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
	} else if (resident.getItemMode().equals("rare") && rare) {
		CivMessage.send(event.getPlayer(), CivColor.LightGreen+"You've picked up "+CivColor.LightPurple+event.getItem().getItemStack().getAmount()+" "+name);
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:20,代碼來源:PlayerListener.java

示例15: OnPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR) 
public void OnPlayerPickupItem(PlayerPickupItemEvent event) {
	BonusGoodie goodie = CivGlobal.getBonusGoodie(event.getItem().getItemStack());
	
	if (goodie == null) {
		return;
	}
	
	try {
		goodie.setHolder(event.getPlayer());
		goodie.update(false);
		goodie.updateLore(event.getItem().getItemStack());
	} catch (CivException e) {
		e.printStackTrace();
	}
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:17,代碼來源:BonusGoodieManager.java


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