Bukkit/CraftBukkit — pull request #1228 by me4502 (2013-08-11 06:31:01+00:00)
Title: [B+C] Implement method to get arrow itemstack and cancel item consume in EntityShootBowEvent. Adds BUKKIT-4686

The Issue:

Currently it is not possible to get the projectiles itemstack or stop it being consumed in EntityShootBowEvent.

Justification for this PR:

This PR adds the above mentioned capabilities to the event, through 3 new methods. getProjectileStack(), setStackConsumeCancelled(boolean), and isStackConsumeCancelled(). This allows these 3 things to be done, which prior to now were just not plausible through the bukkit API.

PR Breakdown:

This PR grabs a copy of the stack of the arrow before it is removed, and creates a clone of it. This clone is then given the count of 1 so that it is only a single arrow. This is then sent to the event.

The consume cancellation uses the 'flag' field, which currently is used by vanilla when the player is in creative or has the infinity enchantment. The PR is also capable or forcing a arrow to be consumed even in creative/infinity enchantment due to this.

Testing Results and Materials:

I created a small plugin that tests the features outlined in this PR. It is available here, http://pastebin.com/pUexySVu

Relevant PR(s):

None

B-#### - https://github.com/Bukkit/Bukkit/pull/#### - Reason
CB-#### - https://github.com/Bukkit/CraftBukkit/pull/#### - Reason

JIRA Ticket:

BUKKIT-4686 - https://bukkit.atlassian.net/browse/BUKKIT-4686