1.15.2 Get player that bred

Discussion in 'Spigot Plugin Development' started by MiniGutt, Mar 2, 2020.

  1. Hello, I am trying to get the player who bred two animals, but cant seem to get it to work.
    Code (Text):
        @EventHandler
        public void onEntityBreed(EntityBreedEvent event) {
            LivingEntity entity = event.getBreeder();
            Player player = entity.getKiller();
            Stats stats = StatsPlugin.playerStatsRepo.getUser(player.getUniqueId());
            stats.setAnimalsBred(stats.getAnimalsBred()+1);
            StatsPlugin.playerStatsRepo.update(stats);
        }
    This doesnt work. What can I do to get the players name or player object of the person who bred?
     
  2. md_5

    Administrator Developer

    Check if player and cast to Player.

    Your code currently gets the killer of the breer, of course it doesn't work
     
    • Like Like x 1
  3. Why ... Why would you fetch the killer?