mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
Don't check same plot over and over again
This commit is contained in:
parent
b224a8d1b8
commit
c25a0c65a2
@ -139,13 +139,18 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>>
|
||||
@Override
|
||||
public List<Plot> handle(@NonNull AutoQuery autoQuery) {
|
||||
Plot plot;
|
||||
PlotId nextId = autoQuery.getStartId();
|
||||
do {
|
||||
synchronized (plotLock) {
|
||||
plot = autoQuery.getPlotArea().getNextFreePlot(autoQuery.getPlayer(), autoQuery.getStartId());
|
||||
plot = autoQuery.getPlotArea().getNextFreePlot(autoQuery.getPlayer(), nextId);
|
||||
if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) {
|
||||
plotCandidateCache.put(plot.getId(), plot);
|
||||
return Collections.singletonList(plot);
|
||||
}
|
||||
// if the plot is already in the cache, we want to make sure we skip it the next time
|
||||
if (plot != null) {
|
||||
nextId = plot.getId();
|
||||
}
|
||||
}
|
||||
} while (plot != null);
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user