Conflicts:
	src/main/java/com/intellectualcrafters/plot/IPlotMain.java
	src/main/java/com/intellectualcrafters/plot/commands/Trim.java
	src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
	src/main/java/com/plotsquared/bukkit/BukkitMain.java
	src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
	src/main/java/com/plotsquared/sponge/SpongeMain.java
	src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java
This commit is contained in:
boy0001 2015-09-13 13:46:45 +10:00
commit 1cccdd9d4d
10 changed files with 80 additions and 54 deletions

View File

@ -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

View File

@ -237,6 +237,33 @@ public class PS
} }
} }
} }
// Auto clearing
if (Settings.AUTO_CLEAR)
{
ExpireManager.runTask();
}
// PlotMe
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME)
{
TaskManager.runTaskLater(new Runnable()
{
@Override
public void run()
{
if (IMP.initPlotMeConverter())
{
log("&c=== IMPORTANT ===");
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
}
}
}, 20);
}
} }
}); });
} }
@ -278,33 +305,6 @@ public class PS
} }
}); });
// PlotMe
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME)
{
TaskManager.runTaskLater(new Runnable()
{
@Override
public void run()
{
if (IMP.initPlotMeConverter())
{
log("&c=== IMPORTANT ===");
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
}
}
}, 200);
}
// Auto clearing
if (Settings.AUTO_CLEAR)
{
ExpireManager.runTask();
}
// World generators: // World generators:
final ConfigurationSection section = config.getConfigurationSection("worlds"); final ConfigurationSection section = config.getConfigurationSection("worlds");
if (section != null) if (section != null)

View File

@ -64,7 +64,7 @@ public class Trim extends SubCommand
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)
{ {
@ -175,14 +175,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, whenDone);
ChunkManager.manager.deleteRegionFiles(world, chunks);
} }
public static void sendMessage(final String message) public static void sendMessage(final String message) {
{ PS.log("&3PlotSquared -> World trim&8: &7" + message);
PS.debug("&3PlotSquared -> World trim&8: &7" + message);
} }
public PlotId getId(final String id) public PlotId getId(final String id)
@ -244,13 +242,15 @@ public class Trim extends SubCommand
final ArrayList<ChunkLoc> empty = new ArrayList<>(); final ArrayList<ChunkLoc> empty = new ArrayList<>();
getTrimRegions(empty, world, new Runnable() getTrimRegions(empty, world, new Runnable()
{ {
public void run() {
deleteChunks(world, empty, new Runnable() {
@Override @Override
public void run() public void run() {
{
deleteChunks(world, empty);
PS.log("$1Trim task complete!"); PS.log("$1Trim task complete!");
} }
}); });
}
});
return true; return true;
} }
} }

View File

@ -125,7 +125,9 @@ 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 Plot hasPlot(final String world, final ChunkLoc chunk); 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); public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);

View File

@ -193,6 +193,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()
{ {

View File

@ -137,10 +137,9 @@ public class BukkitChunkManager extends ChunkManager
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();
} }
try try
@ -154,23 +153,28 @@ 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);
TaskManager.runTaskAsync(new Runnable() }
{
@Override
public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks, final Runnable whenDone) {
TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() public void run()
{ {
for (final ChunkLoc loc : chunks) for (final 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();
}
} }
}); });
} }

View File

@ -491,8 +491,12 @@ public class SpongeMain implements IPlotMain, PluginContainer
} }
@Override @Override
public void disable() public File getWorldContainer() {
{ return new File("world");
}
@Override
public void disable() {
PS.get().disable(); PS.get().disable();
THIS = null; THIS = null;
} }

View File

@ -139,6 +139,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(final String world, final ChunkLoc chunk) public Plot hasPlot(final String world, final ChunkLoc chunk)
{ {

Binary file not shown.

Binary file not shown.