本文整理汇总了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);
}
示例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"));
}
}
// }
}
}
示例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);
}
}
}
}
示例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");
}
示例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();
}
示例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();
}
示例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);
}
}
}
示例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!");
}
}
示例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!");
}
}
示例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);
}
}
示例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));
}
}
}
示例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);
}
}
示例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());
}
示例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));
}
}
示例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);
}
}