Increment loop index whether or not command succeeded. Fixes BUKKIT-5455

When VanillaCommandWrapper dispatches a command containing a
PlayerSelector wtih c>-1 (implicitly true for @a), it loops over the
selected players and exectures the command with each player. However, the
loop index is only incremented if the command fails. As a result, a
successful command is repeated on the same player indefinitely, locking up
the server. This commit fixes the issue by incrementing the loop index
regardless of whether the command succeeds, ensuring the command is only
executed once per player identified by the PlayerSelector.

(cherry picked from commit cd49afd5475ad7723e77311b6de99eb3037b22db)
Merged e682ac7 from upstream manually
Add equals for CraftInventory objects. Adds BUKKIT-4110

When working with inventories you regularly end up with different
Inventory objects that have the same underlying Minecraft inventory.
Currently, even those these point to the same thing, they are not
considered equal. With this commit comparing any Inventory object that
represents the same inventory will result in equals(Object) returning
true.

(cherry picked from commit 23af8223f01bbb3ea236fc6ca8eae1aaf810e313)
Add methods to use arbitrary entries in scoreboards. Adds BUKKIT-3977

(cherry picked from commit 1ab090e71ea261fe38cef980bc2ebe696a494ea3)
[Bleeding] Add missing HangingBreakEvent. Fixes BUKKIT-3943

The old PaintingBreakByEntityEvent was deprecated and replaced by
HangingBreakByEntityEvent. However, in the case of being struck by
lightning, only the deprecated event was being called. This fixes that so
that both the new and old events are called appropriately.

(cherry picked from commit 94f44bfd5cdf40f2167e094950c496b0649fd6e5)
Minor source adjustment to satisfy the following merge
[Bleeding] Add all blocks needed to PortalCreateEvent. Fixes BUKKIT-5464

Due to changes in how portals were created in Minecraft 1.7, the code that
was previously used to find the blocks involved in the PortalCreateEvent
no longer detected all blocks. Additionally, in the process of updating to
1.7.2, a missed diff resulted in some blocks that were found not being
properly added to the blocklist. This commit corrects that missed diff,
while also adding a check to ensure that the top and bottom of the portal
frame are included in the blocklist.

(cherry picked from commit 79ce6323ca49b6b1aa140b49308d9f95437f5e41)
[Bleeding] Ensure skeletons spawn with equipment. Fixes BUKKIT-2836

Previously, when a skeleton was spawned via the spawn(...) function, the
resulting skeleton had no equipped bow and therefore could not properly
attack. This fix gives all skeletons the proper equipment and ensures that
they are able to attack.

(cherry picked from commit a2d90d3e30db2bf2897f19ff0b93461dfc8a487f)
[Bleeding] Return correct furnace SlotType. Fixes BUKKIT-5400

Previously, the SlotType for the 0 slot in a furnace returned CONTAINER,
when it should have returned SlotType.CRAFTING. This updates the code for
determining slot type to return the proper value.

(cherry picked from commit abf90f945408fed2274321b2f9133f8f9a89c21c)
[Bleeding] Return correct player SlotType. Fixes BUKKIT-3188

Previously, the SlotType for the last 4 slots in a player's inventory
returned QUICKBAR when it should have returned SlotType.CONTAINER. This
updates the code for determining slot type to return the proper value.

(cherry picked from commit cce775e72a414490b5d105581c91388788330a95)
[Bleeding] Fix some inventories not using maxStack. Fixes BUKKIT-2883

CraftBukkit adds the ability to specify the maxStack size for most
inventories. However, some inventories were not overriding the getMaxStack
method properly, and so the functionality was unavailable. This fixes the
maxStack setting for Anvils, Minecarts, PlayerInventory, and Hoppers.

(cherry picked from commit c549609d91182cf65afd2d16fa4dcfc84be7ebf3)
[Bleeding] Ice in the nether fades to air. Fixes BUKKIT-5373

Previously, whenever BlockFadeEvent was called for ice melting, it returned
the new BlockState with a type of Material.STATIONARY_WATER. However, in
the Nether, ice melting does not form water, but is simply replaced by air
instead. This changes the event to use the proper BlockState based on
whether the block is located in the Nether or not.

(cherry picked from commit 485d0028a980a4804365fa8bcc8d252b7a0e43de)
[Bleeding] Don't allow null display names. Fixes BUKKIT-5254

Currently, plugins can set a player's display name to null, which could
cause issues for other calls to getDisplayName that aren't expecting a null
value. This changes setDisplayName to follow the same logic as
setPlayerListName, which sets the player's name back to their unmodified
"vanilla" name if it receives a null value as a parameter.

(cherry picked from commit 04c2dcf97e29821eeec3537b470058238a5fa8d1)
Added BlockPoweredRail for diff visibility
[Bleeding] Call BlockRedstoneEvent for all rails. Adds BUKKIT-4080

Previously, Detector Rails were the only rails that properly called
BlockRedstoneEvent when they changed from powered to unpowered. This commit
adds BlockRedstoneEvent calls for both Powered Rails and Activator Rails.
Added PathfinderGoalOcelotAttack for diff visibility
Merged 2b6a9ce for the cases that apply to 1.7.2
Removed the last accessed chunk cache as in 8ede1c3, but I am keeping the chunk lock for not loaded chunks in there
Call event when boat is destroyed by falling. Fixes BUKKIT-5500

(cherry picked from commit 616bcefa77324200f5102acc6ef874d9271047db)
Check that item in hand is not null after book event. Fixes BUKKIT-5443

(cherry picked from commit c72b381440bb899ca3a6eaa350c0ec4aa45d5c36)