GetOwner() and SetOwner() on horse

Discussion in 'Plugin Development' started by user_91277742, Jun 1, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    user_91277742

    Hi there!, so.. i was looking the documentation and i dont really understand, how the getOwner and setOwner works. Basically im doing a horse plugin and i want to make a command to set an owner to a tamed horse . I know how to check if a horse is tamed and more stuff.
     
  2. Offline

    KarimAKL

    @Ahrigumi I've never tried this before but after reading this:
    https://hub.spigotmc.org/javadocs/s....html#setOwner-org.bukkit.entity.AnimalTamer-
    I'm thinking the owner is the one who tamed the horse, if it has an owner then it's tamed, if the owner is set to null, it'll be set as a wild horse.
    The 'setOwner' requires an 'AnimalTamer' and 'Player' implements 'AnimalTamer', so you should be able to set a player as the owner.
    The 'getOwner' returns an 'AnimalTamer', you should be able to check if it's instanceof 'Player' and then cast it to 'Player'.
     
  3. Offline

    user_91277742

    Oh, thank you so much. Now i can understand better how works, i will try more later :D

    Edit: Fixed! thanks!
     
    Last edited by a moderator: Jun 3, 2019
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page