Bukkit/CraftBukkit — pull request #1197 by LinearLogic (2013-07-15 01:00:26+00:00)
Title: [B+C] Implement ChickenLayEggEvent. Adds BUKKIT-4558.

### The Issue:
Bukkit currently provides no adequate method of determining when a chicken lays an egg, something developers have long desired to do in order to regulate "chicken farms" and add modify the items dropped, among other things. Forced to exercise their creativity, members of the community have devised a variety of workarounds - such as checking for the proximity of a chicken in an ItemSpawnEvent handler - but even in the event that one is able to stop an egg from being spawned, the "plopping" sound is still played; this can currently only be prevented using packet manipulation.

### The Justification:
The aforementioned workarounds are inelegant and inefficient, and can be rendered unnecessary with ten or so lines of CraftBukkit code. This PR enables chickens' egg laying behavior to be modified in the following ways:
* Egg laying events can be cancelled and will prevent the egg drop sound from being played
* The item being laid can be retrieved and changed (setting the item to null effectively cancels the event)
* The amount of time, in ticks, before the next egg is laid can be retrieved and changed
* Whether the egg drop sound plays can be toggled, allowing for silent drops

### PR Breakdown:
This PR adds a conventional event caller method to the CraftEventFactory, and modifies EntityChicken code to call said method when the number of ticks before a chicken is scheduled to lay an egg reaches zero. The event is constructed with the chicken (cast to its Bukkit mirror) and the number of ticks before the next egg should be laid (generated using the vanilla server method, which assigns a random value between 6000 and 12000).

Regardless of whether the event is cancelled, the time until the chicken lays its next egg is updated with event.getTicksUntilNextEgg(). The CB code then returns if the event is cancelled or the item is null. Otherwise, the item to be spawned into the world is updated via event.getItem() and the "mob.chicken.plop" sound is played iff event.willSoundPlay() returns true.

### Testing Materials and Results:
The following plugin was used to verify the functionality of the changes made in this commit and in those of the sister PR:
* Source: https://github.com/LinearLogic/ChickenOut
* Compiled jar: http://veltro.org/dev/mc/ChickenOut.jar

No issues were encountered during testing.

### Other Resources:
**Relevant PR:**
B-902 - https://github.com/Bukkit/Bukkit/pull/902 - adds the ChickenLayEggEvent implemented in this PR.

**JIRA Ticket:**
BUKKIT-4558 - https://bukkit.atlassian.net/browse/BUKKIT-4558

*No chickens were harmed in the making of this PR.*