- saveDefaultConfig() - There's no default config in the plugin
- The config process didn't put the world name in the config when saving
- No plugin.yml
- The Main class was created in each class it got referenced (Main
plugin=new Main()), Bukkit doesn't allow that
- TaskManager.configProcess was never set
Still not much for an untested version.
This commit is contained in:
Norbi Peti 2016-11-26 16:21:41 +01:00
parent c1ad76fe25
commit 3dfefcb776
10 changed files with 140 additions and 135 deletions

View file

@ -5,15 +5,18 @@ import org.bukkit.configuration.file.FileConfiguration;
public class ConfigProcess implements Runnable { public class ConfigProcess implements Runnable {
//STATIC //STATIC
private static final Main plugin = new Main(); private static FileConfiguration config;
private static final FileConfiguration config = plugin.getConfig();
static final boolean isNew(String name) static final boolean isNew(String name)
{ {
if(config == null)
config = Main.getPlugin().getConfig();
return !config.contains(name); return !config.contains(name);
} }
static final WorldObject getUnfinished(String name) static final WorldObject getUnfinished(String name)
{ {
if(config == null)
config = Main.getPlugin().getConfig();
return new WorldObject return new WorldObject
( (
config.getInt(name + ".width"), config.getInt(name + ".width"),
@ -40,19 +43,23 @@ public class ConfigProcess implements Runnable {
private final String name = TaskManager.loadProcess.worldname; private final String name = TaskManager.loadProcess.worldname;
public final void run() public final void run()
{ {
config.set(".currentRegion.x", TaskManager.loadProcess.currentRegion[0]); if(config == null)
config.set(".currentRegion.z", TaskManager.loadProcess.currentRegion[1]); config = Main.getPlugin().getConfig();
config.set(".n", TaskManager.loadProcess.n); config.set(name + ".currentRegion.x", TaskManager.loadProcess.currentRegion[0]);
config.set(".c", TaskManager.loadProcess.c); config.set(name + ".currentRegion.z", TaskManager.loadProcess.currentRegion[1]);
config.set(".D", TaskManager.loadProcess.D); config.set(name + ".n", TaskManager.loadProcess.n);
config.set(".d", TaskManager.loadProcess.d); config.set(name + ".c", TaskManager.loadProcess.c);
config.set(".B", TaskManager.loadProcess.B ? 1 : 0); config.set(name + ".D", TaskManager.loadProcess.D);
plugin.saveConfig(); config.set(name + ".d", TaskManager.loadProcess.d);
config.set(name + ".B", TaskManager.loadProcess.B ? 1 : 0);
Main.getPlugin().saveConfig();
} }
final void finish() final void finish()
{ {
if(config == null)
config = Main.getPlugin().getConfig();
config.set("finished", name); config.set("finished", name);
config.set(name, null); config.set(name, null);
plugin.saveConfig(); Main.getPlugin().saveConfig();
} }
} }

View file

@ -3,10 +3,16 @@ package iieLoadSaveEntireWorld;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
private static Main plugin;
public static Main getPlugin()
{
return plugin;
}
public void onEnable() public void onEnable()
{ {
saveDefaultConfig(); //saveDefaultConfig();
plugin = this;
getCommand("beginfullmapload").setExecutor(new TaskManager.StartCommand()); getCommand("beginfullmapload").setExecutor(new TaskManager.StartCommand());
getCommand("stopfullmapload").setExecutor(new TaskManager.StopCommand()); getCommand("stopfullmapload").setExecutor(new TaskManager.StopCommand());
} }

View file

@ -8,9 +8,6 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
public class TaskManager { public class TaskManager {
private static final Main plugin = new Main();
static boolean inProgress = false; static boolean inProgress = false;
static LoadProcess loadProcess; static LoadProcess loadProcess;
static ConfigProcess configProcess; static ConfigProcess configProcess;
@ -22,8 +19,9 @@ public class TaskManager {
{ {
inProgress = true; inProgress = true;
TaskManager.loadProcess = loadProcess; TaskManager.loadProcess = loadProcess;
TaskManager.loadTask = Bukkit.getScheduler().runTaskTimer( plugin, loadProcess, 0, 10 ); TaskManager.configProcess = new ConfigProcess();
TaskManager.configTask = Bukkit.getScheduler().runTaskTimer( plugin, new ConfigProcess(), 0, 200 ); TaskManager.loadTask = Bukkit.getScheduler().runTaskTimer( Main.getPlugin(), loadProcess, 0, 10 );
TaskManager.configTask = Bukkit.getScheduler().runTaskTimer( Main.getPlugin(), configProcess, 0, 200 );
} }
static final void finish() static final void finish()
{ {

View file

View file

@ -1,6 +0,0 @@
main: iieLoadSaveEntireWorld.Main
version: 1.0.0
name: LoadSaveEntireWorld
commands:
loadsaveentireworld:
description: loads and saves the entire map, in 32x32 chunk sections