Removed AnimalTamer cache, fixes BUKKIT-1628

Dieser Commit ist enthalten in:
Wesley Wolfe 2012-05-24 23:02:02 -05:00
Ursprung c43012ef1c
Commit 5d3c8bfaa4

Datei anzeigen

@ -4,12 +4,9 @@ import net.minecraft.server.EntityTameableAnimal;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creature { public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creature {
private AnimalTamer owner;
public CraftTameableAnimal(CraftServer server, EntityTameableAnimal entity) { public CraftTameableAnimal(CraftServer server, EntityTameableAnimal entity) {
super(server, entity); super(server, entity);
} }
@ -20,12 +17,11 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
} }
public AnimalTamer getOwner() { public AnimalTamer getOwner() {
if (owner == null && !("").equals(getOwnerName())) { if (("").equals(getOwnerName())) return null;
owner = getServer().getPlayer(getOwnerName());
if (owner == null) { AnimalTamer owner = getServer().getPlayerExact(getOwnerName());
owner = getServer().getOfflinePlayer(getOwnerName()); if (owner == null) {
} owner = getServer().getOfflinePlayer(getOwnerName());
} }
return owner; return owner;
@ -40,17 +36,10 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
} }
public void setOwner(AnimalTamer tamer) { public void setOwner(AnimalTamer tamer) {
owner = tamer; if (tamer != null) {
if (owner != null) {
setTamed(true); setTamed(true);
getHandle().setPathEntity(null); getHandle().setPathEntity(null);
setOwnerName(tamer.getName());
if (owner instanceof Player) {
setOwnerName(((Player) owner).getName());
} else {
setOwnerName("");
}
} else { } else {
setTamed(false); setTamed(false);
setOwnerName(""); setOwnerName("");
@ -58,7 +47,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
} }
public void setOwnerName(String ownerName) { public void setOwnerName(String ownerName) {
getHandle().setOwnerName(ownerName); getHandle().setOwnerName(ownerName == null ? "" : ownerName);
} }
public void setTamed(boolean tame) { public void setTamed(boolean tame) {