Fixed lots of issues caused by child objects not sending packets to those aware of their parent object

This commit is contained in:
Ziggeh
2015-05-21 20:21:18 +02:00
parent 9cfffeaf0f
commit 66dcc7159e
+14 -1
View File
@@ -251,7 +251,13 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
}
public Player getOwner() {
return owner;
if (owner != null)
return owner;
if (getParent() != null)
return getParent().getOwner(); // Ziggy: Player owner is found recursively
return null;
}
public SWGObject getParent() {
@@ -376,10 +382,17 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
continue;
p.sendPacket(packets);
}
SWGObject parent = getParent();
if(parent != null)
parent.sendObservers(packets);
}
}
public void sendSelf(Packet ... packets) {
Player owner = getOwner();
if (owner != null)
owner.sendPacket(packets);
}