Java Code Examples for org.bukkit.event.player.PlayerPickupArrowEvent

The following are top voted examples for showing how to use org.bukkit.event.player.PlayerPickupArrowEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProjectAres   File: ItemModifyMatchModule.java   View source code 5 votes vote down vote up
@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);
    }
}
 
Example 2
Project: Murder   File: GameListenerArrow.java   View source code 5 votes vote down vote up
@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();
				}
			}
		}
	}
}
 
Example 3
Project: SpigotSource   File: EntityArrow.java   View source code 5 votes vote down vote up
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();
        }

    }
}
 
Example 4
Project: Warzone   File: SpectatorModule.java   View source code 4 votes vote down vote up
@EventHandler
public void onPickupArrow(PlayerPickupArrowEvent event) {
    if (isSpectating(event.getPlayer())) {
        event.setCancelled(true);
    }
}
 
Example 5
Project: AthenaGM   File: SpectatorModule.java   View source code 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerPickupArrow(PlayerPickupArrowEvent event) {
    if (!isPlayerSpectator(event.getPlayer())) return;
    event.setCancelled(true);
}
 
Example 6
Project: Arcade2   File: ObserverListeners.java   View source code 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupArrow(PlayerPickupArrowEvent event) {
    if (this.isObserving(event.getPlayer())) {
        event.setCancelled(true);
    }
}