Skip to content

Commit

Permalink
Version 0.11.2: Fix NPE when logging kills of skeleton horses.
Browse files Browse the repository at this point in the history
In 1.9, skeleton horses spawn naturally, tame but with no owner, violating
a previous assumption in the code that a tame animal always has an owner.

Also fixes a similar NPE when untaming skeleton horses.
  • Loading branch information
totemo committed May 10, 2016
1 parent 0886aef commit d32f032
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>nu.nerd</groupId>
<artifactId>KitchenSink</artifactId>
<name>KitchenSink</name>
<version>0.11.1</version>
<version>0.11.2</version>
<packaging>jar</packaging>
<description>A plugin for miscellaneous functionality that hasn't found a home elsewhere.</description>
<url>https://github.com/NerdNu/KitchenSink</url>
Expand Down
6 changes: 4 additions & 2 deletions src/nu/nerd/kitchensink/KitchenSinkListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (tameable.isTamed()) {
// Warn admins when they bypass ownership.
if (isPetAdmin && tameable.getOwner() != player) {
player.sendMessage(ChatColor.YELLOW + "That pet belongs to " + tameable.getOwner().getName() + ".");
String owner = tameable.getOwner() != null ? tameable.getOwner().getName() : "nobody";
player.sendMessage(ChatColor.YELLOW + "That pet belongs to " + owner + ".");
}

if (tameable.getOwner() == player || isPetAdmin) {
Expand Down Expand Up @@ -588,7 +589,8 @@ public void onEntityDeath(EntityDeathEvent event) {
}
}
}
if (tameable.isTamed()) {
// 1.9 spawns skeleton horses that are tame with no owner.
if (tameable.isTamed() && tameable.getOwner() != null) {
message += "|Owner:" + tameable.getOwner().getName();
}
}
Expand Down

0 comments on commit d32f032

Please sign in to comment.