@EventHandler public void onArrowPickup(PlayerPickupArrowEvent event) { // Only needed for players picking up arrows stuck in blocks final ItemStack item = event.getItem().getItemStack(); if(applyRules(item)) { event.getItem().setItemStack(item); } }
@EventHandler public void on(PlayerPickupArrowEvent event) { Player player = event.getPlayer(); PlayerData data = plugin.playerManager.getData(player.getUniqueId()); if (data != null) { if (data.isInGame()) { if (event.getArrow() != null) { if (event.getArrow().hasMetadata("MURDER")) { event.setCancelled(true); event.getArrow().remove(); } } } } }
public void d(EntityHuman entityhuman) { if (!this.world.isClientSide && this.inGround && this.shake <= 0) { // CraftBukkit start ItemStack itemstack = new ItemStack(Items.ARROW); if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) { EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity()); // event.setCancelled(!entityhuman.canPickUpLoot); TODO this.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return; } } // CraftBukkit end boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild; if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) { flag = false; } if (flag) { this.a(SoundEffects.cV, 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, 1); this.die(); } } }
@EventHandler public void onPickupArrow(PlayerPickupArrowEvent event) { if (isSpectating(event.getPlayer())) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPickupArrow(PlayerPickupArrowEvent event) { if (!isPlayerSpectator(event.getPlayer())) return; event.setCancelled(true); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupArrow(PlayerPickupArrowEvent event) { if (this.isObserving(event.getPlayer())) { event.setCancelled(true); } }