Solved Setting custom name for Wolf, Cat and Parrot not working

Discussion in 'Spigot Plugin Development' started by Snicko, May 28, 2021.

  1. Is it just me, or can cats, wolves and parrots not be named? I am using

    Code (Java):
                Cat entity = (Cat) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.CAT);

                entity.setTamed(true);
                entity.setBaby();
                entity.setOwner((AnimalTamer)player);

                entity.setCustomName("Some name");
                entity.setCustomNameVisible(true);

    Although it works for example if I change it to a PIG.
     
  2. Seems to not work when I use entity.setOwner((AnimalTamer)player);
    Is this a bug?
     
  3. void setOwner(@Nullable AnimalTamer tamer)
    Set this to be owned by given AnimalTamer.
    If the owner is not null, this will be tamed and will have any current path it is following removed. If the owner is set to null, this will be untamed, and the current owner removed.

    Parameters:
    tamer - the AnimalTamer who should own this
     
  4. I think you've misread my problem.

    The issue is that the custom name will not show if I use setOwner();

    If I do:

    Code (Java):
                Cat entity = (Cat) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.CAT);

                entity.setCustomName("Some name");
                entity.setCustomNameVisible(true);
               
                Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
                    @Override
                    public void run() {
                        entity.setOwner(player);
                    }
                }, 30L);
    It will show the name when it spawns, and then when setOwner runs the name is removed for some reason.
    Doesn't work either if I set the name after.
     
  5. Why you need Runnable setOwner?
     
  6. I don't, it was just an example that if I don't use setOwner, the custom name will show properly.
    Then 30 ticks after it spawns, it sets the owner, and the custom name disappears from the entity. The custom name technically exists (entity.getCustomName() shows the name), although the name tag is no longer visible (entity.isCustomNameVisible() is true).
     
  7. Solved. Issue seems to be with the TAB plugin
     
    • Informative Informative x 1
  8. did you even read the question?
     
    • Funny Funny x 1