Spawning Tamed animals

Discussion in 'Spigot Help' started by DeathBySpork, Jun 11, 2017.

  1. I am trying to make a plugin that allows users to buy animals, and I almost have it done, but I keep having an error with this code:


    public void parrot(PlayerInteractEvent e) {
    if (e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GREEN + "Spawning parrot...")) {
    Player p = (Player) e.getPlayer();
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
    Block clicked = e.getClickedBlock();
    Location spawn = clicked.getLocation();

    Parrot parrot = (Wolf) spawn.getWorld().spawnEntity(spawn, parrot);
    parrot.setTamed(true);
    parrot.setOwner(p);

    }

    }

    }


    on the line:
    Parrot parrot = (Wolf) spawn.getWorld().spawnEntity(spawn, parrot);

    it says at the end that parrot has not been initialized, but I am initializing it right there... am I just being silly or is there a reasonable explination for this? thanks for your help!
     
  2. Parrot parrot = (Wolf) spawn.getWorld().spawnEntity(spawn, parrot);