Removes tamed animal ownership on new island

Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1450
This commit is contained in:
tastybento 2020-12-24 10:15:14 -08:00
parent 267387af7a
commit aec2e115eb

View File

@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.entity.Tameable;
import org.bukkit.util.Vector;
import world.bentobox.bentobox.BStats;
@ -246,6 +247,11 @@ public class NewIsland {
* @param loc - the new island location
*/
private void cleanUpUser(Location loc) {
// Remove any tamed animals
world.getEntitiesByClass(Tameable.class).stream()
.filter(Tameable::isTamed)
.filter(t -> t.getOwner() != null && t.getOwner().equals(user.getPlayer()))
.forEach(t -> t.setOwner(null));
// Clear any old home locations (they should be clear, but just in case)
plugin.getPlayers().clearHomeLocations(world, user.getUniqueId());
// Set home location