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