From e3381e895d170a74ce2ce07958f227f3ec4d0df9 Mon Sep 17 00:00:00 2001 From: garbagemule Date: Wed, 7 Aug 2013 02:00:17 +0200 Subject: [PATCH] Some null checks for pet spawner. --- src/com/garbagemule/MobArena/ArenaImpl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/com/garbagemule/MobArena/ArenaImpl.java b/src/com/garbagemule/MobArena/ArenaImpl.java index 06221d2..65e8d86 100644 --- a/src/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/com/garbagemule/MobArena/ArenaImpl.java @@ -719,12 +719,19 @@ public class ArenaImpl implements Arena private void spawnPets() { for (Player p : arenaPlayers) { + // Skip players who are either null or offline + if (p == null || !p.isOnline()) continue; + + // Grab the inventory + PlayerInventory inv = p.getInventory(); + if (inv == null) continue; + // Find the first slot containing bones - int bone = p.getInventory().first(Material.BONE); + int bone = inv.first(Material.BONE); if (bone == -1) continue; // Get the amount of pets to spawn - int amount = p.getInventory().getItem(bone).getAmount(); + int amount = inv.getItem(bone).getAmount(); // Spawn each pet for (int i = 0; i < amount; i++) { @@ -738,7 +745,7 @@ public class ArenaImpl implements Arena } // Remove the bones - p.getInventory().setItem(bone, null); + inv.setItem(bone, null); } }