mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16: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
|
@Override
|
||||||
public List<Plot> handle(@NonNull AutoQuery autoQuery) {
|
public List<Plot> handle(@NonNull AutoQuery autoQuery) {
|
||||||
Plot plot;
|
Plot plot;
|
||||||
|
PlotId nextId = autoQuery.getStartId();
|
||||||
do {
|
do {
|
||||||
synchronized (plotLock) {
|
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) {
|
if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) {
|
||||||
plotCandidateCache.put(plot.getId(), plot);
|
plotCandidateCache.put(plot.getId(), plot);
|
||||||
return Collections.singletonList(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);
|
} while (plot != null);
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user