the quick, dirty, jungle-proof edit
This commit is contained in:
parent
2e07dcbb1a
commit
1d7d4961d3
3 changed files with 78 additions and 28 deletions
|
@ -1,5 +1,8 @@
|
|||
package iieLoadSaveEntireWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
@ -11,6 +14,7 @@ public class LoadProcess implements Runnable
|
|||
final int totalRegions;
|
||||
int[] currentRegion;
|
||||
|
||||
//NEW PROCESS
|
||||
LoadProcess(String name, WorldObj newWorld)
|
||||
{
|
||||
ConfigProcess.addNew(name, newWorld);
|
||||
|
@ -19,7 +23,7 @@ public class LoadProcess implements Runnable
|
|||
totalRegions = newWorld.total;
|
||||
currentRegion = newWorld.current;
|
||||
}
|
||||
|
||||
//RESUME
|
||||
LoadProcess(String name)
|
||||
{
|
||||
final WorldObj unfinished = ConfigProcess.getUnfinished(name);
|
||||
|
@ -108,8 +112,8 @@ public class LoadProcess implements Runnable
|
|||
|
||||
//==================================RUN=================================
|
||||
|
||||
private static volatile boolean ready = true;
|
||||
private volatile int unqueued = 0;
|
||||
private volatile boolean ready = true;
|
||||
private volatile int unqueued = 0;
|
||||
public final void run()
|
||||
{
|
||||
if (!ready) return;
|
||||
|
@ -128,6 +132,52 @@ public class LoadProcess implements Runnable
|
|||
{
|
||||
TaskManager.finish();
|
||||
}
|
||||
while (skip(currentRegion))
|
||||
{
|
||||
if (!setNextRegion())
|
||||
{
|
||||
TaskManager.finish();
|
||||
}
|
||||
}
|
||||
ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================SKIP REGION?=============================
|
||||
//this is specific to our new TerrainControl world
|
||||
//skip all regions that contain jungle biome
|
||||
private static final boolean skip(int[] r)
|
||||
{
|
||||
switch(r[0])
|
||||
{
|
||||
case -17 : return check(r[1], -15,-14 );
|
||||
case -16 : return check(r[1], -20,-19,-18,-17,-16,-15,-14 );
|
||||
case -15 : return check(r[1], -20,-19,-18,-17,-16,-15 );
|
||||
case -14 : return check(r[1], -19,-18,-17,-16,-15 );
|
||||
case -13 : return check(r[1], -19,-18,-17,-16,-15 );
|
||||
case -12 : return check(r[1], -18,-17,-16,-15 );
|
||||
case -11 : return check(r[1], -19,-18,-17,-16,-15,-14 );
|
||||
case -10 : return check(r[1], -19,-18,-17,-16,-15,-14 );
|
||||
case -9 : return check(r[1], -19,-18,-17,-16,-15,-14 );
|
||||
case -8 : return check(r[1], -18,-17,-16,-15 );
|
||||
case -7 : return check(r[1], -18,-17,-16,-15 );
|
||||
case -6 : return check(r[1], -17,-16,-15 );
|
||||
|
||||
case -3 : return check(r[1], -7, -6, -5 );
|
||||
case -2 : return check(r[1], -6, -5, -4 );
|
||||
case -1 : return check(r[1], -7, -6, -5, -4 );
|
||||
case 0 : return check(r[1], -8, -7, -6, -5, -4 );
|
||||
case 1 : return check(r[1], -9, -8, -7, -6, -5, -4 );
|
||||
case 2 : return check(r[1], -9, -8, -7, -6, -5 );
|
||||
case 3 : return check(r[1], -7, -6 );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static final boolean check(int z, int... skips)
|
||||
{
|
||||
for (int skip : skips)
|
||||
{
|
||||
if (z == skip) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,17 @@ public class Main extends JavaPlugin {
|
|||
ConfigProcess.plugin = this;
|
||||
ConfigProcess.config = getConfig();
|
||||
|
||||
if (TaskManager.crashResume())
|
||||
if (ConfigProcess.crashResume())
|
||||
{
|
||||
Bukkit.getScheduler().runTaskLater(this, new CrashResume(), 1200);
|
||||
}
|
||||
}
|
||||
private static final class CrashResume implements Runnable
|
||||
{
|
||||
public final void run()
|
||||
{
|
||||
Bukkit.getLogger().info("...resuming from crash");
|
||||
TaskManager.start(null, ConfigProcess.getCrashResume());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,44 +11,34 @@ public class TaskManager {
|
|||
|
||||
private static boolean inProgress = false;
|
||||
|
||||
static LoadProcess loadProcess;
|
||||
private static ConfigProcess configProcess;
|
||||
static LoadProcess loadProcess;
|
||||
static ConfigProcess configProcess;
|
||||
private static BukkitTask loadTask;
|
||||
private static BukkitTask configTask;
|
||||
|
||||
|
||||
//===================================CONTROLS==================================
|
||||
|
||||
private static final void schedule(long delay)
|
||||
private static final void schedule()
|
||||
{
|
||||
loadTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, delay, 100);
|
||||
configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, configProcess, delay, 200);
|
||||
loadTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, loadProcess, 0, 200);
|
||||
configTask = Bukkit.getScheduler().runTaskTimer(ConfigProcess.plugin, configProcess, 0, 400);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
private static final boolean start(String[] args, String name)
|
||||
static final boolean start(String[] args, String name)
|
||||
{
|
||||
if (ConfigProcess.isNew(name))
|
||||
boolean isNew;
|
||||
if (isNew = ConfigProcess.isNew(name))
|
||||
{
|
||||
loadProcess = new LoadProcess(name, WorldObj.generate(args));
|
||||
configProcess = new ConfigProcess(name);
|
||||
schedule(0);
|
||||
return true;
|
||||
}
|
||||
loadProcess = new LoadProcess(name);
|
||||
configProcess = new ConfigProcess(name);
|
||||
schedule(0);
|
||||
return false;
|
||||
}
|
||||
static final boolean crashResume()
|
||||
{
|
||||
if (ConfigProcess.crashResume())
|
||||
else
|
||||
{
|
||||
loadProcess = new LoadProcess(ConfigProcess.getCrashResume());
|
||||
configProcess = new ConfigProcess(false);
|
||||
schedule(1200);
|
||||
return true;
|
||||
loadProcess = new LoadProcess(name);
|
||||
}
|
||||
return false;
|
||||
configProcess = new ConfigProcess(name);
|
||||
schedule();
|
||||
return isNew;
|
||||
}
|
||||
private static final void stop_or_finish()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue