Skip to content
Permalink
Browse files
Make sure the world is loaded when popping from the location history
  • Loading branch information
killme committed Jul 10, 2018
1 parent dbe6a13 commit bdf603a3f811b99d53687339acdd492c51a38607
Showing 1 changed file with 14 additions and 1 deletion.
@@ -21,13 +21,15 @@
import com.sk89q.commandbook.session.PersistentSession;
import com.sk89q.minecraft.util.commands.CommandException;
import com.zachsthings.libcomponents.config.Setting;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
@@ -105,7 +107,18 @@ public void rememberLocation(Player player) {
}

public Location popLastLocation() {
return locationHistory.poll();
Location l = locationHistory.poll();
if (l == null) {
return null;
}

// Make sure that the world of this location is still valid.
UUID worldId = l.getWorld().getUID();
if (Bukkit.getWorld(worldId) == null) {
return null;
}

return l;
}

public void setIgnoreLocation(Location loc) {

0 comments on commit bdf603a

Please sign in to comment.