mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Fixed bug where animals could be bred or fed to grow up.
https://github.com/BentoBoxWorld/bentobox/issues/366
This commit is contained in:
parent
ff7a43feea
commit
3e07554d3b
@ -33,8 +33,7 @@ public class BreedingListener extends FlagListener {
|
||||
Material.WHEAT_SEEDS,
|
||||
Material.SEAGRASS);
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
|
||||
if (e.getRightClicked() instanceof Animals) {
|
||||
ItemStack inHand = e.getPlayer().getInventory().getItemInMainHand();
|
||||
@ -42,9 +41,10 @@ public class BreedingListener extends FlagListener {
|
||||
inHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
}
|
||||
if (inHand != null && BREEDING_ITEMS.contains(inHand.getType())) {
|
||||
checkIsland(e, e.getRightClicked().getLocation(), Flags.BREEDING);
|
||||
if (!checkIsland(e, e.getRightClicked().getLocation(), Flags.BREEDING)) {
|
||||
((Animals)e.getRightClicked()).setBreed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -239,6 +239,8 @@ public class BreedingListenerTest {
|
||||
bl.onPlayerInteract(e);
|
||||
assertFalse("Animal, breeding item in main hand, wrong world failed " + breedingMat, e.isCancelled());
|
||||
}
|
||||
// verify breeding was prevented
|
||||
Mockito.verify(clickedEntity, Mockito.never()).setBreed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,6 +258,8 @@ public class BreedingListenerTest {
|
||||
bl.onPlayerInteract(e);
|
||||
assertTrue("Animal, breeding item in main hand failed " + breedingMat, e.isCancelled());
|
||||
}
|
||||
// verify breeding was prevented
|
||||
Mockito.verify(clickedEntity, Mockito.times(5)).setBreed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,6 +279,8 @@ public class BreedingListenerTest {
|
||||
bl.onPlayerInteract(e);
|
||||
assertFalse("Animal, breeding item in off hand, wrong world failed " + breedingMat, e.isCancelled());
|
||||
}
|
||||
// verify breeding was not prevented
|
||||
Mockito.verify(clickedEntity, Mockito.never()).setBreed(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,5 +299,7 @@ public class BreedingListenerTest {
|
||||
bl.onPlayerInteract(e);
|
||||
assertTrue("Animal, breeding item in off hand failed " + breedingMat, e.isCancelled());
|
||||
}
|
||||
// verify breeding was prevented
|
||||
Mockito.verify(clickedEntity, Mockito.times(5)).setBreed(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user