Skip to content

Commit

Permalink
Removes tamed animal ownership on new island
Browse files Browse the repository at this point in the history
Fixes #1450
  • Loading branch information
tastybento committed Dec 24, 2020
1 parent 267387a commit aec2e11
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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;
Expand Down Expand Up @@ -246,6 +247,11 @@ private void postCreationTask(Island oldIsland) {
* @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
Expand Down

0 comments on commit aec2e11

Please sign in to comment.