Skip to content

Commit

Permalink
Delay cross-world teleports
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 10, 2020
1 parent 6ee5c65 commit 6436dd5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/net/citizensnpcs/api/npc/AbstractNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,16 @@ public void setUseMinecraftAI(boolean use) {
private void teleport(final Entity entity, Location location, int delay) {
final Entity passenger = entity.getPassenger();
entity.eject();
entity.teleport(location);
if (!location.getWorld().equals(entity.getWorld())) {
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
entity.teleport(location);
}
}, delay++);
} else {
entity.teleport(location);
}
if (passenger == null)
return;
teleport(passenger, location, delay++);
Expand Down

0 comments on commit 6436dd5

Please sign in to comment.