当前位置: 首页>>代码示例>>Java>>正文


Java PlayerPickupItemEvent.getItem方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerPickupItemEvent.getItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerPickupItemEvent.getItem方法的具体用法?Java PlayerPickupItemEvent.getItem怎么用?Java PlayerPickupItemEvent.getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerPickupItemEvent的用法示例。


在下文中一共展示了PlayerPickupItemEvent.getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

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

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

示例4: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event) {
    this.plugin.entering(this.getClass(), "onPlayerPickupItem");
    final Item i = event.getItem();
    if (this.itemMap.containsKey(i)) {
        this.plugin.debug("Item is handled by an Altar");
        final String playerName = event.getPlayer().getName();
        final String awaitedPlayerName = this.itemMap.get(i);
        if (!playerName.equals(awaitedPlayerName)) {
            if (this.plugin.isDebugEnabled()) {
                this.plugin.debug("Not the right player (" + playerName + "), cancel pickup. Awaited '" + awaitedPlayerName + '\'');
            }
            event.setCancelled(true);
        } else {
            this.plugin.debug("Right player, allow pickup");
            this.itemMap.remove(i);
            final Altar altar = this.plugin.getAltars().get(new ChunkCoord(i.getLocation().getChunk()));
            if (altar != null) {
                this.plugin.getItemProvidedToLockedTransition().doTransition(altar);
            }
        }
    }
    this.plugin.exiting(this.getClass(), "onPlayerPickupItem");
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:25,代码来源:ItemListener.java

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

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

示例7: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    // When this event is fired, the ItemStack in the Item being picked up is temporarily
    // set to the amount that will actually be picked up, while the difference from the
    // actual amount in the stack is available from getRemaining(). When the event returns,
    // the original amount is restored to the stack, meaning that we can't change the amount
    // from inside the event, so instead we replace the entire stack.

    int initialQuantity = event.getItem().getItemStack().getAmount();
    PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(
        event, ItemTransferEvent.Type.PICKUP, event.getPlayer(),
        Optional.empty(),
        Optional.of(new InventorySlot<>(event.getPlayer().getInventory())),
        event.getItem().getItemStack(), event.getItem(),
        initialQuantity, event.getPlayer().getOpenInventory().getCursor()
    );

    this.callEvent(transferEvent);

    int quantity = Math.min(transferEvent.getQuantity(), initialQuantity);

    if(!event.isCancelled() && quantity < initialQuantity) {
        event.setCancelled(true);
        if(quantity > 0) {
            ItemStack stack = event.getItem().getItemStack().clone();
            stack.setAmount(stack.getAmount() - quantity);
            event.getItem().setItemStack(stack);

            stack = stack.clone();
            stack.setAmount(quantity);
            event.getPlayer().getInventory().addItem(stack);
            event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:36,代码来源:ItemTransferListener.java

示例8: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
/**
 * Limits the player to one workbench in their inventory at a time, by means of picking up an item.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  Player player = event.getPlayer();
  if (item.getItemStack().getType().equals(Material.WORKBENCH)
      && player.getInventory().contains(Material.WORKBENCH)) {
    event.setCancelled(true);
    item.setPickupDelay(20);

    player.sendMessage(ChatColor.RED + "You may not pick up another workbench!");
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:18,代码来源:BenchBlitz.java

示例9: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
/**
 * Prevents a player from picking up a bow.
 *
 * @param event The event
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
  Item item = event.getItem();
  if (item.getItemStack().getType().equals(Material.BOW)) {
    event.setCancelled(true);
    item.setPickupDelay(20);
    
    event.getPlayer().sendMessage(ChatColor.RED + "You may not pick up a bow!");
  }
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:16,代码来源:Bowless.java

示例10: onPickUp

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPickUp(PlayerPickupItemEvent e) {
    TOAUser p = TOA.getPlayer(e.getPlayer());
    Item it = e.getItem();

    if (p.isOnRank(PACmd.Grupo.Admin)) {
        e.setCancelled(false);
        return;
    }
    if (plugin.getGm().getInTower().contains(p)) {
        e.setCancelled(true);
        addItem(p, it);
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:15,代码来源:BagEvents.java

示例11: onItemPickUp

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemPickUp(PlayerPickupItemEvent e) {
    if (e.isCancelled()) {
        return;
    }

    Item item = e.getItem();
    ItemStack is = item.getItemStack();

    if (isMoneyItem(is)) {
        e.setCancelled(true);

        BigDecimal money = new BigDecimal(Double.valueOf(ChatColor.stripColor(is.getItemMeta().getLore().get(0))
                .replaceAll("[^0-9.]", "")))
                .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN);

        EntityType entityType = EntityType.valueOf(is.getItemMeta().getLore().get(1));
        EntityProperties ep = EntityManager.getEntityProperties(entityType);

        if (ep == null) {
            return;
        }

        UUID uuid = UUID.fromString(is.getItemMeta().getLore().get(2));

        if (!DefaultConfig.isMoneyItemAnyonePickUp() && !uuid.equals(e.getPlayer().getUniqueId())) {
            return;
        }

        WorldProperties wp = EntityManager.getWorldProperties(ep, e.getItem().getLocation().getWorld().getName());

        if (wp != null) {
            item.remove();

            Bukkit.getPluginManager().callEvent(new KMEarnMoneyPickedUpEvent(wp.getMoneyProperties(),
                    e.getPlayer(), money));
        }
    }
}
 
开发者ID:diecode,项目名称:KillerMoney,代码行数:40,代码来源:MoneyHandler.java

示例12: onPlayerPickupPearl

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
/**
 * Prevent imprisoned players from picking up Prisonpearls.
 * @param e The event args
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerPickupPearl(PlayerPickupItemEvent e) {
	Item item = e.getItem();

	ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
	if (pearl == null) {
		return;
	}

	if (pearlApi.isPlayerExiled(e.getPlayer())) {
		e.setCancelled(true);
	}
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:18,代码来源:PlayerListener.java

示例13: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
/**
 * Track the location of a pearl if a player picks it up
 * @param e The event args
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent e) {
	Item item = e.getItem();

	ExilePearl pearl = pearlApi.getPearlFromItemStack(item.getItemStack());
	if (pearl == null) {
		return;
	}

	updatePearl(pearl, (Player) e.getPlayer());
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:16,代码来源:PlayerListener.java

示例14: onPlayerPickupItem

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
	Player player = event.getPlayer();
	SpleefArena arena = PlayerManager.getArena(player.getUniqueId());
	if (arena == null) {
		return;
	}
	Item item = event.getItem();
	if (item.hasMetadata("EpicSpleef:" + arena.getName() + ":Grenade")) {
		event.setCancelled(true);
		item.remove();
		player.getInventory().addItem(new ItemStack(Material.EGG));
	}
	if (item.hasMetadata("EpicSpleef:" + arena.getName() + ":Speed")) {
		event.setCancelled(true);
		item.remove();
		player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20*10, 1));
	}
	if (item.hasMetadata("EpicSpleef:" + arena.getName() + ":Jump")) {
		event.setCancelled(true);
		item.remove();
		player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20*10, 1));
	}
	if (item.hasMetadata("EpicSpleef:" + arena.getName() + ":Invisibility")) {
		event.setCancelled(true);
		item.remove();
		player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 20*3, 1));
	}
}
 
开发者ID:BtoBastian,项目名称:EpicSpleef,代码行数:30,代码来源:PlayerPickupItemListener.java

示例15: onArrowPickup

import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onArrowPickup(PlayerPickupItemEvent event) {
	Item arrow = event.getItem();
	Client client = Client.getClient(event.getPlayer());
	if(arrow == new ItemStack(Material.ARROW) && (client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning())) {
		event.setCancelled(true);
	}
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:9,代码来源:PlayerEvents.java


注:本文中的org.bukkit.event.player.PlayerPickupItemEvent.getItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。