Horse clones from /zh here are incomplete
RedPanda4552 opened this issue ยท 5 comments
Horses teleported with /zh here
are only partially reconstructed versions of the original. The owner field is stripped away. Carried saddles also don't carry over, and I don't see a setter for the armor either.
Adding something to the effect of horse.setOwner(Bukkit.getPlayer(statRecord.getOwnerUUID()));
in your HorseManager.assignStats()
method should do the trick for the owner, if I am reading everything right.
I might have skipped the owner indeed.
However, saddles or any other inventory item should be copied thanks to this method : https://github.com/Xibalba/ZHorse/blob/master/src/com/gmail/xibalbazedd/zhorse/managers/HorseManager.java#L262
Are there any errors in the console when executing /zh here ?
I do not have console access; I am actually another plugin dev who the server owners contacted about this.
It looks like the inventory clone isn't doing the trick. Normal horses have a HorseInventory
object that has specific definitions for the saddle and armor slot, and these don't exist in the Inventory
object inherited from LivingEntity
. I know there is also a LlamaInventory
that does the same thing. But all the other horse types, I haven't found a good way to access saddles. Type casting the inventory won't do either.
I haven't been super pleased with the 1.11.x APIs from Spigot for these reasons...
Well, a console output would help because it works fine on many other servers :p
I just updated my test server to the very last Spigot release and it still works, so I can't really help without other details.
About the inventory, I don't know the internal behaviour of Inventory::setContent but it might be overrided by all sub-classes of Inventory, or taking the size and slots into account, thus allowing to transfer saddles, armors, chests, etc. as expected.
I just modified one of my plugins to imitate this inventory copy with the generic getInventory()
and it does seem to work. So now I can't even reproduce my own problem on my test server. At this point I'm willing to chalk that up to a server side problem of theirs.
Now, other problem I just had on their server was duplication. /zh here made a clone and didn't remove the old. I can't help with reproduction on this one, as Vault is throwing permission errors on my test server (I don't have permissions plugins, I just have OP for everything). But thought I'd let you know this popped up as well.