mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-27 17:28:28 +01:00
Fix trimming for worlds in non-standard directories
This commit is contained in:
parent
66730794d6
commit
629ff443f3
@ -31,6 +31,12 @@ public interface IPlotMain {
|
||||
* @return
|
||||
*/
|
||||
File getDirectory();
|
||||
|
||||
/**
|
||||
* Get the directory containing all the worlds
|
||||
* @return
|
||||
*/
|
||||
File getWorldContainer();
|
||||
|
||||
/**
|
||||
* Wrap a player into a PlotPlayer object
|
||||
|
@ -63,7 +63,7 @@ public class Trim extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
final String directory = world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final File folder = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
for (final File file : regionFiles) {
|
||||
final String name = file.getName();
|
||||
@ -155,12 +155,12 @@ public class Trim extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks) {
|
||||
ChunkManager.manager.deleteRegionFiles(world, chunks);
|
||||
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks, final Runnable whenDone) {
|
||||
ChunkManager.manager.deleteRegionFiles(world, chunks, whenDone);
|
||||
}
|
||||
|
||||
public static void sendMessage(final String message) {
|
||||
PS.debug("&3PlotSquared -> World trim&8: &7" + message);
|
||||
PS.log("&3PlotSquared -> World trim&8: &7" + message);
|
||||
}
|
||||
|
||||
public PlotId getId(final String id) {
|
||||
@ -211,8 +211,12 @@ public class Trim extends SubCommand {
|
||||
getTrimRegions(empty, world, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
deleteChunks(world, empty);
|
||||
PS.log("$1Trim task complete!");
|
||||
deleteChunks(world, empty, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PS.log("$1Trim task complete!");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -111,6 +111,8 @@ public abstract class ChunkManager {
|
||||
|
||||
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks);
|
||||
|
||||
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone);
|
||||
|
||||
public abstract Plot hasPlot(String world, ChunkLoc chunk);
|
||||
|
||||
public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);
|
||||
|
@ -180,7 +180,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public File getDirectory() {
|
||||
return getDataFolder();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getWorldContainer() {
|
||||
return Bukkit.getWorldContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
return new BukkitTaskManager();
|
||||
|
@ -68,8 +68,8 @@ import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
public ArrayList<ChunkLoc> getChunkChunks(final String world) {
|
||||
final String directory = Bukkit.getWorldContainer() + File.separator + world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final String directory = world + File.separator + "region";
|
||||
final File folder = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
if (regionFiles == null) {
|
||||
@ -123,8 +123,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
public void run() {
|
||||
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||
final File file = new File(directory);
|
||||
PS.debug("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
|
||||
final File file = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
PS.log("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
@ -136,18 +136,26 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks) {
|
||||
public void deleteRegionFiles(String world, List<ChunkLoc> chunks) {
|
||||
deleteRegionFiles(world, chunks, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (ChunkLoc loc : chunks) {
|
||||
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||
final File file = new File(directory);
|
||||
PS.debug("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
||||
final File file = new File(PS.get().IMP.getWorldContainer(), directory);
|
||||
PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -427,6 +427,11 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
return new File("mods/PlotSquared");
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorldContainer() {
|
||||
return new File(".");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
PS.get().disable();
|
||||
|
@ -120,7 +120,12 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteRegionFiles(String world, List<ChunkLoc> chunks, Runnable whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot hasPlot(String world, ChunkLoc chunk) {
|
||||
// TODO Auto-generated method stub
|
||||
|
Loading…
Reference in New Issue
Block a user