Add in checks for potential NPEs. Fixes BUKKIT-1706 and BUKKIT-1590.

This commit is contained in:
Travis Watkins
2012-05-24 19:11:05 -05:00
parent 2f16b8ffa3
commit c1bc0df718
4 changed files with 13 additions and 1 deletions

View File

@@ -221,6 +221,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
}
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
if (player.netServerHandler == null) return;
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
container = CraftEventFactory.callInventoryOpenEvent(player, container);
@@ -270,6 +271,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public void openInventory(InventoryView inventory) {
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
if (getHandle().activeContainer != getHandle().defaultContainer) {
// fire INVENTORY_CLOSE if one already open
((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));