Skip to content

Commit

Permalink
Fix NPE in 'getPet().getCraftPet()'
Browse files Browse the repository at this point in the history
We called getPet() while we were trying to create the pet
  • Loading branch information
Techcable committed May 14, 2016
1 parent c9e45a4 commit 7e3b72e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
Expand Down Expand Up @@ -104,7 +105,8 @@ public EntityPet spawn(IPet pet, Player owner) {
EntityPet entityPet = (EntityPet) pet.getPetType().getNewEntityPetInstance(mcWorld, pet);

entityPet.spawnIn(mcWorld);
entityPet.getPet().getCraftPet().setCollidable(false);
//noinspection RedundantCast - the version of craftbukkit we compile against doesn't have this method, but the version of bukkit does
((Creature) entityPet.getBukkitEntity()).setCollidable(false);
entityPet.setLocation(new Location(mcWorld.getWorld(), l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch()));
if (!l.getChunk().isLoaded()) {
l.getChunk().load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public EntityPet spawn(IPet pet, Player owner) {
EntityPet entityPet = (EntityPet) pet.getPetType().getNewEntityPetInstance(mcWorld, pet);

entityPet.spawnIn(mcWorld);
entityPet.getPet().getCraftPet().setCollidable(false);
entityPet.getBukkitEntity().setCollidable(false);
entityPet.setLocation(new Location(mcWorld.getWorld(), l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch()));
if (!l.getChunk().isLoaded()) {
l.getChunk().load();
Expand Down

0 comments on commit 7e3b72e

Please sign in to comment.