mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +01:00
Don't check/set if a chunk should be saved if it's a world-plot
This commit is contained in:
parent
823e78377b
commit
d1dbf777a4
@ -32,6 +32,7 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.util.ReflectionUtils.RefClass;
|
||||
import com.plotsquared.core.util.ReflectionUtils.RefField;
|
||||
import com.plotsquared.core.util.ReflectionUtils.RefMethod;
|
||||
@ -295,7 +296,7 @@ public class ChunkListener implements Listener {
|
||||
Chunk chunk = event.getChunk();
|
||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||
String world = chunk.getWorld().getName();
|
||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||
if ((!Settings.Enabled_Components.WORLDS || !SinglePlotArea.isSinglePlotWorld(world)) && this.plotAreaManager.hasPlotArea(world)) {
|
||||
if (unloadChunk(world, chunk, true)) {
|
||||
return;
|
||||
}
|
||||
@ -365,8 +366,7 @@ public class ChunkListener implements Listener {
|
||||
}
|
||||
|
||||
private void cleanChunk(final Chunk chunk) {
|
||||
TaskManager.index.incrementAndGet();
|
||||
final int currentIndex = TaskManager.index.get();
|
||||
final int currentIndex = TaskManager.index.incrementAndGet();
|
||||
PlotSquaredTask task = TaskManager.runTaskRepeat(() -> {
|
||||
if (!chunk.isLoaded()) {
|
||||
Objects.requireNonNull(TaskManager.removeTask(currentIndex)).cancel();
|
||||
|
@ -27,6 +27,7 @@ package com.plotsquared.bukkit.listener;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||
import com.plotsquared.core.util.ReflectionUtils;
|
||||
import org.bukkit.Chunk;
|
||||
@ -86,7 +87,7 @@ public class SingleWorldListener implements Listener {
|
||||
if (!(man instanceof SinglePlotAreaManager)) {
|
||||
return;
|
||||
}
|
||||
if (!isPlotId(name)) {
|
||||
if (!SinglePlotArea.isSinglePlotWorld(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,31 +104,4 @@ public class SingleWorldListener implements Listener {
|
||||
handle(event);
|
||||
}
|
||||
|
||||
private boolean isPlotId(String worldName) {
|
||||
int len = worldName.length();
|
||||
int separator = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
switch (worldName.charAt(i)) {
|
||||
case '_':
|
||||
separator++;
|
||||
break;
|
||||
case '-':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return separator == 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||
import com.plotsquared.core.listener.PlotListener;
|
||||
import com.plotsquared.core.location.BlockLoc;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.location.PlotLoc;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
@ -78,6 +77,38 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
this.setDefaultHome(new BlockLoc(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given string matches the naming system used to identify single plot worlds
|
||||
* e.g. -1_5 represents plot id *;-1;5. "*" being the plot area name given to single plot world
|
||||
* {@link com.plotsquared.core.plot.PlotArea}.
|
||||
*/
|
||||
public static boolean isSinglePlotWorld(String worldName) {
|
||||
int len = worldName.length();
|
||||
int separator = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
switch (worldName.charAt(i)) {
|
||||
case '_':
|
||||
separator++;
|
||||
break;
|
||||
case '-':
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return separator == 1;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected PlotManager createManager() {
|
||||
|
Loading…
Reference in New Issue
Block a user